diff --git a/docs/layouts/partials/templates/dashboard-tabs.html b/docs/layouts/partials/templates/dashboard-tabs.html new file mode 100644 index 000000000..6b4f2ee31 --- /dev/null +++ b/docs/layouts/partials/templates/dashboard-tabs.html @@ -0,0 +1,25 @@ +
+ + +
+

Click a tab to view the dashboard template

+
+ + +
+ {{ highlight (partial "templates/grafana/dashboard.html" (dict "type" .type "alerts" .alerts "devMode" .devMode)) "json" }} +
+
diff --git a/docs/layouts/partials/templates/grafana/dashboard.html b/docs/layouts/partials/templates/grafana/dashboard.html new file mode 100644 index 000000000..8b5db4f77 --- /dev/null +++ b/docs/layouts/partials/templates/grafana/dashboard.html @@ -0,0 +1,186 @@ +{ + "__inputs": [], + "__elements": {}, + "__requires": [ + { + "type": "panel", + "id": "bargauge", + "name": "Bar gauge", + "version": "" + }, + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "9.5.12" + }, + { + "type": "datasource", + "id": "grafana-azure-monitor-datasource", + "name": "Azure Monitor", + "version": "1.0.0" + } + ], + "title": "{{ humanize .type }}", + "editable": true, + "links": [], + "liveNow": false, + "panels": [ + {{ $types := slice "Log" "Metric" }} + {{ $alerts := where .alerts "visible" true }} + {{ $alerts := where $alerts "type" "in" $types }} + {{ range $idx, $value := sort $alerts "name" "asc" }}{{ if ne $idx 0}}, + {{ end }} { + "title": "{{ $value.name }}", + "datasource": { + "type": "grafana-azure-monitor-datasource", + "uid": "${ds}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "#808080", + "value": null + }, + { +{{ if or (eq $value.properties.operator "GreaterThan") (eq $value.properties.operator "GreaterThanOrEqual") }} + "color": "dark-green",{{ else }} + "color": "dark-red",{{ end }} + "value": 0 + }, + { +{{ if or (eq $value.properties.operator "GreaterThan") (eq $value.properties.operator "GreaterThanOrEqual") }} + "color": "dark-red",{{ else }} + "color": "dark-green",{{ end }} + "value": {{ if $value.properites.threshold }}{{ string $value.properties.threshold }}{{ else }}0{{ end }} + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": {{ mul 12 (mod $idx 2) }}, + "y": {{ mul 8 (div $idx 2) }} + }, + "id": {{ add $idx 1 }}, + "options": { + "displayMode": "basic", + "minVizHeight": 10, + "minVizWidth": 0, + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": true + }, + "showUnfilled": true, + "valueMode": "color" + }, + "pluginVersion": "9.5.12", + "targets": [ + { + "azureLogAnalytics": { +{{ if eq $value.type "Log" }} + "query": {{ jsonify (replace $value.properties.query "\n" " ") }},{{ else }} + "query": "AzureMetrics\r\n| where _ResourceId has '{{ $value.properties.metricNamespace }}'\r\n| where MetricName has '{{ $value.properties.metricName }}'\r\n| summarize metric = avg({{ $value.properties.timeAggregation }}) by _ResourceId, Resource",{{ end }} + "resources": [ + "/subscriptions/$sub" + ] + }, + "azureMonitor": { + "allowedTimeGrainsMs": [], + "timeGrain": "auto" + }, + "datasource": { + "type": "grafana-azure-monitor-datasource", + "uid": "${ds}" + }, + "queryType": "Azure Log Analytics", + "refId": "A" + } + ], + "transformations": [ + { + "id": "organize", + "options": { + "excludeByName": { + "_ResourceId": true + }, + "indexByName": {}, + "renameByName": {} + } + } + ], + "type": "bargauge" + }{{ end }} + ], + "refresh": "", + "schemaVersion": 38, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "current": {}, + "hide": 0, + "includeAll": false, + "label": "Datasource", + "multi": false, + "name": "ds", + "options": [], + "query": "grafana-azure-monitor-datasource", + "queryValue": "", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "type": "datasource" + }, + { + "current": {}, + "datasource": { + "type": "grafana-azure-monitor-datasource", + "uid": "${ds}" + }, + "definition": "", + "hide": 0, + "includeAll": false, + "label": "Subscription", + "multi": false, + "name": "sub", + "options": [], + "query": { + "azureLogAnalytics": { + "query": "", + "resources": [] + }, + "queryType": "Azure Subscriptions", + "refId": "A" + }, + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "type": "query" + } + ] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "version": null +} \ No newline at end of file diff --git a/docs/layouts/shortcodes/alertList.html b/docs/layouts/shortcodes/alertList.html index 48a117f26..1fe124fe9 100644 --- a/docs/layouts/shortcodes/alertList.html +++ b/docs/layouts/shortcodes/alertList.html @@ -33,6 +33,9 @@
+

Dashboards:

+ {{ partial "templates/dashboard-tabs.html" (dict "type" $type "alerts" .alerts "devMode" $.Site.Params.ambaDevMode) }} + {{ range sort .alerts "name" "asc" }} {{ if or (eq .visible true) (eq $.Site.Params.ambaDevMode true) }}