diff --git a/grafana_dashboards/schema/panel/graph.py b/grafana_dashboards/schema/panel/graph.py index ada6f78..8c4a788 100644 --- a/grafana_dashboards/schema/panel/graph.py +++ b/grafana_dashboards/schema/panel/graph.py @@ -84,6 +84,18 @@ class Graph(Base): y_formats = [y_format] + legend = { + v.Optional('alignAsTable', default=False): v.All(bool), + v.Optional('avg', default=False): v.All(bool), + v.Optional('current', default=False): v.All(bool), + v.Optional('max', default=False): v.All(bool), + v.Optional('min', default=False): v.All(bool), + v.Optional('rightSide', default=False): v.All(bool), + v.Optional('show', default=False): v.All(bool), + v.Optional('total', default=False): v.All(bool), + v.Optional('values', default=False): v.All(bool), + } + null_point_modes = v.Any('connected', 'null', 'null as zero') value_types = v.Any('individual', 'cumulative') @@ -119,6 +131,7 @@ class Graph(Base): v.Required('fill', default=1): v.All(int), v.Optional('hideTimeOverride'): v.All(bool), v.Optional('leftYAxisLabel'): v.All(str, v.Length(min=1)), + v.Optional('legend'): v.All(legend), v.Required('lines', default=True): v.All(bool), v.Required('linewidth', default=2): v.All(int), v.Optional('nullPointMode'): v.All(null_point_modes), diff --git a/tests/schema/fixtures/dashboard-0023.json b/tests/schema/fixtures/dashboard-0023.json new file mode 100644 index 0000000..61bbaa8 --- /dev/null +++ b/tests/schema/fixtures/dashboard-0023.json @@ -0,0 +1,68 @@ +{ + "dashboard": { + "new-dashboard": { + "rows": [ + { + "collapse": false, + "editable": true, + "height": "250px", + "panels": [ + { + "bars": false, + "datasource": "graphite", + "editable": true, + "error": false, + "fill": 1, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "rightSide": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "percentage": false, + "pointradius": 5, + "points": false, + "span": 12, + "stack": false, + "steppedLine": false, + "targets": [ + { + "target": "$hostname.Cpu.cpu_prct_used" + } + ], + "title": "no title (click here)", + "type": "graph", + "x-axis": true, + "y-axis": true + } + ], + "showTitle": false, + "title": "New row" + } + ], + "templating": { + "enabled": true, + "list": [ + { + "datasource": "graphite", + "includeAll": false, + "multi": false, + "name": "hostname", + "query": "node*", + "refresh": true, + "type": "query" + } + ] + }, + "timezone": "utc", + "title": "New dashboard" + } + } +} diff --git a/tests/schema/fixtures/dashboard-0023.yaml b/tests/schema/fixtures/dashboard-0023.yaml new file mode 100644 index 0000000..89f3f36 --- /dev/null +++ b/tests/schema/fixtures/dashboard-0023.yaml @@ -0,0 +1,27 @@ +dashboard: + templating: + - name: hostname + type: query + datasource: graphite + query: node* + refresh: true + title: New dashboard + rows: + - title: New row + height: 250px + panels: + - title: no title (click here) + type: graph + datasource: graphite + targets: + - target: $hostname.Cpu.cpu_prct_used + legend: + alignAsTable: true + avg: true + current: true + max: true + min: true + rightSide: true + show: true + total: false + values: true