Merge pull request #87 from cloudflare/livemocks

Generate mock files from a live Alertmanager instance
This commit is contained in:
Łukasz Mierzwa
2017-05-02 10:34:34 +01:00
committed by GitHub
41 changed files with 3305 additions and 1065 deletions

View File

@@ -1,7 +1,6 @@
package alertmanager_test
import (
"strings"
"testing"
"github.com/cloudflare/unsee/alertmanager"
@@ -12,8 +11,6 @@ import (
httpmock "gopkg.in/jarcoal/httpmock.v1"
)
var testVersions = []string{"0.4", "0.5", "0.6.1"}
func TestGetAlerts(t *testing.T) {
log.SetLevel(log.ErrorLevel)
config.Config.AlertmanagerURI = "http://localhost"
@@ -21,13 +18,13 @@ func TestGetAlerts(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()
for _, version := range testVersions {
for _, version := range mock.ListAllMocks() {
httpmock.Reset()
mock.RegisterURL("http://localhost/api/v1/status", version, "status")
mock.RegisterURL("http://localhost/api/v1/alerts/groups", version, "alerts/groups")
v := alertmanager.GetVersion()
if !strings.HasPrefix(v, version) {
if v != version {
t.Errorf("GetVersion() returned '%s', expected '%s'", v, version)
}
@@ -35,8 +32,8 @@ func TestGetAlerts(t *testing.T) {
if err != nil {
t.Errorf("GetAlerts(%s) failed: %s", version, err.Error())
}
if len(groups) != 4 {
t.Errorf("Got %d groups, expected %d", len(groups), 4)
if len(groups) != 6 {
t.Errorf("Got %d groups, expected 6", len(groups))
}
}
}
@@ -48,13 +45,13 @@ func TestGetSilences(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()
for _, version := range testVersions {
for _, version := range mock.ListAllMocks() {
httpmock.Reset()
mock.RegisterURL("http://localhost/api/v1/status", version, "status")
mock.RegisterURL("http://localhost/api/v1/silences", version, "silences")
v := alertmanager.GetVersion()
if !strings.HasPrefix(v, version) {
if v != version {
t.Errorf("GetVersion() returned '%s', expected '%s'", v, version)
}

0
mock/0.4.0/.ok Normal file
View File

View File

@@ -0,0 +1,332 @@
{
"data": [
{
"blocks": [
{
"alerts": [
{
"annotations": {
"alert": "Less than 10% disk space is free",
"dashboard": "http://localhost/dashboard.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Free_Disk_Space_Too_Low",
"cluster": "staging",
"instance": "server5",
"job": "node_exporter"
},
"startsAt": "2017-05-01T20:44:55.763656584Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Free_Disk_Space_Too_Low",
"cluster": "staging"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"help": "Example help annotation",
"summary": "Example summary",
"url": "http://localhost/example.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev",
"instance": "web1",
"job": "node_exporter"
},
"silenced": 1,
"startsAt": "2017-05-01T20:44:55.763656584Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev",
"instance": "web2",
"job": "node_exporter"
},
"startsAt": "2017-05-01T20:44:55.763656584Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server6",
"job": "node_ping"
},
"silenced": 2,
"startsAt": "2017-05-01T20:44:55.763656584Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server7",
"job": "node_ping"
},
"silenced": 2,
"startsAt": "2017-05-01T20:44:55.763656584Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server8",
"job": "node_ping"
},
"silenced": 2,
"startsAt": "2017-05-01T20:44:55.763656584Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Host_Down",
"cluster": "dev"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"summary": "Example summary",
"url": "http://localhost/example.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "prod",
"instance": "server1",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:44:55.763656584Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "prod",
"instance": "server2",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:44:55.763656584Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Host_Down",
"cluster": "prod"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server5",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:44:55.763656584Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server3",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:44:55.763656584Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server4",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:44:55.763656584Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Host_Down",
"cluster": "staging"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"alert": "Memory usage exceeding threshold",
"dashboard": "http://localhost/dashboard.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Memory_Usage_Too_High",
"cluster": "prod",
"instance": "server2",
"job": "node_exporter"
},
"startsAt": "2017-05-01T20:44:55.763656584Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Memory_Usage_Too_High",
"cluster": "prod"
}
}
],
"status": "success"
}

View File

@@ -0,0 +1,43 @@
{
"data": {
"silences": [
{
"comment": "Silenced instance",
"createdAt": "2017-05-01T20:44:55.717083559Z",
"createdBy": "john@example.com",
"endsAt": "2063-01-01T00:00:00Z",
"id": 1,
"matchers": [
{
"isRegex": false,
"name": "instance",
"value": "web1"
}
],
"startsAt": "2017-02-18T01:34:34Z"
},
{
"comment": "Silenced Host_Down alerts in the dev cluster",
"createdAt": "2017-05-01T20:44:55.739048756Z",
"createdBy": "john@example.com",
"endsAt": "2063-01-01T00:00:00Z",
"id": 2,
"matchers": [
{
"isRegex": false,
"name": "alertname",
"value": "Host_Down"
},
{
"isRegex": false,
"name": "cluster",
"value": "dev"
}
],
"startsAt": "2017-02-18T01:34:34Z"
}
],
"totalSilences": 2
},
"status": "success"
}

65
mock/0.4.0/api/v1/status Normal file
View File

@@ -0,0 +1,65 @@
{
"data": {
"config": "route:\n group_by: ['alertname', 'cluster', 'service']\n group_wait: 15s\n group_interval: 35s\n repeat_interval: 999h\n receiver: default\n\ninhibit_rules:\n- source_match:\n severity: 'critical'\n target_match:\n severity: 'warning'\n # Apply inhibition if the alertname is the same.\n equal: ['alertname', 'cluster', 'service']\n\nreceivers:\n- name: 'default'\n",
"configJSON": {
"global": {
"hipchat_auth_token": "",
"hipchat_url": "https://api.hipchat.com/",
"opsgenie_api_host": "https://api.opsgenie.com/",
"pagerduty_url": "https://events.pagerduty.com/generic/2010-04-15/create_event.json",
"resolve_timeout": 300000000000,
"slack_api_url": "",
"smtp_auth_identity": "",
"smtp_auth_password": "",
"smtp_auth_secret": "",
"smtp_auth_username": "",
"smtp_from": "",
"smtp_smarthost": ""
},
"inhibit_rules": [
{
"equal": [
"alertname",
"cluster",
"service"
],
"source_match": {
"severity": "critical"
},
"source_match_re": null,
"target_match": {
"severity": "warning"
},
"target_match_re": null
}
],
"receivers": [
{
"name": "default"
}
],
"route": {
"group_by": [
"alertname",
"cluster",
"service"
],
"group_interval": 35000000000,
"group_wait": 15000000000,
"receiver": "default",
"repeat_interval": 3596400000000000
},
"templates": null
},
"uptime": "2017-05-01T20:44:45.763122163Z",
"versionInfo": {
"branch": "master",
"buildDate": "20160823-12:57:02",
"buildUser": "root@4d444a116210",
"goVersion": "go1.6.2",
"revision": "7f6bc0b6e303ce36b78284e58edb85304c42b355",
"version": "0.4.0"
}
},
"status": "success"
}

0
mock/0.4.1/.ok Normal file
View File

View File

@@ -0,0 +1,332 @@
{
"data": [
{
"blocks": [
{
"alerts": [
{
"annotations": {
"alert": "Less than 10% disk space is free",
"dashboard": "http://localhost/dashboard.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Free_Disk_Space_Too_Low",
"cluster": "staging",
"instance": "server5",
"job": "node_exporter"
},
"startsAt": "2017-05-01T20:45:58.865330456Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Free_Disk_Space_Too_Low",
"cluster": "staging"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"help": "Example help annotation",
"summary": "Example summary",
"url": "http://localhost/example.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev",
"instance": "web1",
"job": "node_exporter"
},
"silenced": 1,
"startsAt": "2017-05-01T20:45:58.865330456Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev",
"instance": "web2",
"job": "node_exporter"
},
"startsAt": "2017-05-01T20:45:58.865330456Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server8",
"job": "node_ping"
},
"silenced": 2,
"startsAt": "2017-05-01T20:45:58.865330456Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server6",
"job": "node_ping"
},
"silenced": 2,
"startsAt": "2017-05-01T20:45:58.865330456Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server7",
"job": "node_ping"
},
"silenced": 2,
"startsAt": "2017-05-01T20:45:58.865330456Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Host_Down",
"cluster": "dev"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"summary": "Example summary",
"url": "http://localhost/example.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "prod",
"instance": "server1",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:45:58.865330456Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "prod",
"instance": "server2",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:45:58.865330456Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Host_Down",
"cluster": "prod"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server3",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:45:58.865330456Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server4",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:45:58.865330456Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server5",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:45:58.865330456Z"
}
],
"routeOpts": {
"groupBy": [
"cluster",
"service",
"alertname"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Host_Down",
"cluster": "staging"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"alert": "Memory usage exceeding threshold",
"dashboard": "http://localhost/dashboard.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Memory_Usage_Too_High",
"cluster": "prod",
"instance": "server2",
"job": "node_exporter"
},
"startsAt": "2017-05-01T20:45:58.865330456Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Memory_Usage_Too_High",
"cluster": "prod"
}
}
],
"status": "success"
}

View File

@@ -0,0 +1,43 @@
{
"data": {
"silences": [
{
"comment": "Silenced instance",
"createdAt": "2017-05-01T20:45:58.802450694Z",
"createdBy": "john@example.com",
"endsAt": "2063-01-01T00:00:00Z",
"id": 1,
"matchers": [
{
"isRegex": false,
"name": "instance",
"value": "web1"
}
],
"startsAt": "2017-02-18T01:34:34Z"
},
{
"comment": "Silenced Host_Down alerts in the dev cluster",
"createdAt": "2017-05-01T20:45:58.82453438Z",
"createdBy": "john@example.com",
"endsAt": "2063-01-01T00:00:00Z",
"id": 2,
"matchers": [
{
"isRegex": false,
"name": "alertname",
"value": "Host_Down"
},
{
"isRegex": false,
"name": "cluster",
"value": "dev"
}
],
"startsAt": "2017-02-18T01:34:34Z"
}
],
"totalSilences": 2
},
"status": "success"
}

65
mock/0.4.1/api/v1/status Normal file
View File

@@ -0,0 +1,65 @@
{
"data": {
"config": "route:\n group_by: ['alertname', 'cluster', 'service']\n group_wait: 15s\n group_interval: 35s\n repeat_interval: 999h\n receiver: default\n\ninhibit_rules:\n- source_match:\n severity: 'critical'\n target_match:\n severity: 'warning'\n # Apply inhibition if the alertname is the same.\n equal: ['alertname', 'cluster', 'service']\n\nreceivers:\n- name: 'default'\n",
"configJSON": {
"global": {
"hipchat_auth_token": "",
"hipchat_url": "https://api.hipchat.com/",
"opsgenie_api_host": "https://api.opsgenie.com/",
"pagerduty_url": "https://events.pagerduty.com/generic/2010-04-15/create_event.json",
"resolve_timeout": 300000000000,
"slack_api_url": "",
"smtp_auth_identity": "",
"smtp_auth_password": "",
"smtp_auth_secret": "",
"smtp_auth_username": "",
"smtp_from": "",
"smtp_smarthost": ""
},
"inhibit_rules": [
{
"equal": [
"alertname",
"cluster",
"service"
],
"source_match": {
"severity": "critical"
},
"source_match_re": null,
"target_match": {
"severity": "warning"
},
"target_match_re": null
}
],
"receivers": [
{
"name": "default"
}
],
"route": {
"group_by": [
"alertname",
"cluster",
"service"
],
"group_interval": 35000000000,
"group_wait": 15000000000,
"receiver": "default",
"repeat_interval": 3596400000000000
},
"templates": null
},
"uptime": "2017-05-01T20:45:48.854261256Z",
"versionInfo": {
"branch": "master",
"buildDate": "20160831-22:29:03",
"buildUser": "root@d97584317568",
"goVersion": "go1.6.2",
"revision": "230a80a08942c78e1213e69959d571c292473bde",
"version": "0.4.1"
}
},
"status": "success"
}

0
mock/0.4.2/.ok Normal file
View File

View File

@@ -0,0 +1,332 @@
{
"data": [
{
"blocks": [
{
"alerts": [
{
"annotations": {
"alert": "Less than 10% disk space is free",
"dashboard": "http://localhost/dashboard.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Free_Disk_Space_Too_Low",
"cluster": "staging",
"instance": "server5",
"job": "node_exporter"
},
"startsAt": "2017-05-01T20:47:02.216312801Z"
}
],
"routeOpts": {
"groupBy": [
"service",
"alertname",
"cluster"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Free_Disk_Space_Too_Low",
"cluster": "staging"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"help": "Example help annotation",
"summary": "Example summary",
"url": "http://localhost/example.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev",
"instance": "web1",
"job": "node_exporter"
},
"silenced": 1,
"startsAt": "2017-05-01T20:47:02.216312801Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev",
"instance": "web2",
"job": "node_exporter"
},
"startsAt": "2017-05-01T20:47:02.216312801Z"
}
],
"routeOpts": {
"groupBy": [
"service",
"alertname",
"cluster"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server7",
"job": "node_ping"
},
"silenced": 2,
"startsAt": "2017-05-01T20:47:02.216312801Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server8",
"job": "node_ping"
},
"silenced": 2,
"startsAt": "2017-05-01T20:47:02.216312801Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server6",
"job": "node_ping"
},
"silenced": 2,
"startsAt": "2017-05-01T20:47:02.216312801Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Host_Down",
"cluster": "dev"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"summary": "Example summary",
"url": "http://localhost/example.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "prod",
"instance": "server1",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:47:02.216312801Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "prod",
"instance": "server2",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:47:02.216312801Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Host_Down",
"cluster": "prod"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server3",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:47:02.216312801Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server4",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:47:02.216312801Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server5",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:47:02.216312801Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Host_Down",
"cluster": "staging"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"alert": "Memory usage exceeding threshold",
"dashboard": "http://localhost/dashboard.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Memory_Usage_Too_High",
"cluster": "prod",
"instance": "server2",
"job": "node_exporter"
},
"startsAt": "2017-05-01T20:47:02.216312801Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Memory_Usage_Too_High",
"cluster": "prod"
}
}
],
"status": "success"
}

View File

@@ -0,0 +1,43 @@
{
"data": {
"silences": [
{
"comment": "Silenced instance",
"createdAt": "2017-05-01T20:47:01.957358662Z",
"createdBy": "john@example.com",
"endsAt": "2063-01-01T00:00:00Z",
"id": 1,
"matchers": [
{
"isRegex": false,
"name": "instance",
"value": "web1"
}
],
"startsAt": "2017-02-18T01:34:34Z"
},
{
"comment": "Silenced Host_Down alerts in the dev cluster",
"createdAt": "2017-05-01T20:47:02.193094888Z",
"createdBy": "john@example.com",
"endsAt": "2063-01-01T00:00:00Z",
"id": 2,
"matchers": [
{
"isRegex": false,
"name": "alertname",
"value": "Host_Down"
},
{
"isRegex": false,
"name": "cluster",
"value": "dev"
}
],
"startsAt": "2017-02-18T01:34:34Z"
}
],
"totalSilences": 2
},
"status": "success"
}

65
mock/0.4.2/api/v1/status Normal file
View File

@@ -0,0 +1,65 @@
{
"data": {
"config": "route:\n group_by: ['alertname', 'cluster', 'service']\n group_wait: 15s\n group_interval: 35s\n repeat_interval: 999h\n receiver: default\n\ninhibit_rules:\n- source_match:\n severity: 'critical'\n target_match:\n severity: 'warning'\n # Apply inhibition if the alertname is the same.\n equal: ['alertname', 'cluster', 'service']\n\nreceivers:\n- name: 'default'\n",
"configJSON": {
"global": {
"hipchat_auth_token": "",
"hipchat_url": "https://api.hipchat.com/",
"opsgenie_api_host": "https://api.opsgenie.com/",
"pagerduty_url": "https://events.pagerduty.com/generic/2010-04-15/create_event.json",
"resolve_timeout": 300000000000,
"slack_api_url": "",
"smtp_auth_identity": "",
"smtp_auth_password": "",
"smtp_auth_secret": "",
"smtp_auth_username": "",
"smtp_from": "",
"smtp_smarthost": ""
},
"inhibit_rules": [
{
"equal": [
"alertname",
"cluster",
"service"
],
"source_match": {
"severity": "critical"
},
"source_match_re": null,
"target_match": {
"severity": "warning"
},
"target_match_re": null
}
],
"receivers": [
{
"name": "default"
}
],
"route": {
"group_by": [
"alertname",
"cluster",
"service"
],
"group_interval": 35000000000,
"group_wait": 15000000000,
"receiver": "default",
"repeat_interval": 3596400000000000
},
"templates": null
},
"uptime": "2017-05-01T20:46:51.9830008Z",
"versionInfo": {
"branch": "master",
"buildDate": "20160902-15:33:13",
"buildUser": "root@2811d2f42616",
"goVersion": "go1.6.3",
"revision": "9a5ab2fa63dd7951f4f202b0846d4f4d8e9615b0",
"version": "0.4.2"
}
},
"status": "success"
}

View File

@@ -1,282 +0,0 @@
{
"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_Too_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": "Free_Disk_Space_Too_Low",
"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": true
}
]
}
]
}
]
}

