-
Notifications
You must be signed in to change notification settings - Fork 177
Copy some dashboard opinions from kubernete-mixin and apply to all dashboards. #235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…shboards. Previously, this would happen automatically as all mixins were merged into one. Now we keep mixins in different namespaces, this needs to be done by out grafana jsonnet code. Opinions are: // - Dashboard UIDs should be the md5 hash of their filename. // - Timezone should be default (ie local). // - Tooltip should only show a single value. Signed-off-by: Tom Wilkie <[email protected]>
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,17 +10,48 @@ | |
| // New API: Mixins go in the mixins map. | ||
| mixins+:: {}, | ||
|
|
||
| // emptyMixin allows us to reliably do `mixin.grafanaDashboards` without | ||
| // mixinProto allows us to reliably do `mixin.grafanaDashboards` without | ||
| // having to check the field exists first. Some mixins don't declare all | ||
| // the fields, and thats fine. | ||
| local emptyMixin = { | ||
| grafanaDashboards+: {}, | ||
| // | ||
| // We also use this to add a little "opinion": | ||
| // - Dashboard UIDs should be the md5 hash of their filename. | ||
| // - Timezone should be "default" (ie local). | ||
| // - Tooltip should only show a single value. | ||
| local mixinProto = { | ||
| grafanaDashboards+:: {}, | ||
| } + { | ||
| local grafanaDashboards = super.grafanaDashboards, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just to clarify,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, thats just there so we can reliably reference super.grafanaDashboards (you can do std.hasField(super, ...). |
||
|
|
||
| grafanaDashboards+:: { | ||
| [filename]: | ||
| local dashboard = grafanaDashboards[filename]; | ||
| dashboard { | ||
| uid: std.md5(filename), | ||
| timezone: '', | ||
|
|
||
| [if std.objectHas(dashboard, 'rows') then 'rows']: [ | ||
| row { | ||
| panels: [ | ||
| panel { | ||
| tooltip+: { | ||
| shared: false, | ||
| }, | ||
| } | ||
| for panel in super.panels | ||
| ], | ||
| } | ||
| for row in super.rows | ||
| ], | ||
| } | ||
| for filename in std.objectFields(grafanaDashboards) | ||
| }, | ||
| }, | ||
|
|
||
| // Legacy extension points for you to add your own dashboards. | ||
| grafanaDashboards+:: std.foldr( | ||
| function(mixinName, acc) | ||
| local mixin = $.mixins[mixinName] + emptyMixin; | ||
| local mixin = $.mixins[mixinName] + mixinProto; | ||
| if !std.objectHas(mixin, 'grafanaDashboardFolder') | ||
| then acc + mixin.grafanaDashboards | ||
| else acc, | ||
|
|
@@ -30,7 +61,7 @@ | |
|
|
||
| dashboardsByFolder+:: std.foldr( | ||
| function(mixinName, acc) | ||
| local mixin = $.mixins[mixinName] + emptyMixin; | ||
| local mixin = $.mixins[mixinName] + mixinProto; | ||
| if std.objectHas(mixin, 'grafanaDashboardFolder') | ||
| then acc { | ||
| [mixin.grafanaDashboardFolder]: mixin.grafanaDashboards, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldsounds like we do validation here – but we actually just force this behaviour