From d6189955b22b7d2af93d12f42153fecc17b23293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Mon, 27 Mar 2017 18:24:47 -0700 Subject: [PATCH] Add mock data for testing --- Makefile | 6 +- mock/api/v1/alerts/groups | 282 ++++++++++++++++++++++++++++++++++++++ mock/api/v1/silences | 43 ++++++ 3 files changed, 328 insertions(+), 3 deletions(-) create mode 100644 mock/api/v1/alerts/groups create mode 100644 mock/api/v1/silences diff --git a/Makefile b/Makefile index bd5e05e62..9e9343af3 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ NAME := unsee VERSION := $(shell git describe --tags --always --dirty='-dev') # Alertmanager instance used when running locally, points to mock data -ALERTMANAGER_URI := https://raw.githubusercontent.com/prymitive/alertmanager-demo-api/master +ALERTMANAGER_URI := https://raw.githubusercontent.com/cloudflare/unsee/master/mock # Listen port when running locally PORT := 8080 @@ -44,7 +44,7 @@ clean: run: $(NAME) DEBUG=true \ ALERTMANAGER_URI=$(ALERTMANAGER_URI) \ - COLOR_LABELS_UNIQUE="instance" \ + COLOR_LABELS_UNIQUE="instance cluster" \ COLOR_LABELS_STATIC="job" \ PORT=$(PORT) \ ./$(NAME) @@ -59,7 +59,7 @@ run-docker: docker-image docker run \ --name $(NAME) \ -e ALERTMANAGER_URI=$(ALERTMANAGER_URI) \ - -e COLOR_LABELS_UNIQUE="instance" \ + -e COLOR_LABELS_UNIQUE="instance cluster" \ -e COLOR_LABELS_STATIC="job" \ -e PORT=$(PORT) \ -p $(PORT):$(PORT) \ diff --git a/mock/api/v1/alerts/groups b/mock/api/v1/alerts/groups new file mode 100644 index 000000000..96939c8ad --- /dev/null +++ b/mock/api/v1/alerts/groups @@ -0,0 +1,282 @@ +{ + "status": "success", + "data": [ + { + "labels": { + "alertname": "HTTP_Probe_Failed", + "cluster": "dev" + }, + "blocks": [ + { + "routeOpts": { + "receiver": "default", + "groupBy": [ + "alertname", + "cluster" + ], + "groupWait": 30000000000, + "groupInterval": 300000000000, + "repeatInterval": 10800000000000 + }, + "alerts": [ + { + "labels": { + "alertname": "HTTP_Probe_Failed", + "instance": "web1", + "job": "node_exporter", + "cluster": "dev" + }, + "annotations": { + "help": "Example help annotation", + "summary": "Example summary", + "url": "http://localhost/example.html" + }, + "startsAt": "2017-02-18T01:14:36Z", + "endsAt": "0001-01-01T00:00:00Z", + "generatorURL": "http://localhost/graph", + "inhibited": false, + "silenced": 1 + }, + { + "labels": { + "alertname": "HTTP_Probe_Failed", + "instance": "web2", + "job": "node_exporter", + "cluster": "dev" + }, + "annotations": { + "summary": "Example summary" + }, + "startsAt": "2017-02-18T01:14:37Z", + "endsAt": "0001-01-01T00:00:00Z", + "generatorURL": "http://localhost/graph", + "inhibited": false + } + ] + } + ] + }, + { + "labels": { + "alertname": "Host_Down" + }, + "blocks": [ + { + "routeOpts": { + "receiver": "default", + "groupBy": [ + "alertname", + "cluster" + ], + "groupWait": 30000000000, + "groupInterval": 300000000000, + "repeatInterval": 10800000000000 + }, + "alerts": [ + { + "labels": { + "alertname": "Host_Down", + "instance": "server1", + "job": "node_ping", + "cluster": "prod" + }, + "annotations": { + "summary": "Example summary", + "url": "http://localhost/example.html" + }, + "startsAt": "2017-02-18T01:14:38Z", + "endsAt": "0001-01-01T00:00:00Z", + "generatorURL": "http://localhost/graph", + "inhibited": false, + "silenced": 1 + }, + { + "labels": { + "alertname": "Host_Down", + "instance": "server2", + "job": "node_ping", + "cluster": "prod" + }, + "annotations": { + "summary": "Example summary" + }, + "startsAt": "2017-02-18T01:14:39Z", + "endsAt": "0001-01-01T00:00:00Z", + "generatorURL": "http://localhost/graph", + "inhibited": false + }, + { + "labels": { + "alertname": "Host_Down", + "instance": "server3", + "job": "node_ping", + "cluster": "staging" + }, + "annotations": { + "summary": "Example summary" + }, + "startsAt": "2017-02-18T01:14:40Z", + "endsAt": "0001-01-01T00:00:00Z", + "generatorURL": "http://localhost/graph", + "inhibited": false + }, + { + "labels": { + "alertname": "Host_Down", + "instance": "server4", + "job": "node_ping", + "cluster": "staging" + }, + "annotations": { + "summary": "Example summary" + }, + "startsAt": "2017-02-18T01:14:41Z", + "endsAt": "0001-01-01T00:00:00Z", + "generatorURL": "http://localhost/graph", + "inhibited": false + }, + { + "labels": { + "alertname": "Host_Down", + "instance": "server5", + "job": "node_ping", + "cluster": "staging" + }, + "annotations": { + "summary": "Example summary" + }, + "startsAt": "2017-02-18T01:14:42Z", + "endsAt": "0001-01-01T00:00:00Z", + "generatorURL": "http://localhost/graph", + "inhibited": false + }, + { + "labels": { + "alertname": "Host_Down", + "instance": "server6", + "job": "node_ping", + "cluster": "dev" + }, + "annotations": { + "summary": "Example summary" + }, + "startsAt": "2017-02-18T01:14:43Z", + "endsAt": "0001-01-01T00:00:00Z", + "generatorURL": "http://localhost/graph", + "inhibited": false, + "silenced": 2 + }, + { + "labels": { + "alertname": "Host_Down", + "instance": "server7", + "job": "node_ping", + "cluster": "dev" + }, + "annotations": { + "summary": "Example summary" + }, + "startsAt": "2017-02-18T01:14:34Z", + "endsAt": "0001-01-01T00:00:00Z", + "generatorURL": "http://localhost/graph", + "inhibited": false, + "silenced": 2 + }, + { + "labels": { + "alertname": "Host_Down", + "instance": "server8", + "job": "node_ping", + "cluster": "dev" + }, + "annotations": { + "summary": "Example summary" + }, + "startsAt": "2017-02-18T01:14:48Z", + "endsAt": "0001-01-01T00:00:00Z", + "generatorURL": "http://localhost/graph", + "inhibited": false, + "silenced": 2 + } + ] + } + ] + }, + { + "labels": { + "alertname": "Memory_Usage_High", + "cluster": "prod" + }, + "blocks": [ + { + "routeOpts": { + "receiver": "default", + "groupBy": [ + "alertname", + "cluster" + ], + "groupWait": 30000000000, + "groupInterval": 300000000000, + "repeatInterval": 10800000000000 + }, + "alerts": [ + { + "labels": { + "alertname": "Memory_Usage_Too_High", + "instance": "server2", + "job": "node_exporter", + "cluster": "prod" + }, + "annotations": { + "alert": "Memory usage exceeding threshold", + "dashboard": "http://localhost/dashboard.html" + }, + "startsAt": "2017-02-18T01:14:36Z", + "endsAt": "0001-01-01T00:00:00Z", + "generatorURL": "http://localhost/graph", + "inhibited": false + } + ] + } + ] + }, + { + "labels": { + "alertname": "Free_Disk_Space_Too_Low", + "cluster": "staging" + }, + "blocks": [ + { + "routeOpts": { + "receiver": "default", + "groupBy": [ + "alertname", + "cluster" + ], + "groupWait": 30000000000, + "groupInterval": 300000000000, + "repeatInterval": 10800000000000 + }, + "alerts": [ + { + "labels": { + "alertname": "Memory_Usage_Too_High", + "instance": "server5", + "job": "node_exporter", + "cluster": "staging" + }, + "annotations": { + "alert": "Less than 10% disk space is free", + "dashboard": "http://localhost/dashboard.html" + }, + "startsAt": "2017-02-18T01:14:38Z", + "endsAt": "0001-01-01T00:00:00Z", + "generatorURL": "http://localhost/graph", + "inhibited": false + } + ] + } + ] + } + ] +} diff --git a/mock/api/v1/silences b/mock/api/v1/silences new file mode 100644 index 000000000..4323e6374 --- /dev/null +++ b/mock/api/v1/silences @@ -0,0 +1,43 @@ +{ + "status": "success", + "data": { + "silences": [ + { + "id": 1, + "matchers": [ + { + "name": "instance", + "value": "web1", + "isRegex": false + } + ], + "startsAt": "2017-02-18T01:34:34Z", + "endsAt": "0001-01-01T00:00:00Z", + "createdAt": "2017-02-18T01:34:34Z", + "createdBy": "john@unicorn.corp", + "comment": "Silenced instance" + }, + { + "id": 2, + "matchers": [ + { + "name": "alertname", + "value": "Host_Down", + "isRegex": false + }, + { + "name": "cluster", + "value": "dev", + "isRegex": false + } + ], + "startsAt": "2017-02-18T01:34:34Z", + "endsAt": "0001-01-01T00:00:00Z", + "createdAt": "2017-02-18T01:34:34Z", + "createdBy": "john@unicorn.corp", + "comment": "Silenced Host_Down alerts in the dev cluster" + } + ], + "totalSilences": 2 + } +}