View File

@@ -1,43 +0,0 @@
{
"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@example.com",
"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@example.com",
"comment": "Silenced Host_Down alerts in the dev cluster"
}
],
"totalSilences": 2
}
}

View File

@@ -1,21 +0,0 @@
{
"status": "success",
"data": {
"configJSON": {
"global": {},
"route": {},
"inhibit_rules": [],
"receivers": [],
"templates": []
},
"versionInfo": {
"branch": "master",
"buildDate": "20160831-22:29:03",
"buildUser": "root@d97584317568",
"goVersion": "go1.6.2",
"revision": "230a80a08942c78e1213e69959d571c292473bde",
"version": "0.4.1"
},
"uptime": "2017-04-01T16:41:51.716681297Z"
}
}

0
mock/0.5.0/.ok Normal file
View File

View File

@@ -0,0 +1,332 @@
{
"data": [
{
"blocks": [
{
"alerts": [
{
"annotations": {
"alert": "Less than 10% disk space is free",
"dashboard": "http://localhost/dashboard.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Free_Disk_Space_Too_Low",
"cluster": "staging",
"instance": "server5",
"job": "node_exporter"
},
"startsAt": "2017-05-01T20:48:07.504986978Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Free_Disk_Space_Too_Low",
"cluster": "staging"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"help": "Example help annotation",
"summary": "Example summary",
"url": "http://localhost/example.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev",
"instance": "web1",
"job": "node_exporter"
},
"silenced": "a202a84a-7fc7-4340-9358-bcfdea507b38",
"startsAt": "2017-05-01T20:48:07.504986978Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev",
"instance": "web2",
"job": "node_exporter"
},
"startsAt": "2017-05-01T20:48:07.504986978Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server6",
"job": "node_ping"
},
"silenced": "f5471ebc-43d8-402f-9c3f-ddd9e7f6d7c0",
"startsAt": "2017-05-01T20:48:07.504986978Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server7",
"job": "node_ping"
},
"silenced": "f5471ebc-43d8-402f-9c3f-ddd9e7f6d7c0",
"startsAt": "2017-05-01T20:48:07.504986978Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server8",
"job": "node_ping"
},
"silenced": "f5471ebc-43d8-402f-9c3f-ddd9e7f6d7c0",
"startsAt": "2017-05-01T20:48:07.504986978Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Host_Down",
"cluster": "dev"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"summary": "Example summary",
"url": "http://localhost/example.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "prod",
"instance": "server1",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:48:07.504986978Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "prod",
"instance": "server2",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:48:07.504986978Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Host_Down",
"cluster": "prod"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server4",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:48:07.504986978Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server5",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:48:07.504986978Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server3",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:48:07.504986978Z"
}
],
"routeOpts": {
"groupBy": [
"cluster",
"service",
"alertname"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Host_Down",
"cluster": "staging"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"alert": "Memory usage exceeding threshold",
"dashboard": "http://localhost/dashboard.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Memory_Usage_Too_High",
"cluster": "prod",
"instance": "server2",
"job": "node_exporter"
},
"startsAt": "2017-05-01T20:48:07.504986978Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Memory_Usage_Too_High",
"cluster": "prod"
}
}
],
"status": "success"
}

