Skip to content

Commit

Permalink
Add UIDs to dashboards (#3042)
Browse files Browse the repository at this point in the history
Automatically add a uid to each dashboard.
This prevents changing URLs when restarting a grafana pod and
re-importing the dashboards via ConfigMaps.

Signed-off-by: Stefan Andres <[email protected]>
  • Loading branch information
stefanandres authored Jul 14, 2024
1 parent e11a4f0 commit fe71568
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/node-mixin/dashboards/node.libsonnet
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
local nodemixin = import '../lib/prom-mixin.libsonnet',
grafanaDashboards+:: {
'nodes.json': nodemixin.new(config=$._config, platform='Linux').dashboard,
'nodes-darwin.json': nodemixin.new(config=$._config, platform='Darwin').dashboard,
'nodes.json': nodemixin.new(config=$._config, platform='Linux', uid=std.md5('nodes.json')).dashboard,
'nodes-darwin.json': nodemixin.new(config=$._config, platform='Darwin', uid=std.md5('nodes-darwin.json')).dashboard,
},
}
9 changes: 6 additions & 3 deletions docs/node-mixin/dashboards/use.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ local diskSpaceUtilisation =
tags=($._config.dashboardTags),
timezone='utc',
refresh='30s',
graphTooltip='shared_crosshair'
graphTooltip='shared_crosshair',
uid=std.md5('node-rsrc-use.json')
)
.addTemplate(datasourceTemplate)
.addTemplate($._clusterTemplate)
Expand Down Expand Up @@ -215,7 +216,8 @@ local diskSpaceUtilisation =
tags=($._config.dashboardTags),
timezone='utc',
refresh='30s',
graphTooltip='shared_crosshair'
graphTooltip='shared_crosshair',
uid=std.md5('node-cluster-rsrc-use.json')
)
.addTemplate(datasourceTemplate)
.addTemplate($._clusterTemplate)
Expand Down Expand Up @@ -326,7 +328,8 @@ local diskSpaceUtilisation =
tags=($._config.dashboardTags),
timezone='utc',
refresh='30s',
graphTooltip='shared_crosshair'
graphTooltip='shared_crosshair',
uid=std.md5('node-multicluster-rsrc-use.json')
)
.addTemplate(datasourceTemplate)
.addRow(
Expand Down
8 changes: 5 additions & 3 deletions docs/node-mixin/lib/prom-mixin.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local table = grafana70.panel.table;

{

new(config=null, platform=null):: {
new(config=null, platform=null, uid=null):: {

local prometheusDatasourceTemplate = {
current: {
Expand Down Expand Up @@ -501,7 +501,8 @@ local table = grafana70.panel.table;
tags=(config.dashboardTags),
timezone='utc',
refresh='30s',
graphTooltip='shared_crosshair'
graphTooltip='shared_crosshair',
uid=std.md5(uid)
)
.addTemplates(templates)
.addRows(rows)
Expand All @@ -512,7 +513,8 @@ local table = grafana70.panel.table;
tags=(config.dashboardTags),
timezone='utc',
refresh='30s',
graphTooltip='shared_crosshair'
graphTooltip='shared_crosshair',
uid=std.md5(uid)
)
.addTemplates(templates)
.addRows(rows),
Expand Down

0 comments on commit fe71568

Please sign in to comment.