From 8f068f2cade5ac7681872940551142d3101896c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Mon, 4 Feb 2019 13:19:11 +0000 Subject: [PATCH] feat(demo): add severity labels with custom colors --- demo/generator.py | 25 ++++++++++++++++--------- demo/karma.yaml | 5 +++++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/demo/generator.py b/demo/generator.py index 35f11c359..abef696e4 100755 --- a/demo/generator.py +++ b/demo/generator.py @@ -136,7 +136,8 @@ class AlwaysOnAlert(AlertGenerator): def alerts(self): def _gen(size, cluster): return [newAlert( - self._labels(instance="server{}".format(i), cluster=cluster), + self._labels(instance="server{}".format(i), cluster=cluster, + severity="info"), self._annotations( summary="Silence this alert, it's always firing") ) for i in xrange(1, size)] @@ -151,7 +152,8 @@ class RandomInstances(AlertGenerator): instances = random.randint(0, 30) return [ newAlert( - self._labels(instance="server{}".format(i), cluster="staging"), + self._labels(instance="server{}".format(i), cluster="staging", + severity="warning"), self._annotations( dashboard="https://www.google.com/search?q=" "server{}".format(i)) @@ -171,7 +173,7 @@ class RandomName(AlertGenerator): newAlert( self._labels(alertname="Alert Nr {}".format(throw), instance="server{}".format(i), - cluster="dev"), + cluster="dev", severity="info"), self._annotations( summary="This is a random alert", dashboard="https://www.google.com/search?q=" @@ -191,7 +193,8 @@ class LowChance(AlertGenerator): return [] return [ newAlert( - self._labels(instance="server{}".format(i), cluster="dev"), + self._labels(instance="server{}".format(i), cluster="dev", + severity="critical"), self._annotations() ) for i in xrange(0, 3) ] @@ -204,7 +207,8 @@ class TimeAnnotation(AlertGenerator): def alerts(self): return [ - newAlert(self._labels(instance="server1", cluster="prod"), + newAlert(self._labels(instance="server1", cluster="prod", + severity="warning"), self._annotations(time=str(int(time.time()))) ) ] @@ -222,7 +226,7 @@ class DiskFreeLowAlert(AlertGenerator): newAlert(self._labels(instance="server{}".format(i), cluster="prod", device="/dev/sda{}".format(i), - mount_point="/disk"), + mount_point="/disk", severity="critical"), self._annotations( summary="Only {}% free space left on /disk".format( spaceFree), @@ -238,7 +242,8 @@ class SilencedAlert(AlertGenerator): def alerts(self): return [ - newAlert(self._labels(instance="server1", cluster="prod"), + newAlert(self._labels(instance="server1", cluster="prod", + severity="info"), self._annotations( alertReference="https://www." "youtube.com/watch?v=dQw4w9WgXcQ") @@ -265,7 +270,8 @@ class MixedAlerts(AlertGenerator): def alerts(self): return [ - newAlert(self._labels(instance="server{}".format(i), cluster="prod"), + newAlert(self._labels(instance="server{}".format(i), cluster="prod", + severity="warning"), self._annotations( alertReference="https://www." "youtube.com/watch?v=dQw4w9WgXcQ") @@ -295,7 +301,8 @@ class LongNameAlerts(AlertGenerator): def alerts(self): def _gen(size, cluster): return [newAlert( - self._labels(instance="server{}".format(i), cluster=cluster), + self._labels(instance="server{}".format(i), cluster=cluster, + severity="info"), self._annotations( verylong="Lorem ipsum dolor sit amet, consectetur " "adipiscing elit, sed do eiusmod tempor incididunt" diff --git a/demo/karma.yaml b/demo/karma.yaml index 8f9f1e2ee..32bac3ed6 100644 --- a/demo/karma.yaml +++ b/demo/karma.yaml @@ -25,6 +25,11 @@ labels: - cluster - instance - "@receiver" + custom: + severity: + info: "#87c4e0" + warning: "#ffae42" + critical: "#ff220c" log: config: false level: warning