View File

@@ -0,0 +1,40 @@
{
"data": [
{
"comment": "Silenced instance",
"createdBy": "john@example.com",
"endsAt": "2063-01-01T00:00:00Z",
"id": "a202a84a-7fc7-4340-9358-bcfdea507b38",
"matchers": [
{
"isRegex": false,
"name": "instance",
"value": "web1"
}
],
"startsAt": "2017-05-01T20:48:07.497691065Z",
"updatedAt": "2017-05-01T20:48:07.497691065Z"
},
{
"comment": "Silenced Host_Down alerts in the dev cluster",
"createdBy": "john@example.com",
"endsAt": "2063-01-01T00:00:00Z",
"id": "f5471ebc-43d8-402f-9c3f-ddd9e7f6d7c0",
"matchers": [
{
"isRegex": false,
"name": "alertname",
"value": "Host_Down"
},
{
"isRegex": false,
"name": "cluster",
"value": "dev"
}
],
"startsAt": "2017-05-01T20:48:07.501342745Z",
"updatedAt": "2017-05-01T20:48:07.501342745Z"
}
],
"status": "success"
}

15
mock/0.5.0/api/v1/status Normal file
View File

@@ -0,0 +1,15 @@
{
"data": {
"config": "route:\n group_by: ['alertname', 'cluster', 'service']\n group_wait: 15s\n group_interval: 35s\n repeat_interval: 999h\n receiver: default\n\ninhibit_rules:\n- source_match:\n severity: 'critical'\n target_match:\n severity: 'warning'\n # Apply inhibition if the alertname is the same.\n equal: ['alertname', 'cluster', 'service']\n\nreceivers:\n- name: 'default'\n",
"uptime": "2017-05-01T20:47:57.36073197Z",
"versionInfo": {
"branch": "master",
"buildDate": "20161101-18:10:50",
"buildUser": "root@f336dcc453a4",
"goVersion": "go1.7.3",
"revision": "a91fe17ddf0a57c627e2cfcdaa0ab364b1ab3e04",
"version": "0.5.0"
}
},
"status": "success"
}

