Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
333af6fd
Commit
333af6fd
authored
May 31, 2018
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
provisioning: makes the interval for polling for changes configurable
parent
c817aecd
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
15 additions
and
4 deletions
+15
-4
devenv/setup.sh
+1
-1
pkg/services/provisioning/dashboards/config_reader.go
+4
-0
pkg/services/provisioning/dashboards/config_reader_test.go
+2
-0
pkg/services/provisioning/dashboards/file_reader.go
+1
-3
pkg/services/provisioning/dashboards/testdata/test-configs/dashboards-from-disk/dev-dashboards.yaml
+1
-0
pkg/services/provisioning/dashboards/testdata/test-configs/version-0/version-0.yaml
+1
-0
pkg/services/provisioning/dashboards/types.go
+5
-0
No files found.
devenv/setup.sh
View file @
333af6fd
...
@@ -5,7 +5,7 @@ bulkDashboard() {
...
@@ -5,7 +5,7 @@ bulkDashboard() {
requiresJsonnet
requiresJsonnet
COUNTER
=
0
COUNTER
=
0
MAX
=
4
MAX
=
4
00
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
...
...
pkg/services/provisioning/dashboards/config_reader.go
View file @
333af6fd
...
@@ -81,6 +81,10 @@ func (cr *configReader) readConfig() ([]*DashboardsAsConfig, error) {
...
@@ -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
...
...
pkg/services/provisioning/dashboards/config_reader_test.go
View file @
333af6fd
...
@@ -68,6 +68,7 @@ func validateDashboardAsConfig(cfg []*DashboardsAsConfig) {
...
@@ -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) {
...
@@ -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
)
}
}
pkg/services/provisioning/dashboards/file_reader.go
View file @
333af6fd
...
@@ -21,8 +21,6 @@ import (
...
@@ -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 {
...
@@ -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
...
...
pkg/services/provisioning/dashboards/testdata/test-configs/dashboards-from-disk/dev-dashboards.yaml
View file @
333af6fd
...
@@ -6,6 +6,7 @@ providers:
...
@@ -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
...
...
pkg/services/provisioning/dashboards/testdata/test-configs/version-0/version-0.yaml
View file @
333af6fd
...
@@ -3,6 +3,7 @@
...
@@ -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
...
...
pkg/services/provisioning/dashboards/types.go
View file @
333af6fd
...
@@ -17,6 +17,7 @@ type DashboardsAsConfig struct {
...
@@ -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 {
...
@@ -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 {
...
@@ -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
...
@@ -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 {
...
@@ -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
,
})
})
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment