mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
provisioning: makes the interval for polling for changes configurable
This commit is contained in:
@@ -5,7 +5,7 @@ bulkDashboard() {
|
|||||||
requiresJsonnet
|
requiresJsonnet
|
||||||
|
|
||||||
COUNTER=0
|
COUNTER=0
|
||||||
MAX=4
|
MAX=400
|
||||||
while [ $COUNTER -lt $MAX ]; do
|
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}' }"
|
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
|
let COUNTER=COUNTER+1
|
||||||
|
@@ -81,6 +81,10 @@ func (cr *configReader) readConfig() ([]*DashboardsAsConfig, error) {
|
|||||||
if dashboards[i].OrgId == 0 {
|
if dashboards[i].OrgId == 0 {
|
||||||
dashboards[i].OrgId = 1
|
dashboards[i].OrgId = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if dashboards[i].IntervalSeconds == 0 {
|
||||||
|
dashboards[i].IntervalSeconds = 3
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dashboards, nil
|
return dashboards, nil
|
||||||
|
@@ -68,6 +68,7 @@ func validateDashboardAsConfig(cfg []*DashboardsAsConfig) {
|
|||||||
So(len(ds.Options), ShouldEqual, 1)
|
So(len(ds.Options), ShouldEqual, 1)
|
||||||
So(ds.Options["path"], ShouldEqual, "/var/lib/grafana/dashboards")
|
So(ds.Options["path"], ShouldEqual, "/var/lib/grafana/dashboards")
|
||||||
So(ds.DisableDeletion, ShouldBeTrue)
|
So(ds.DisableDeletion, ShouldBeTrue)
|
||||||
|
So(ds.IntervalSeconds, ShouldEqual, 10)
|
||||||
|
|
||||||
ds2 := cfg[1]
|
ds2 := cfg[1]
|
||||||
So(ds2.Name, ShouldEqual, "default")
|
So(ds2.Name, ShouldEqual, "default")
|
||||||
@@ -78,4 +79,5 @@ func validateDashboardAsConfig(cfg []*DashboardsAsConfig) {
|
|||||||
So(len(ds2.Options), ShouldEqual, 1)
|
So(len(ds2.Options), ShouldEqual, 1)
|
||||||
So(ds2.Options["path"], ShouldEqual, "/var/lib/grafana/dashboards")
|
So(ds2.Options["path"], ShouldEqual, "/var/lib/grafana/dashboards")
|
||||||
So(ds2.DisableDeletion, ShouldBeFalse)
|
So(ds2.DisableDeletion, ShouldBeFalse)
|
||||||
|
So(ds2.IntervalSeconds, ShouldEqual, 3)
|
||||||
}
|
}
|
||||||
|
@@ -21,8 +21,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
checkDiskForChangesInterval = time.Second * 3
|
|
||||||
|
|
||||||
ErrFolderNameMissing = errors.New("Folder name missing")
|
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)
|
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
|
running := false
|
||||||
|
|
||||||
|
@@ -6,6 +6,7 @@ providers:
|
|||||||
folder: 'developers'
|
folder: 'developers'
|
||||||
editable: true
|
editable: true
|
||||||
disableDeletion: true
|
disableDeletion: true
|
||||||
|
intervalSeconds: 10
|
||||||
type: file
|
type: file
|
||||||
options:
|
options:
|
||||||
path: /var/lib/grafana/dashboards
|
path: /var/lib/grafana/dashboards
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
folder: 'developers'
|
folder: 'developers'
|
||||||
editable: true
|
editable: true
|
||||||
disableDeletion: true
|
disableDeletion: true
|
||||||
|
intervalSeconds: 10
|
||||||
type: file
|
type: file
|
||||||
options:
|
options:
|
||||||
path: /var/lib/grafana/dashboards
|
path: /var/lib/grafana/dashboards
|
||||||
|
@@ -17,6 +17,7 @@ type DashboardsAsConfig struct {
|
|||||||
Editable bool
|
Editable bool
|
||||||
Options map[string]interface{}
|
Options map[string]interface{}
|
||||||
DisableDeletion bool
|
DisableDeletion bool
|
||||||
|
IntervalSeconds int64
|
||||||
}
|
}
|
||||||
|
|
||||||
type DashboardsAsConfigV0 struct {
|
type DashboardsAsConfigV0 struct {
|
||||||
@@ -27,6 +28,7 @@ type DashboardsAsConfigV0 struct {
|
|||||||
Editable bool `json:"editable" yaml:"editable"`
|
Editable bool `json:"editable" yaml:"editable"`
|
||||||
Options map[string]interface{} `json:"options" yaml:"options"`
|
Options map[string]interface{} `json:"options" yaml:"options"`
|
||||||
DisableDeletion bool `json:"disableDeletion" yaml:"disableDeletion"`
|
DisableDeletion bool `json:"disableDeletion" yaml:"disableDeletion"`
|
||||||
|
IntervalSeconds int64 `json:"intervalSeconds" yaml:"intervalSeconds"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConfigVersion struct {
|
type ConfigVersion struct {
|
||||||
@@ -45,6 +47,7 @@ type DashboardProviderConfigs struct {
|
|||||||
Editable bool `json:"editable" yaml:"editable"`
|
Editable bool `json:"editable" yaml:"editable"`
|
||||||
Options map[string]interface{} `json:"options" yaml:"options"`
|
Options map[string]interface{} `json:"options" yaml:"options"`
|
||||||
DisableDeletion bool `json:"disableDeletion" yaml:"disableDeletion"`
|
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) {
|
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,
|
Editable: v.Editable,
|
||||||
Options: v.Options,
|
Options: v.Options,
|
||||||
DisableDeletion: v.DisableDeletion,
|
DisableDeletion: v.DisableDeletion,
|
||||||
|
IntervalSeconds: v.IntervalSeconds,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,6 +97,7 @@ func (dc *DashboardAsConfigV1) mapToDashboardAsConfig() []*DashboardsAsConfig {
|
|||||||
Editable: v.Editable,
|
Editable: v.Editable,
|
||||||
Options: v.Options,
|
Options: v.Options,
|
||||||
DisableDeletion: v.DisableDeletion,
|
DisableDeletion: v.DisableDeletion,
|
||||||
|
IntervalSeconds: v.IntervalSeconds,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user