Use a config variable for the Prometheus name

Signed-off-by: beorn7 <beorn@grafana.com>
This commit is contained in:
beorn7 2019-06-27 14:34:11 +02:00
parent 613cb5430c
commit 1336a28848
2 changed files with 21 additions and 13 deletions

View File

@ -14,7 +14,7 @@
severity: 'critical',
},
annotations: {
message: 'Prometheus failed to reload config, see container logs',
message: 'Prometheus %(prometheusName)s failed to reload config, see container logs' % $._config,
},
},
{
@ -31,7 +31,7 @@
severity: 'warning',
},
annotations: {
message: "Prometheus' alert notification queue is running full for {{$labels.namespace}}/{{$labels.pod}}",
message: "Prometheus's alert notification queue is running full for %(prometheusName)s" % $._config,
},
},
{
@ -49,7 +49,7 @@
severity: 'warning',
},
annotations: {
message: '{{ printf "%.1f" $value }}% errors while sending alerts from Prometheus {{$labels.namespace}}/{{$labels.pod}} to Alertmanager {{$labels.Alertmanager}}',
message: '{{ printf "%%.1f" $value }}%% errors while sending alerts from Prometheus %(prometheusName)s to Alertmanager {{$labels.Alertmanager}}' % $._config,
},
},
{
@ -68,7 +68,7 @@
severity: 'critical',
},
annotations: {
message: '{{ printf "%.1f" $value }}% errors while sending alerts from Prometheus {{$labels.namespace}}/{{$labels.pod}} to Alertmanager {{$labels.Alertmanager}}',
message: '{{ printf "%%.1f" $value }}%% errors while sending alerts from Prometheus %(prometheusName)s to Alertmanager {{$labels.Alertmanager}}' % $._config,
},
},
{
@ -81,7 +81,7 @@
severity: 'warning',
},
annotations: {
message: 'Prometheus {{$labels.namespace}}/{{$labels.pod}} is not connected to any Alertmanagers',
message: 'Prometheus %(prometheusName)s is not connected to any Alertmanagers' % $._config,
},
},
{
@ -94,7 +94,7 @@
severity: 'warning',
},
annotations: {
message: '{{$labels.job}} at {{$labels.instance}} had {{$value | humanize}} reload failures over the last four hours.',
message: 'Prometheus %(prometheusName)s had {{$value | humanize}} reload failures over the last four hours.' % $._config,
},
},
{
@ -107,7 +107,7 @@
severity: 'warning',
},
annotations: {
message: '{{$labels.job}} at {{$labels.instance}} had {{$value | humanize}} compaction failures over the last four hours.',
message: 'Prometheus %(prometheusName)s had {{$value | humanize}} compaction failures over the last four hours.' % $._config,
},
},
{
@ -120,7 +120,7 @@
severity: 'warning',
},
annotations: {
message: '{{$labels.job}} at {{$labels.instance}} has a corrupted write-ahead log (WAL).',
message: 'Prometheus %(prometheusName)s has a corrupted write-ahead log (WAL).' % $._config,
},
},
{
@ -133,7 +133,7 @@
severity: 'warning',
},
annotations: {
message: "Prometheus {{$labels.namespace }}/{{ $labels.pod}} isn't ingesting samples.",
message: "Prometheus %(prometheusName)s isn't ingesting samples." % $._config,
},
},
{
@ -146,7 +146,7 @@
severity: 'warning',
},
annotations: {
message: '{{$labels.namespace}}/{{$labels.pod}} has many samples rejected due to duplicate timestamps but different values',
message: 'Prometheus %(prometheusName)s has many samples rejected due to duplicate timestamps but different values' % $._config,
},
},
{
@ -169,7 +169,7 @@
severity: 'critical',
},
annotations: {
message: 'Prometheus failed to send {{ printf "%.1f" $value }}% samples',
message: 'Prometheus %(prometheusName)s failed to send {{ printf "%%.1f" $value }}%% samples' % $._config,
},
},
{
@ -187,7 +187,7 @@
severity: 'critical',
},
annotations: {
message: 'Prometheus remote write is {{ printf "%.1f" $value }}s behind.',
message: 'Prometheus %(prometheusName)s remote write is {{ printf "%%.1f" $value }}s behind.' % $._config,
},
},
{
@ -200,7 +200,7 @@
severity: 'critical',
},
annotations: {
message: 'Prometheus failed to evaluate {{ printf "%.1f" $value }} rules / s',
message: 'Prometheus %(prometheusName)s failed to evaluate {{ printf "%%.1f" $value }} rules / s' % $._config,
},
},
],

View File

@ -3,5 +3,13 @@
// Selectors are inserted between {} in Prometheus queries.
prometheusSelector: 'job="prometheus"',
alertmanagerSelector: 'job="alertmanager"',
// prometheusName is inserted into annotations to name the Prometheus
// instance affected by the alert.
prometheusName: '{{$labels.instance}}',
// If you run Prometheus on Kubernetes with the Prometheus
// Operator, you can make use of the configured target labels for
// nicer naming:
// prometheusNameTemplate: '{{$labels.namespace}}/{{$labels.pod}}'
},
}