Add: Custom tags and prefix in Prometheus Mixin (#8287)

* Add: custom tags and prefix

Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>

* Fix: fmt

Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>
This commit is contained in:
Nicolas Lamirault 2020-12-16 18:49:06 +01:00 committed by GitHub
parent 8dc53c2218
commit aa1ca13025
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 5 deletions

View file

@ -37,5 +37,12 @@
// expression is matched against the `alertmanager` label. // expression is matched against the `alertmanager` label.
// Example: @'http://test-alertmanager\..*' // Example: @'http://test-alertmanager\..*'
nonNotifyingAlertmanagerRegEx: @'', nonNotifyingAlertmanagerRegEx: @'',
grafana: {
prefix: 'Prometheus / ',
tags: ['prometheus-mixin'],
// The default refresh time for all dashboards, default to 60s
refresh: '60s',
},
}, },
} }

View file

@ -10,7 +10,9 @@ local template = grafana.template;
{ {
grafanaDashboards+:: { grafanaDashboards+:: {
'prometheus.json': 'prometheus.json':
g.dashboard('Prometheus Overview') g.dashboard(
'%(prefix)sOverview' % $._config.grafana
)
.addMultiTemplate('job', 'prometheus_build_info', 'job') .addMultiTemplate('job', 'prometheus_build_info', 'job')
.addMultiTemplate('instance', 'prometheus_build_info', 'instance') .addMultiTemplate('instance', 'prometheus_build_info', 'instance')
.addRow( .addRow(
@ -96,7 +98,10 @@ local template = grafana.template;
{ yaxes: g.yaxes('ms') } + { yaxes: g.yaxes('ms') } +
g.stack, g.stack,
) )
), ) + {
tags: $._config.grafana.tags,
refresh: $._config.grafana.refresh,
},
// Remote write specific dashboard. // Remote write specific dashboard.
'prometheus-remote-write.json': 'prometheus-remote-write.json':
local timestampComparison = local timestampComparison =
@ -287,8 +292,10 @@ local template = grafana.template;
legendFormat='{{cluster}}:{{instance}} {{remote_name}}:{{url}}' legendFormat='{{cluster}}:{{instance}} {{remote_name}}:{{url}}'
)); ));
dashboard.new('Prometheus Remote Write', dashboard.new(
editable=true) title='%(prefix)sRemote Write' % $._config.grafana,
editable=true
)
.addTemplate( .addTemplate(
{ {
hide: 0, hide: 0,
@ -372,6 +379,9 @@ local template = grafana.template;
.addPanel(failedSamples) .addPanel(failedSamples)
.addPanel(retriedSamples) .addPanel(retriedSamples)
.addPanel(enqueueRetries) .addPanel(enqueueRetries)
), ) + {
tags: $._config.grafana.tags,
refresh: $._config.grafana.refresh,
},
}, },
} }