Commit 333af6fd by bergquist

provisioning: makes the interval for polling for changes configurable

parent c817aecd
......@@ -5,7 +5,7 @@ bulkDashboard() {
requiresJsonnet
COUNTER=0
MAX=4
MAX=400
while [ $COUNTER -lt $MAX ]; do
jsonnet -o "dashboards/bulk-testing/dashboard${COUNTER}.json" -e "local bulkDash = import 'dashboards/bulk-testing/bulkdash.jsonnet'; bulkDash + { uid: 'uid-${COUNTER}', title: 'title-${COUNTER}' }"
let COUNTER=COUNTER+1
......
......@@ -81,6 +81,10 @@ func (cr *configReader) readConfig() ([]*DashboardsAsConfig, error) {
if dashboards[i].OrgId == 0 {
dashboards[i].OrgId = 1
}
if dashboards[i].IntervalSeconds == 0 {
dashboards[i].IntervalSeconds = 3
}
}
return dashboards, nil
......
......@@ -68,6 +68,7 @@ func validateDashboardAsConfig(cfg []*DashboardsAsConfig) {
So(len(ds.Options), ShouldEqual, 1)
So(ds.Options["path"], ShouldEqual, "/var/lib/grafana/dashboards")
So(ds.DisableDeletion, ShouldBeTrue)
So(ds.IntervalSeconds, ShouldEqual, 10)
ds2 := cfg[1]
So(ds2.Name, ShouldEqual, "default")
......@@ -78,4 +79,5 @@ func validateDashboardAsConfig(cfg []*DashboardsAsConfig) {
So(len(ds2.Options), ShouldEqual, 1)
So(ds2.Options["path"], ShouldEqual, "/var/lib/grafana/dashboards")
So(ds2.DisableDeletion, ShouldBeFalse)
So(ds2.IntervalSeconds, ShouldEqual, 3)
}
......@@ -21,8 +21,6 @@ import (
)
var (
checkDiskForChangesInterval = time.Second * 3
ErrFolderNameMissing = errors.New("Folder name missing")
)
......@@ -68,7 +66,7 @@ func (fr *fileReader) ReadAndListen(ctx context.Context) error {
fr.log.Error("failed to search for dashboards", "error", err)
}
ticker := time.NewTicker(checkDiskForChangesInterval)
ticker := time.NewTicker(time.Duration(int64(time.Second) * fr.Cfg.IntervalSeconds))
running := false
......
......@@ -6,6 +6,7 @@ providers:
folder: 'developers'
editable: true
disableDeletion: true
intervalSeconds: 10
type: file
options:
path: /var/lib/grafana/dashboards
......
......@@ -3,6 +3,7 @@
folder: 'developers'
editable: true
disableDeletion: true
intervalSeconds: 10
type: file
options:
path: /var/lib/grafana/dashboards
......
......@@ -17,6 +17,7 @@ type DashboardsAsConfig struct {
Editable bool
Options map[string]interface{}
DisableDeletion bool
IntervalSeconds int64
}
type DashboardsAsConfigV0 struct {
......@@ -27,6 +28,7 @@ type DashboardsAsConfigV0 struct {
Editable bool `json:"editable" yaml:"editable"`
Options map[string]interface{} `json:"options" yaml:"options"`
DisableDeletion bool `json:"disableDeletion" yaml:"disableDeletion"`
IntervalSeconds int64 `json:"intervalSeconds" yaml:"intervalSeconds"`
}
type ConfigVersion struct {
......@@ -45,6 +47,7 @@ type DashboardProviderConfigs struct {
Editable bool `json:"editable" yaml:"editable"`
Options map[string]interface{} `json:"options" yaml:"options"`
DisableDeletion bool `json:"disableDeletion" yaml:"disableDeletion"`
IntervalSeconds int64 `json:"intervalSeconds" yaml:"intervalSeconds"`
}
func createDashboardJson(data *simplejson.Json, lastModified time.Time, cfg *DashboardsAsConfig, folderId int64) (*dashboards.SaveDashboardDTO, error) {
......@@ -75,6 +78,7 @@ func mapV0ToDashboardAsConfig(v0 []*DashboardsAsConfigV0) []*DashboardsAsConfig
Editable: v.Editable,
Options: v.Options,
DisableDeletion: v.DisableDeletion,
IntervalSeconds: v.IntervalSeconds,
})
}
......@@ -93,6 +97,7 @@ func (dc *DashboardAsConfigV1) mapToDashboardAsConfig() []*DashboardsAsConfig {
Editable: v.Editable,
Options: v.Options,
DisableDeletion: v.DisableDeletion,
IntervalSeconds: v.IntervalSeconds,
})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment