summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-06-19 01:44:57 +0000
committerGerrit Code Review <review@openstack.org>2018-06-19 01:44:57 +0000
commita73d39daa8b0345f60a59988ce222bde53a9947e (patch)
treef4e2a45c1a47fc2c7f966213e8c3ff598ae34cb9
parent3e4f2e5ee359516bdb97423a5cf015b9a28318d2 (diff)
parentc82c2b8ef73caa1e130e44e0e4ea81333c52610d (diff)
Merge "Add alerts to graphs"
-rw-r--r--grafana_dashboards/schema/panel/graph.py14
-rw-r--r--tests/schema/fixtures/dashboard-0031.json90
-rw-r--r--tests/schema/fixtures/dashboard-0031.yaml41
3 files changed, 145 insertions, 0 deletions
diff --git a/grafana_dashboards/schema/panel/graph.py b/grafana_dashboards/schema/panel/graph.py
index e33d773..66c54a5 100644
--- a/grafana_dashboards/schema/panel/graph.py
+++ b/grafana_dashboards/schema/panel/graph.py
@@ -22,6 +22,19 @@ from grafana_dashboards.schema.panel.base import Base
22class Graph(Base): 22class Graph(Base):
23 23
24 def get_schema(self): 24 def get_schema(self):
25
26 alert_format = {
27 # could enforce "evaulator"/"operator"/"query" on this...
28 v.Required('conditions'): v.All(list),
29 v.Required('frequency', default='60s'): v.All(str),
30 v.Required('name'): v.All(str),
31 v.Required('executionErrorState', default='alerting'): (
32 v.Any('alerting', 'keep_state')),
33 v.Required('noDataState', default='no_data'): (
34 v.Any('no_data', 'alerting', 'ok', 'keep_state')),
35 v.Optional('notifications', default=[]): v.All(list),
36 }
37
25 yaxes_format = [ 38 yaxes_format = [
26 { 39 {
27 v.Optional('decimals'): v.All(int), 40 v.Optional('decimals'): v.All(int),
@@ -76,6 +89,7 @@ class Graph(Base):
76 series_overrides = [series_override] 89 series_overrides = [series_override]
77 90
78 graph = { 91 graph = {
92 v.Optional('alert'): v.All(alert_format),
79 v.Required('bars', default=False): v.All(bool), 93 v.Required('bars', default=False): v.All(bool),
80 v.Optional('datasource'): v.All(str), 94 v.Optional('datasource'): v.All(str),
81 v.Optional('decimals'): v.All(int), 95 v.Optional('decimals'): v.All(int),
diff --git a/tests/schema/fixtures/dashboard-0031.json b/tests/schema/fixtures/dashboard-0031.json
new file mode 100644
index 0000000..f03d233
--- /dev/null
+++ b/tests/schema/fixtures/dashboard-0031.json
@@ -0,0 +1,90 @@
1{
2 "dashboard": {
3 "new-dashboard": {
4 "rows": [
5 {
6 "collapse": false,
7 "editable": true,
8 "height": "250px",
9 "panels": [
10 {
11 "alert": {
12 "conditions": [
13 {
14 "evaluator": {
15 "params": [
16 0.85
17 ],
18 "type": "gt"
19 },
20 "operator": {
21 "type": "and"
22 },
23 "query": {
24 "params": [
25 "C",
26 "5m",
27 "now"
28 ]
29 },
30 "reducer": {
31 "params": [],
32 "type": "avg"
33 },
34 "type": "query"
35 }
36 ],
37 "executionErrorState": "alerting",
38 "frequency": "60s",
39 "name": "A test alert",
40 "noDataState": "no_data",
41 "notifications": []
42 },
43 "bars": false,
44 "datasource": "graphite",
45 "editable": true,
46 "error": false,
47 "fill": 1,
48 "lines": true,
49 "linewidth": 2,
50 "percentage": false,
51 "pointradius": 5,
52 "points": false,
53 "span": 12,
54 "stack": false,
55 "steppedLine": false,
56 "targets": [
57 {
58 "hide": true,
59 "refId": "A",
60 "target": "stats.gauges.afs.afs01_dfw_openstack_org.part.vicepa.total"
61 },
62 {
63 "hide": false,
64 "refId": "B",
65 "target": "divideSeries(stats.gauges.afs.afs01_dfw_openstack_org.part.vicpa.used, #A)"
66 }
67 ],
68 "title": "no title (click here)",
69 "type": "graph",
70 "x-axis": true,
71 "y-axis": true
72 }
73 ],
74 "showTitle": false,
75 "title": "New row"
76 }
77 ],
78 "templating": {
79 "enabled": false,
80 "list": []
81 },
82 "time": {
83 "from": "2018-02-07T08:42:27.000Z",
84 "to": "2018-02-07T13:48:32.000Z"
85 },
86 "timezone": "utc",
87 "title": "New dashboard"
88 }
89 }
90}
diff --git a/tests/schema/fixtures/dashboard-0031.yaml b/tests/schema/fixtures/dashboard-0031.yaml
new file mode 100644
index 0000000..e261915
--- /dev/null
+++ b/tests/schema/fixtures/dashboard-0031.yaml
@@ -0,0 +1,41 @@
1dashboard:
2 time:
3 from: "2018-02-07T08:42:27.000Z"
4 to: "2018-02-07T13:48:32.000Z"
5 title: New dashboard
6 rows:
7 - title: New row
8 height: 250px
9 panels:
10 - title: no title (click here)
11 type: graph
12 datasource: graphite
13 targets:
14 - target: "stats.gauges.afs.afs01_dfw_openstack_org.part.vicepa.total"
15 refId: "A"
16 hide: true
17 - target: "divideSeries(stats.gauges.afs.afs01_dfw_openstack_org.part.vicpa.used, #A)"
18 refId: "B"
19 hide: false
20 alert:
21 conditions:
22 - evaluator:
23 params:
24 - 0.85
25 type: gt
26 operator:
27 type: and
28 query:
29 params:
30 - C
31 - 5m
32 - now
33 reducer:
34 params: []
35 type: avg
36 type: query
37 executionErrorState: alerting
38 frequency: 60s
39 name: A test alert
40 noDataState: no_data
41