fix(demo): add missing job labels

We have config for job labels, but no labels on alerts, fix it
This commit is contained in:
Łukasz Mierzwa
2019-03-20 20:30:58 +00:00
parent 2e9ee9e69a
commit 23f51f9f7b

View File

@@ -137,7 +137,7 @@ class AlwaysOnAlert(AlertGenerator):
def _gen(size, cluster):
return [newAlert(
self._labels(instance="server{}".format(i), cluster=cluster,
severity="info"),
severity="info", job="node_exporter"),
self._annotations(
summary="Silence this alert, it's always firing")
) for i in xrange(1, size)]
@@ -153,7 +153,7 @@ class RandomInstances(AlertGenerator):
return [
newAlert(
self._labels(instance="server{}".format(i), cluster="staging",
severity="warning"),
severity="warning", job="node_exporter"),
self._annotations(
dashboard="https://www.google.com/search?q="
"server{}".format(i))
@@ -173,7 +173,8 @@ class RandomName(AlertGenerator):
newAlert(
self._labels(alertname="Alert Nr {}".format(throw),
instance="server{}".format(i),
cluster="dev", severity="info"),
cluster="dev", severity="info",
job="random_exporter"),
self._annotations(
summary="This is a random alert",
dashboard="https://www.google.com/search?q="
@@ -194,7 +195,7 @@ class LowChance(AlertGenerator):
return [
newAlert(
self._labels(instance="server{}".format(i), cluster="dev",
severity="critical"),
severity="critical", job="random_exporter"),
self._annotations()
) for i in xrange(0, 3)
]
@@ -208,7 +209,7 @@ class TimeAnnotation(AlertGenerator):
def alerts(self):
return [
newAlert(self._labels(instance="server1", cluster="prod",
severity="warning"),
severity="warning", job="ntp_exporter"),
self._annotations(time=str(int(time.time())))
)
]
@@ -226,7 +227,8 @@ class DiskFreeLowAlert(AlertGenerator):
newAlert(self._labels(instance="server{}".format(i),
cluster="prod",
device="/dev/sda{}".format(i),
mount_point="/disk", severity="critical"),
mount_point="/disk", severity="critical",
job="node_exporter"),
self._annotations(
summary="Only {}% free space left on /disk".format(
spaceFree),
@@ -243,7 +245,7 @@ class SilencedAlert(AlertGenerator):
def alerts(self):
return [
newAlert(self._labels(instance="server1", cluster="prod",
severity="info"),
severity="info", job="mysql_exporter"),
self._annotations(
alertReference="https://www."
"youtube.com/watch?v=dQw4w9WgXcQ")
@@ -279,7 +281,7 @@ class MixedAlerts(AlertGenerator):
def alerts(self):
return [
newAlert(self._labels(instance="server{}".format(i), cluster="prod",
severity="warning"),
severity="warning", job="node_exporter"),
self._annotations(
alertReference="https://www."
"youtube.com/watch?v=dQw4w9WgXcQ")
@@ -310,7 +312,7 @@ class LongNameAlerts(AlertGenerator):
def _gen(size, cluster):
return [newAlert(
self._labels(instance="server{}".format(i), cluster=cluster,
severity="info"),
severity="info", job="textfile_exporter"),
self._annotations(
verylong="Lorem ipsum dolor sit amet, consectetur "
"adipiscing elit, sed do eiusmod tempor incididunt"
@@ -336,7 +338,7 @@ class InhibitedAlert(AlertGenerator):
def alerts(self):
return [
newAlert(self._labels(instance="server1", cluster="prod",
severity="warning"),
severity="warning", job="textfile_exporter"),
self._annotations()
)
]
@@ -349,7 +351,7 @@ class InhibitingAlert(AlertGenerator):
def alerts(self):
return [
newAlert(self._labels(instance="server1", cluster="prod",
severity="critical"),
severity="critical", job="textfile_exporter"),
self._annotations()
)
]
@@ -362,7 +364,7 @@ class SilencedAlertWithJiraLink(AlertGenerator):
def alerts(self):
return [
newAlert(self._labels(instance="server%d" % i, cluster="staging",
severity="critical"),
severity="critical", job="node_exporter"),
self._annotations(
dashboard="https://www.atlassian.com/software/jira")
) for i in xrange(1, 9)