0
mock/0.5.1/.ok Normal file
View File

View File

@@ -0,0 +1,332 @@
{
"data": [
{
"blocks": [
{
"alerts": [
{
"annotations": {
"alert": "Less than 10% disk space is free",
"dashboard": "http://localhost/dashboard.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Free_Disk_Space_Too_Low",
"cluster": "staging",
"instance": "server5",
"job": "node_exporter"
},
"startsAt": "2017-05-01T20:49:10.737246096Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Free_Disk_Space_Too_Low",
"cluster": "staging"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"help": "Example help annotation",
"summary": "Example summary",
"url": "http://localhost/example.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev",
"instance": "web1",
"job": "node_exporter"
},
"silenced": "a2e60dae-4166-4b14-be6d-62e9ca32153f",
"startsAt": "2017-05-01T20:49:10.737246096Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev",
"instance": "web2",
"job": "node_exporter"
},
"startsAt": "2017-05-01T20:49:10.737246096Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server6",
"job": "node_ping"
},
"silenced": "e64b0232-fd8c-427c-9174-f77390bd0bc4",
"startsAt": "2017-05-01T20:49:10.737246096Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server7",
"job": "node_ping"
},
"silenced": "e64b0232-fd8c-427c-9174-f77390bd0bc4",
"startsAt": "2017-05-01T20:49:10.737246096Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server8",
"job": "node_ping"
},
"silenced": "e64b0232-fd8c-427c-9174-f77390bd0bc4",
"startsAt": "2017-05-01T20:49:10.737246096Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Host_Down",
"cluster": "dev"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"summary": "Example summary",
"url": "http://localhost/example.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "prod",
"instance": "server1",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:49:10.737246096Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "prod",
"instance": "server2",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:49:10.737246096Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Host_Down",
"cluster": "prod"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server3",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:49:10.737246096Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server4",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:49:10.737246096Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server5",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:49:10.737246096Z"
}
],
"routeOpts": {
"groupBy": [
"cluster",
"service",
"alertname"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Host_Down",
"cluster": "staging"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"alert": "Memory usage exceeding threshold",
"dashboard": "http://localhost/dashboard.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Memory_Usage_Too_High",
"cluster": "prod",
"instance": "server2",
"job": "node_exporter"
},
"startsAt": "2017-05-01T20:49:10.737246096Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"labels": {
"alertname": "Memory_Usage_Too_High",
"cluster": "prod"
}
}
],
"status": "success"
}

View File

@@ -0,0 +1,40 @@
{
"data": [
{
"comment": "Silenced instance",
"createdBy": "john@example.com",
"endsAt": "2063-01-01T00:00:00Z",
"id": "a2e60dae-4166-4b14-be6d-62e9ca32153f",
"matchers": [
{
"isRegex": false,
"name": "instance",
"value": "web1"
}
],
"startsAt": "2017-05-01T20:49:10.732910442Z",
"updatedAt": "2017-05-01T20:49:10.732910442Z"
},
{
"comment": "Silenced Host_Down alerts in the dev cluster",
"createdBy": "john@example.com",
"endsAt": "2063-01-01T00:00:00Z",
"id": "e64b0232-fd8c-427c-9174-f77390bd0bc4",
"matchers": [
{
"isRegex": false,
"name": "alertname",
"value": "Host_Down"
},
{
"isRegex": false,
"name": "cluster",
"value": "dev"
}
],
"startsAt": "2017-05-01T20:49:10.735083335Z",
"updatedAt": "2017-05-01T20:49:10.735083335Z"
}
],
"status": "success"
}

67
mock/0.5.1/api/v1/status Normal file
View File

@@ -0,0 +1,67 @@
{
"data": {
"config": "route:\n group_by: ['alertname', 'cluster', 'service']\n group_wait: 15s\n group_interval: 35s\n repeat_interval: 999h\n receiver: default\n\ninhibit_rules:\n- source_match:\n severity: 'critical'\n target_match:\n severity: 'warning'\n # Apply inhibition if the alertname is the same.\n equal: ['alertname', 'cluster', 'service']\n\nreceivers:\n- name: 'default'\n",
"configJSON": {
"global": {
"hipchat_auth_token": "",
"hipchat_url": "https://api.hipchat.com/",
"opsgenie_api_host": "https://api.opsgenie.com/",
"pagerduty_url": "https://events.pagerduty.com/generic/2010-04-15/create_event.json",
"resolve_timeout": 300000000000,
"slack_api_url": "",
"smtp_auth_identity": "",
"smtp_auth_password": "",
"smtp_auth_secret": "",
"smtp_auth_username": "",
"smtp_from": "",
"smtp_require_tls": true,
"smtp_smarthost": "",
"victorops_api_url": "https://alert.victorops.com/integrations/generic/20131114/alert/"
},
"inhibit_rules": [
{
"equal": [
"alertname",
"cluster",
"service"
],
"source_match": {
"severity": "critical"
},
"source_match_re": null,
"target_match": {
"severity": "warning"
},
"target_match_re": null
}
],
"receivers": [
{
"name": "default"
}
],
"route": {
"group_by": [
"alertname",
"cluster",
"service"
],
"group_interval": 35000000000,
"group_wait": 15000000000,
"receiver": "default",
"repeat_interval": 3596400000000000
},
"templates": null
},
"uptime": "2017-05-01T20:49:00.61677729Z",
"versionInfo": {
"branch": "master",
"buildDate": "20161125-08:14:40",
"buildUser": "root@fb407787b8bf",
"goVersion": "go1.7.3",
"revision": "0ea1cac51e6a620ec09d053f0484b97932b5c902",
"version": "0.5.1"
}
},
"status": "success"
}

View File

@@ -1,282 +0,0 @@
{
"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_Too_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": "Free_Disk_Space_Too_Low",
"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": true
}
]
}
]
}
]
}

View File

@@ -1,40 +0,0 @@
{
"status": "success",
"data": [
{
"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@example.com",
"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@example.com",
"comment": "Silenced Host_Down alerts in the dev cluster"
}
]
}

View File

@@ -1,21 +0,0 @@
{
"status": "success",
"data": {
"configJSON": {
"global": {},
"route": {},
"inhibit_rules": [],
"receivers": [],
"templates": []
},
"versionInfo": {
"branch": "master",
"buildDate": "20161125-08:14:40",
"buildUser": "root@fb407787b8bf",
"goVersion": "go1.7.3",
"revision": "0ea1cac51e6a620ec09d053f0484b97932b5c902",
"version": "0.5.1"
},
"uptime": "2017-04-01T17:01:29.225354076Z"
}
}

0
mock/0.6.0/.ok Normal file
View File

View File

@@ -0,0 +1,338 @@
{
"data": [
{
"blocks": [
{
"alerts": [
{
"annotations": {
"alert": "Less than 10% disk space is free",
"dashboard": "http://localhost/dashboard.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Free_Disk_Space_Too_Low",
"cluster": "staging",
"instance": "server5",
"job": "node_exporter"
},
"startsAt": "2017-05-01T20:50:13.961979914Z"
}
],
"routeOpts": {
"groupBy": [
"service",
"alertname",
"cluster"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"groupKey": "{}:{alertname=\"Free_Disk_Space_Too_Low\", cluster=\"staging\"}",
"labels": {
"alertname": "Free_Disk_Space_Too_Low",
"cluster": "staging"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"help": "Example help annotation",
"summary": "Example summary",
"url": "http://localhost/example.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev",
"instance": "web1",
"job": "node_exporter"
},
"silenced": "4b1c588a-c40f-4ec8-9602-754637ad315a",
"startsAt": "2017-05-01T20:50:13.961979914Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev",
"instance": "web2",
"job": "node_exporter"
},
"startsAt": "2017-05-01T20:50:13.961979914Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"groupKey": "{}:{alertname=\"HTTP_Probe_Failed\", cluster=\"dev\"}",
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server6",
"job": "node_ping"
},
"silenced": "c4ffbd39-92fa-40b4-9ba1-5d19df3a410d",
"startsAt": "2017-05-01T20:50:13.961979914Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server7",
"job": "node_ping"
},
"silenced": "c4ffbd39-92fa-40b4-9ba1-5d19df3a410d",
"startsAt": "2017-05-01T20:50:13.961979914Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server8",
"job": "node_ping"
},
"silenced": "c4ffbd39-92fa-40b4-9ba1-5d19df3a410d",
"startsAt": "2017-05-01T20:50:13.961979914Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"groupKey": "{}:{alertname=\"Host_Down\", cluster=\"dev\"}",
"labels": {
"alertname": "Host_Down",
"cluster": "dev"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"summary": "Example summary",
"url": "http://localhost/example.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "prod",
"instance": "server1",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:50:13.961979914Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "prod",
"instance": "server2",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:50:13.961979914Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"groupKey": "{}:{alertname=\"Host_Down\", cluster=\"prod\"}",
"labels": {
"alertname": "Host_Down",
"cluster": "prod"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server5",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:50:13.961979914Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server3",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:50:13.961979914Z"
},
{
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server4",
"job": "node_ping"
},
"startsAt": "2017-05-01T20:50:13.961979914Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"groupKey": "{}:{alertname=\"Host_Down\", cluster=\"staging\"}",
"labels": {
"alertname": "Host_Down",
"cluster": "staging"
}
},
{
"blocks": [
{
"alerts": [
{
"annotations": {
"alert": "Memory usage exceeding threshold",
"dashboard": "http://localhost/dashboard.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibited": false,
"labels": {
"alertname": "Memory_Usage_Too_High",
"cluster": "prod",
"instance": "server2",
"job": "node_exporter"
},
"startsAt": "2017-05-01T20:50:13.961979914Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"groupKey": "{}:{alertname=\"Memory_Usage_Too_High\", cluster=\"prod\"}",
"labels": {
"alertname": "Memory_Usage_Too_High",
"cluster": "prod"
}
}
],
"status": "success"
}

View File

@@ -0,0 +1,40 @@
{
"data": [
{
"comment": "Silenced instance",
"createdBy": "john@example.com",
"endsAt": "2063-01-01T00:00:00Z",
"id": "4b1c588a-c40f-4ec8-9602-754637ad315a",
"matchers": [
{
"isRegex": false,
"name": "instance",
"value": "web1"
}
],
"startsAt": "2017-05-01T20:50:13.957724279Z",
"updatedAt": "2017-05-01T20:50:13.957724279Z"
},
{
"comment": "Silenced Host_Down alerts in the dev cluster",
"createdBy": "john@example.com",
"endsAt": "2063-01-01T00:00:00Z",
"id": "c4ffbd39-92fa-40b4-9ba1-5d19df3a410d",
"matchers": [
{
"isRegex": false,
"name": "alertname",
"value": "Host_Down"
},
{
"isRegex": false,
"name": "cluster",
"value": "dev"
}
],
"startsAt": "2017-05-01T20:50:13.959964356Z",
"updatedAt": "2017-05-01T20:50:13.959964356Z"
}
],
"status": "success"
}

78
mock/0.6.0/api/v1/status Normal file
View File

@@ -0,0 +1,78 @@
{
"data": {
"config": "route:\n group_by: ['alertname', 'cluster', 'service']\n group_wait: 15s\n group_interval: 35s\n repeat_interval: 999h\n receiver: default\n\ninhibit_rules:\n- source_match:\n severity: 'critical'\n target_match:\n severity: 'warning'\n # Apply inhibition if the alertname is the same.\n equal: ['alertname', 'cluster', 'service']\n\nreceivers:\n- name: 'default'\n",
"configJSON": {
"global": {
"hipchat_auth_token": "",
"hipchat_url": "https://api.hipchat.com/",
"opsgenie_api_host": "https://api.opsgenie.com/",
"pagerduty_url": "https://events.pagerduty.com/generic/2010-04-15/create_event.json",
"resolve_timeout": 300000000000,
"slack_api_url": "",
"smtp_auth_identity": "",
"smtp_auth_password": "",
"smtp_auth_secret": "",
"smtp_auth_username": "",
"smtp_from": "",
"smtp_require_tls": true,
"smtp_smarthost": "",
"victorops_api_url": "https://alert.victorops.com/integrations/generic/20131114/alert/"
},
"inhibit_rules": [
{
"equal": [
"alertname",
"cluster",
"service"
],
"source_match": {
"severity": "critical"
},
"source_match_re": null,
"target_match": {
"severity": "warning"
},
"target_match_re": null
}
],
"receivers": [
{
"name": "default"
}
],
"route": {
"group_by": [
"alertname",
"cluster",
"service"
],
"group_interval": 35000000000,
"group_wait": 15000000000,
"receiver": "default",
"repeat_interval": 3596400000000000
},
"templates": null
},
"meshStatus": {
"name": "02:42:ac:11:00:02",
"nickName": "056ea9373951",
"peers": [
{
"name": "02:42:ac:11:00:02",
"nickName": "056ea9373951",
"uid": 15872478154679362182
}
]
},
"uptime": "2017-05-01T20:50:03.840143699Z",
"versionInfo": {
"branch": "master",
"buildDate": "20170425-19:48:54",
"buildUser": "root@e81189977445",
"goVersion": "go1.8.1",
"revision": "762b5c479a8d35c8ed9763fe13a16b4e521f7c54",
"version": "0.6.0"
}
},
"status": "success"
}

0
mock/0.6.1/.ok Normal file
View File

View File

@@ -1,317 +1,366 @@
{
"status": "success",
"data": [
{
"labels": {
"alertname": "Free_Disk_Space_Too_Low",
"cluster": "staging"
},
"groupKey": "{}:{alertname=\"Free_Disk_Space_Too_Low\", cluster=\"staging\"}",
"blocks": [
"data": [
{
"routeOpts": {
"receiver": "default",
"groupBy": [
"alertname",
"cluster",
"service"
"blocks": [
{
"alerts": [
{
"Status": "active",
"annotations": {
"alert": "Less than 10% disk space is free",
"dashboard": "http://localhost/dashboard.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibitedBy": [],
"labels": {
"alertname": "Free_Disk_Space_Too_Low",
"cluster": "staging",
"instance": "server5",
"job": "node_exporter"
},
"silencedBy": [],
"startsAt": "2017-05-01T20:59:51.364108486Z"
}
],
"routeOpts": {
"groupBy": [
"service",
"alertname",
"cluster"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"groupWait": 30000000000,
"groupInterval": 300000000000,
"repeatInterval": 10800000000000
},
"alerts": [
{
"labels": {
"groupKey": "{}:{alertname=\"Free_Disk_Space_Too_Low\", cluster=\"staging\"}",
"labels": {
"alertname": "Free_Disk_Space_Too_Low",
"cluster": "staging",
"instance": "server5",
"job": "node_exporter"
},
"annotations": {
"alert": "Less than 10% disk space is free",
"dashboard": "http://localhost/dashboard.html"
},
"startsAt": "2017-05-01T20:34:21.20891774+01:00",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"Status": "active",
"inhibitedBy": [],
"silencedBy": []
"cluster": "staging"
}
]
}
]
},
{
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev"
},
"groupKey": "{}:{alertname=\"HTTP_Probe_Failed\", cluster=\"dev\"}",
"blocks": [
},
{
"routeOpts": {
"receiver": "default",
"groupBy": [
"alertname",
"cluster",
"service"
"blocks": [
{
"alerts": [
{
"Status": "suppressed",
"annotations": {
"help": "Example help annotation",
"summary": "Example summary",
"url": "http://localhost/example.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibitedBy": null,
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev",
"instance": "web1",
"job": "node_exporter"
},
"silencedBy": [
"d68b4fd6-f18a-474a-8953-255a86250742"
],
"startsAt": "2017-05-01T20:59:51.364108486Z"
},
{
"Status": "active",
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibitedBy": [],
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev",
"instance": "web2",
"job": "node_exporter"
},
"silencedBy": [],
"startsAt": "2017-05-01T20:59:51.364108486Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"groupWait": 30000000000,
"groupInterval": 300000000000,
"repeatInterval": 10800000000000
},
"alerts": [
{
"labels": {
"groupKey": "{}:{alertname=\"HTTP_Probe_Failed\", cluster=\"dev\"}",
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev",
"instance": "web2",
"job": "node_exporter"
},
"annotations": {
"summary": "Example summary"
},
"startsAt": "2017-05-01T20:34:21.20891774+01:00",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"Status": "active",
"inhibitedBy": [],
"silencedBy": []
},
{
"labels": {
"alertname": "HTTP_Probe_Failed",
"cluster": "dev",
"instance": "web1",
"job": "node_exporter"
},
"annotations": {
"help": "Example help annotation",
"summary": "Example summary",
"url": "http://localhost/example.html"
},
"startsAt": "2017-05-01T20:34:21.20891774+01:00",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"Status": "suppressed",
"inhibitedBy": [],
"silencedBy": [
"419caf4f-c9d3-4a73-bb78-cfef2bc703e9"
]
"cluster": "dev"
}
]
}
]
},
{
"labels": {
"alertname": "Host_Down"
},
"groupKey": "{}:{alertname=\"Host_Down\"}",
"blocks": [
},
{
"routeOpts": {
"receiver": "default",
"groupBy": [
"alertname",
"cluster",
"service"
"blocks": [
{
"alerts": [
{
"Status": "suppressed",
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibitedBy": null,
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server6",
"job": "node_ping"
},
"silencedBy": [
"89142af0-b17f-4ffd-b2c2-2398de624466"
],
"startsAt": "2017-05-01T20:59:51.364108486Z"
},
{
"Status": "suppressed",
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibitedBy": null,
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server7",
"job": "node_ping"
},
"silencedBy": [
"89142af0-b17f-4ffd-b2c2-2398de624466"
],
"startsAt": "2017-05-01T20:59:51.364108486Z"
},
{
"Status": "suppressed",
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibitedBy": null,
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server8",
"job": "node_ping"
},
"silencedBy": [
"89142af0-b17f-4ffd-b2c2-2398de624466"
],
"startsAt": "2017-05-01T20:59:51.364108486Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"groupWait": 30000000000,
"groupInterval": 300000000000,
"repeatInterval": 10800000000000
},
"alerts": [
{
"labels": {
"groupKey": "{}:{alertname=\"Host_Down\", cluster=\"dev\"}",
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server6",
"job": "node_ping"
},
"annotations": {
"summary": "Example summary"
},
"startsAt": "2017-05-01T20:34:21.20891774+01:00",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"Status": "suppressed",
"inhibitedBy": [],
"silencedBy": [
"337b3ba9-aa95-4562-924b-be95335bafae"
]
},
{
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server7",
"job": "node_ping"
},
"annotations": {
"summary": "Example summary"
},
"startsAt": "2017-05-01T20:34:21.20891774+01:00",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"Status": "suppressed",
"inhibitedBy": [],
"silencedBy": [
"337b3ba9-aa95-4562-924b-be95335bafae"
]
},
{
"labels": {
"alertname": "Host_Down",
"cluster": "dev",
"instance": "server8",
"job": "node_ping"
},
"annotations": {
"summary": "Example summary"
},
"startsAt": "2017-05-01T20:34:21.20891774+01:00",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"Status": "suppressed",
"inhibitedBy": [],
"silencedBy": [
"337b3ba9-aa95-4562-924b-be95335bafae"
]
},
{
"labels": {
"alertname": "Host_Down",
"cluster": "prod",
"instance": "server1",
"job": "node_ping"
},
"annotations": {
"summary": "Example summary",
"url": "http://localhost/example.html"
},
"startsAt": "2017-05-01T20:34:21.20891774+01:00",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"Status": "active",
"inhibitedBy": [],
"silencedBy": []
},
{
"labels": {
"alertname": "Host_Down",
"cluster": "prod",
"instance": "server2",
"job": "node_ping"
},
"annotations": {
"summary": "Example summary"
},
"startsAt": "2017-05-01T20:34:21.20891774+01:00",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"Status": "active",
"inhibitedBy": [],
"silencedBy": []
},
{
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server4",
"job": "node_ping"
},
"annotations": {
"summary": "Example summary"
},
"startsAt": "2017-05-01T20:34:21.20891774+01:00",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"Status": "active",
"inhibitedBy": [],
"silencedBy": []
},
{
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server5",
"job": "node_ping"
},
"annotations": {
"summary": "Example summary"
},
"startsAt": "2017-05-01T20:34:21.20891774+01:00",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"Status": "active",
"inhibitedBy": [],
"silencedBy": []
},
{
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server3",
"job": "node_ping"
},
"annotations": {
"summary": "Example summary"
},
"startsAt": "2017-05-01T20:34:21.20891774+01:00",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"Status": "active",
"inhibitedBy": [],
"silencedBy": []
"cluster": "dev"
}
]
}
]
},
{
"labels": {
"alertname": "Memory_Usage_Too_High",
"cluster": "prod"
},
"groupKey": "{}:{alertname=\"Memory_Usage_Too_High\", cluster=\"prod\"}",
"blocks": [
},
{
"routeOpts": {
"receiver": "default",
"groupBy": [
"alertname",
"cluster",
"service"
"blocks": [
{
"alerts": [
{
"Status": "active",
"annotations": {
"summary": "Example summary",
"url": "http://localhost/example.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibitedBy": [],
"labels": {
"alertname": "Host_Down",
"cluster": "prod",
"instance": "server1",
"job": "node_ping"
},
"silencedBy": [],
"startsAt": "2017-05-01T20:59:51.364108486Z"
},
{
"Status": "active",
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibitedBy": [],
"labels": {
"alertname": "Host_Down",
"cluster": "prod",
"instance": "server2",
"job": "node_ping"
},
"silencedBy": [],
"startsAt": "2017-05-01T20:59:51.364108486Z"
}
],
"routeOpts": {
"groupBy": [
"service",
"alertname",
"cluster"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"groupWait": 30000000000,
"groupInterval": 300000000000,
"repeatInterval": 10800000000000
},
"alerts": [
{
"labels": {
"groupKey": "{}:{alertname=\"Host_Down\", cluster=\"prod\"}",
"labels": {
"alertname": "Host_Down",
"cluster": "prod"
}
},
{
"blocks": [
{
"alerts": [
{
"Status": "active",
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibitedBy": [],
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server3",
"job": "node_ping"
},
"silencedBy": [],
"startsAt": "2017-05-01T20:59:51.364108486Z"
},
{
"Status": "active",
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibitedBy": [],
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server4",
"job": "node_ping"
},
"silencedBy": [],
"startsAt": "2017-05-01T20:59:51.364108486Z"
},
{
"Status": "active",
"annotations": {
"summary": "Example summary"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibitedBy": [],
"labels": {
"alertname": "Host_Down",
"cluster": "staging",
"instance": "server5",
"job": "node_ping"
},
"silencedBy": [],
"startsAt": "2017-05-01T20:59:51.364108486Z"
}
],
"routeOpts": {
"groupBy": [
"alertname",
"cluster",
"service"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"groupKey": "{}:{alertname=\"Host_Down\", cluster=\"staging\"}",
"labels": {
"alertname": "Host_Down",
"cluster": "staging"
}
},
{
"blocks": [
{
"alerts": [
{
"Status": "active",
"annotations": {
"alert": "Memory usage exceeding threshold",
"dashboard": "http://localhost/dashboard.html"
},
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"inhibitedBy": [],
"labels": {
"alertname": "Memory_Usage_Too_High",
"cluster": "prod",
"instance": "server2",
"job": "node_exporter"
},
"silencedBy": [],
"startsAt": "2017-05-01T20:59:51.364108486Z"
}
],
"routeOpts": {
"groupBy": [
"service",
"alertname",
"cluster"
],
"groupInterval": 35000000000,
"groupWait": 15000000000,
"receiver": "default",
"repeatInterval": 3596400000000000
}
}
],
"groupKey": "{}:{alertname=\"Memory_Usage_Too_High\", cluster=\"prod\"}",
"labels": {
"alertname": "Memory_Usage_Too_High",
"cluster": "prod",
"instance": "server2",
"job": "node_exporter"
},
"annotations": {
"alert": "Memory usage exceeding threshold",
"dashboard": "http://localhost/dashboard.html"
},
"startsAt": "2017-05-01T20:34:21.20891774+01:00",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "",
"Status": "active",
"inhibitedBy": [],
"silencedBy": []
"cluster": "prod"
}
]
}
]
}
]
],
"status": "success"
}

View File

@@ -1,40 +1,40 @@
{
"status": "success",
"data": [
{
"id": "419caf4f-c9d3-4a73-bb78-cfef2bc703e9",
"matchers": [
"data": [
{
"name": "instance",
"value": "web1",
"isRegex": false
}
],
"startsAt": "2017-05-01T19:34:21.205359295Z",
"endsAt": "2063-01-01T00:00:00Z",
"updatedAt": "2017-05-01T19:34:21.205359295Z",
"createdBy": "john@example.com",
"comment": "Silenced instance"
},
{
"id": "337b3ba9-aa95-4562-924b-be95335bafae",
"matchers": [
{
"name": "alertname",
"value": "Host_Down",
"isRegex": false
"comment": "Silenced instance",
"createdBy": "john@example.com",
"endsAt": "2063-01-01T00:00:00Z",
"id": "d68b4fd6-f18a-474a-8953-255a86250742",
"matchers": [
{
"isRegex": false,
"name": "instance",
"value": "web1"
}
],
"startsAt": "2017-05-01T20:59:51.359703208Z",
"updatedAt": "2017-05-01T20:59:51.359703208Z"
},
{
"name": "cluster",
"value": "dev",
"isRegex": false
"comment": "Silenced Host_Down alerts in the dev cluster",
"createdBy": "john@example.com",
"endsAt": "2063-01-01T00:00:00Z",
"id": "89142af0-b17f-4ffd-b2c2-2398de624466",
"matchers": [
{
"isRegex": false,
"name": "alertname",
"value": "Host_Down"
},
{
"isRegex": false,
"name": "cluster",
"value": "dev"
}
],
"startsAt": "2017-05-01T20:59:51.361896025Z",
"updatedAt": "2017-05-01T20:59:51.361896025Z"
}
],
"startsAt": "2017-05-01T19:34:21.207248344Z",
"endsAt": "2063-01-01T00:00:00Z",
"updatedAt": "2017-05-01T19:34:21.207248344Z",
"createdBy": "john@example.com",
"comment": "Silenced Host_Down alerts in the dev cluster"
}
]
],
"status": "success"
}

View File

@@ -1,32 +1,78 @@
{
"status": "success",
"data": {
"configJSON": {
"global": {},
"route": {},
"inhibit_rules": [],
"receivers": [],
"templates": []
},
"versionInfo": {
"branch": "HEAD",
"buildDate": "20170501-19:31:12",
"buildUser": "lukasz@localhost",
"goVersion": "go1.8.1",
"revision": "5aeaf2cb988b0094b7998bbe6568bba23a0eb9c2",
"version": "0.6.1"
},
"uptime": "2017-05-01T20:31:38.102687341+01:00",
"meshStatus": {
"name": "28:d2:44:df:95:eb",
"nickName": "localhost",
"peers": [
{
"name": "28:d2:44:df:95:eb",
"nickName": "localhost",
"uid": 18388267050726621000
"data": {
"config": "route:\n group_by: ['alertname', 'cluster', 'service']\n group_wait: 15s\n group_interval: 35s\n repeat_interval: 999h\n receiver: default\n\ninhibit_rules:\n- source_match:\n severity: 'critical'\n target_match:\n severity: 'warning'\n # Apply inhibition if the alertname is the same.\n equal: ['alertname', 'cluster', 'service']\n\nreceivers:\n- name: 'default'\n",
"configJSON": {
"global": {
"hipchat_auth_token": "",
"hipchat_url": "https://api.hipchat.com/",
"opsgenie_api_host": "https://api.opsgenie.com/",
"pagerduty_url": "https://events.pagerduty.com/generic/2010-04-15/create_event.json",
"resolve_timeout": 300000000000,
"slack_api_url": "",
"smtp_auth_identity": "",
"smtp_auth_password": "",
"smtp_auth_secret": "",
"smtp_auth_username": "",
"smtp_from": "",
"smtp_require_tls": true,
"smtp_smarthost": "",
"victorops_api_url": "https://alert.victorops.com/integrations/generic/20131114/alert/"
},
"inhibit_rules": [
{
"equal": [
"alertname",
"cluster",
"service"
],
"source_match": {
"severity": "critical"
},
"source_match_re": null,
"target_match": {
"severity": "warning"
},
"target_match_re": null
}
],
"receivers": [
{
"name": "default"
}
],
"route": {
"group_by": [
"alertname",
"cluster",
"service"
],
"group_interval": 35000000000,
"group_wait": 15000000000,
"receiver": "default",
"repeat_interval": 3596400000000000
},
"templates": null
},
"meshStatus": {
"name": "02:42:ac:11:00:02",
"nickName": "c8a6f2549aee",
"peers": [
{
"name": "02:42:ac:11:00:02",
"nickName": "c8a6f2549aee",
"uid": 5746289647142050162
}
]
},
"uptime": "2017-05-01T20:59:36.222911307Z",
"versionInfo": {
"branch": "master",
"buildDate": "20170428-10:15:22",
"buildUser": "root@5f1ac69d2582",
"goVersion": "go1.8.1",
"revision": "5aeaf2cb988b0094b7998bbe6568bba23a0eb9c2",
"version": "0.6.1"
}
]
}
}
},
"status": "success"
}

29
mock/Makefile Normal file
View File

@@ -0,0 +1,29 @@
DOCKER_NAME := alertmanager-unsee-mock
DOCKER_IMAGE := prom/alertmanager
DOCKER_ARGS := --name $(DOCKER_NAME) --rm -d -p 9093:9093 -v $(CURDIR)/alertmanager.yml:/etc/alertmanager/config.yml
# list of Alertmanager versions to generate mock files for
VERSIONS := 0.4.0 0.4.1 0.4.2 0.5.0 0.5.1 0.6.0 0.6.1
%/.ok:
$(eval VERSION := $(word 1, $(subst /, ,$@)))
@echo "Generating mock files for Alertmanager $(VERSION)"
@docker pull $(DOCKER_IMAGE):v$(VERSION) > /dev/null
@docker rm -f $(DOCKER_NAME) > /dev/null 2>&1 || true
@echo "Starting Alertmanager"
@docker run $(DOCKER_ARGS) $(DOCKER_IMAGE):v$(VERSION)
@sleep 15
@echo "Sending mock alerts and silences"
@python livemock.py
@mkdir -p $(CURDIR)/$(VERSION)/api/v1 $(CURDIR)/$(VERSION)/api/v1/alerts
@echo "Collecting API responses"
@curl --fail -s localhost:9093/api/v1/status | python -m json.tool > $(CURDIR)/$(VERSION)/api/v1/status
@curl --fail -s localhost:9093/api/v1/silences | python -m json.tool > $(CURDIR)/$(VERSION)/api/v1/silences
@curl --fail -s localhost:9093/api/v1/alerts/groups | python -m json.tool > $(CURDIR)/$(VERSION)/api/v1/alerts/groups
@touch $(VERSION)/.ok
@echo "Done"
.PHONY: all
all: $(foreach version, $(VERSIONS), $(version)/.ok)
.DEFAULT_GOAL := all

17
mock/alertmanager.yml Normal file
View File

@@ -0,0 +1,17 @@
route:
group_by: ['alertname', 'cluster', 'service']
group_wait: 15s
group_interval: 35s
repeat_interval: 999h
receiver: default
inhibit_rules:
- source_match:
severity: 'critical'
target_match:
severity: 'warning'
# Apply inhibition if the alertname is the same.
equal: ['alertname', 'cluster', 'service']
receivers:
- name: 'default'

172
mock/livemock.py Normal file
View File

@@ -0,0 +1,172 @@
#!/usr/bin/env python
import os
import time
import json
import requests
requests.post('http://localhost:9093/api/v1/silences',
json={
"matchers": [
{
"name": "instance",
"value": "web1",
"isRegex": False
}
],
"startsAt": "2017-02-18T01:34:34Z",
"endsAt": "2063-01-01T00:00:00Z",
"createdBy": "john@example.com",
"comment": "Silenced instance"
})
requests.post('http://localhost:9093/api/v1/silences',
json={
"matchers": [
{
"name": "alertname",
"value": "Host_Down",
"isRegex": False
},
{
"name": "cluster",
"value": "dev",
"isRegex": False
}
],
"startsAt": "2017-02-18T01:34:34Z",
"endsAt": "2063-01-01T00:00:00Z",
"createdBy": "john@example.com",
"comment": "Silenced Host_Down alerts in the dev cluster"
})
for i in xrange(0, 5):
requests.post('http://localhost:9093/api/v1/alerts',
json=[{
"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"
}
}, {
"labels": {
"alertname": "HTTP_Probe_Failed",
"instance": "web2",
"job": "node_exporter",
"cluster": "dev"
},
"annotations": {
"summary": "Example summary"
}
}, {
"labels": {
"alertname": "Host_Down",
"instance": "server1",
"job": "node_ping",
"cluster": "prod"
},
"annotations": {
"summary": "Example summary",
"url": "http://localhost/example.html"
}
}, {
"labels": {
"alertname": "Host_Down",
"instance": "server2",
"job": "node_ping",
"cluster": "prod"
},
"annotations": {
"summary": "Example summary"
}
}, {
"labels": {
"alertname": "Host_Down",
"instance": "server3",
"job": "node_ping",
"cluster": "staging"
},
"annotations": {
"summary": "Example summary"
}
}, {
"labels": {
"alertname": "Host_Down",
"instance": "server4",
"job": "node_ping",
"cluster": "staging"
},
"annotations": {
"summary": "Example summary"
}
}, {
"labels": {
"alertname": "Host_Down",
"instance": "server5",
"job": "node_ping",
"cluster": "staging"
},
"annotations": {
"summary": "Example summary"
}
}, {
"labels": {
"alertname": "Host_Down",
"instance": "server6",
"job": "node_ping",
"cluster": "dev"
},
"annotations": {
"summary": "Example summary"
}
}, {
"labels": {
"alertname": "Host_Down",
"instance": "server7",
"job": "node_ping",
"cluster": "dev"
},
"annotations": {
"summary": "Example summary"
}
}, {
"labels": {
"alertname": "Host_Down",
"instance": "server8",
"job": "node_ping",
"cluster": "dev"
},
"annotations": {
"summary": "Example summary"
}
}, {
"labels": {
"alertname": "Memory_Usage_Too_High",
"instance": "server2",
"job": "node_exporter",
"cluster": "prod"
},
"annotations": {
"alert": "Memory usage exceeding threshold",
"dashboard": "http://localhost/dashboard.html"
}
}, {
"labels": {
"alertname": "Free_Disk_Space_Too_Low",
"instance": "server5",
"job": "node_exporter",
"cluster": "staging"
},
"annotations": {
"alert": "Less than 10% disk space is free",
"dashboard": "http://localhost/dashboard.html"
}
}]
)
time.sleep(10)

View File

@@ -28,3 +28,22 @@ func RegisterURL(url string, version string, filename string) {
}
httpmock.RegisterResponder("GET", url, httpmock.NewBytesResponder(200, mockJSON))
}
// ListAllMocks will return a list of all mock versions we have files for
func ListAllMocks() []string {
_, f, _, _ := runtime.Caller(0)
cwd := filepath.Dir(f)
dirents, err := ioutil.ReadDir(cwd)
if err != nil {
panic(err)
}
dirs := []string{}
for _, dirent := range dirents {
if dirent.IsDir() {
dirs = append(dirs, dirent.Name())
}
}
return dirs
}

View File

@@ -42,7 +42,7 @@ var transportTests = []transportTest{
failed: true,
},
transportTest{
uri: fmt.Sprintf("file://%s", mock.GetAbsoluteMockPath("status", "0.4")),
uri: fmt.Sprintf("file://%s", mock.GetAbsoluteMockPath("status", mock.ListAllMocks()[0])),
},
transportTest{
uri: "file:///non-existing-file.abcdef",

View File

@@ -20,8 +20,6 @@ import (
"gopkg.in/jarcoal/httpmock.v1"
)
var testVersions = []string{"0.4", "0.5", "0.6.1"}
func stringInSlice(stringArray []string, value string) bool {
for _, s := range stringArray {
if s == value {
@@ -115,7 +113,7 @@ func mockAlerts(version string) {
func TestAlerts(t *testing.T) {
mockConfig()
for _, version := range testVersions {
for _, version := range mock.ListAllMocks() {
mockAlerts(version)
r := ginTestEngine()
req, _ := http.NewRequest("GET", "/alerts.json?q=alertname=HTTP_Probe_Failed,instance=web1", nil)
@@ -172,7 +170,7 @@ func TestAlerts(t *testing.T) {
func TestValidateAllAlerts(t *testing.T) {
mockConfig()
for _, version := range testVersions {
for _, version := range mock.ListAllMocks() {
mockAlerts(version)
r := ginTestEngine()
req, _ := http.NewRequest("GET", "/alerts.json?q=alertname=HTTP_Probe_Failed,instance=web1", nil)
@@ -326,7 +324,7 @@ var acTests = []acTestCase{
func TestAutocomplete(t *testing.T) {
mockConfig()
for _, version := range testVersions {
for _, version := range mock.ListAllMocks() {
mockAlerts(version)
r := ginTestEngine()