From 653013f517c4eabe57d37330f47ca14f8590f2ed Mon Sep 17 00:00:00 2001 From: DrPsychick Date: Mon, 23 Dec 2024 00:50:27 +0100 Subject: [PATCH] :sparkles: add optional Grafana dashboard --- sickhub/mtr-exporter/Chart.yaml | 2 +- sickhub/mtr-exporter/ci/test-values.yaml | 2 + sickhub/mtr-exporter/files/mtr-exporter.json | 299 ++++++++++++++++++ sickhub/mtr-exporter/templates/dashboard.yaml | 15 + sickhub/mtr-exporter/values.yaml | 5 + 5 files changed, 322 insertions(+), 1 deletion(-) create mode 100644 sickhub/mtr-exporter/files/mtr-exporter.json create mode 100644 sickhub/mtr-exporter/templates/dashboard.yaml diff --git a/sickhub/mtr-exporter/Chart.yaml b/sickhub/mtr-exporter/Chart.yaml index 72dcf7c..2e856de 100644 --- a/sickhub/mtr-exporter/Chart.yaml +++ b/sickhub/mtr-exporter/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: mtr-exporter description: A Helm chart for an mtr-exporter pod providing metrics. type: application -version: 0.0.2 +version: 0.0.3 # https://github.com/mgumz/mtr-exporter # https://github.com/mgumz/mtr-exporter/pkgs/container/mtr-exporter appVersion: "0.4.0" diff --git a/sickhub/mtr-exporter/ci/test-values.yaml b/sickhub/mtr-exporter/ci/test-values.yaml index 828aa25..9bc20c1 100644 --- a/sickhub/mtr-exporter/ci/test-values.yaml +++ b/sickhub/mtr-exporter/ci/test-values.yaml @@ -10,3 +10,5 @@ volumeMounts: volumes: - name: test emptyDir: {} +grafanaDashboards: + enabled: true diff --git a/sickhub/mtr-exporter/files/mtr-exporter.json b/sickhub/mtr-exporter/files/mtr-exporter.json new file mode 100644 index 0000000..485c2f8 --- /dev/null +++ b/sickhub/mtr-exporter/files/mtr-exporter.json @@ -0,0 +1,299 @@ +{ + "__inputs": [ + { + "name": "DS_VICTORIAMETRICS", + "label": "VictoriaMetrics", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], + "__elements": {}, + "__requires": [ + { + "type": "panel", + "id": "barchart", + "name": "Bar chart", + "version": "" + }, + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "11.4.0" + }, + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "1.0.0" + }, + { + "type": "panel", + "id": "stat", + "name": "Stat", + "version": "" + } + ], + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "Grafana dashboard for mtr-exporter (https://artifacthub.io/packages/helm/drpsychick/mtr-exporter). Numeric sorting of series currently depends on a feature of VictoriaMetrics.", + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_VICTORIAMETRICS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 11, + "w": 2, + "x": 0, + "y": 0 + }, + "id": 2, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": true, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "11.4.0", + "targets": [ + { + "editorMode": "code", + "expr": "sum(mtr_report_count_hubs{mtr_exporter_job=\"$label\"})", + "legendFormat": "__auto", + "range": true, + "refId": "A", + "datasource": { + "type": "prometheus", + "uid": "${DS_VICTORIAMETRICS}" + } + } + ], + "title": "Hops", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_VICTORIAMETRICS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "fillOpacity": 80, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineWidth": 1, + "scaleDistribution": { + "type": "linear" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "fieldMinMax": false, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ms" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "count" + }, + "properties": [ + { + "id": "custom.hideFrom", + "value": { + "legend": true, + "tooltip": true, + "viz": true + } + } + ] + } + ] + }, + "gridPos": { + "h": 11, + "w": 22, + "x": 2, + "y": 0 + }, + "id": 1, + "options": { + "barRadius": 0, + "barWidth": 0.97, + "fullHighlight": false, + "groupWidth": 0.7, + "legend": { + "calcs": [ + "mean", + "max" + ], + "displayMode": "table", + "placement": "right", + "showLegend": true + }, + "orientation": "auto", + "showValue": "auto", + "stacking": "none", + "tooltip": { + "mode": "multi", + "sort": "none" + }, + "xTickLabelRotation": 15, + "xTickLabelSpacing": 0 + }, + "pluginVersion": "11.4.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_VICTORIAMETRICS}" + }, + "disableTextWrap": false, + "editorMode": "code", + "exemplar": false, + "expr": "sort_by_label_numeric(avg(mtr_report_avg{mtr_exporter_job=\"$label\"}) by (count, host), \"count\")", + "format": "time_series", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "interval": "10m", + "legendFormat": "{{count}}. {{host}} ", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "MTR hops", + "type": "barchart" + } + ], + "schemaVersion": 40, + "tags": [], + "templating": { + "list": [ + { + "current": {}, + "definition": "label_values(mtr_report_avg,dst)", + "hide": 2, + "name": "destination", + "options": [], + "query": { + "qryType": 1, + "query": "label_values(mtr_report_avg,dst)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 1, + "regex": "", + "type": "query" + }, + { + "current": {}, + "definition": "label_values(mtr_report_avg,mtr_exporter_job)", + "name": "label", + "options": [], + "query": { + "qryType": 1, + "query": "label_values(mtr_report_avg,mtr_exporter_job)", + "refId": "PrometheusVariableQueryEditor-VariableQuery" + }, + "refresh": 1, + "regex": "", + "type": "query" + } + ] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": {}, + "timezone": "browser", + "title": "mtr-exporter", + "uid": "fe7q8ucsdk4cgd", + "version": 20, + "weekStart": "" +} diff --git a/sickhub/mtr-exporter/templates/dashboard.yaml b/sickhub/mtr-exporter/templates/dashboard.yaml new file mode 100644 index 0000000..5bd25b3 --- /dev/null +++ b/sickhub/mtr-exporter/templates/dashboard.yaml @@ -0,0 +1,15 @@ +{{- if .Values.grafanaDashboards.enabled }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + labels: + app: mtr-exporter + grafana_dashboard: "1" + annotations: + grafana_folder: "{{ .Values.grafanaDashboards.folder }}" + name: mtr-exporter-dashboard +data: + mtr-exporter-dashboard.json: |- + {{- .Files.Get "files/mtr-exporter.json" | nindent 4 }} +{{- end}} \ No newline at end of file diff --git a/sickhub/mtr-exporter/values.yaml b/sickhub/mtr-exporter/values.yaml index 13067e8..312c911 100644 --- a/sickhub/mtr-exporter/values.yaml +++ b/sickhub/mtr-exporter/values.yaml @@ -42,6 +42,11 @@ serviceMonitor: labels: {} # prometheus: default +# Enable grafana dashboard as a ConfigMap. This currently depends on `sort_by_label_numeric` of VictoriaMetrics. +grafanaDashboards: + enabled: false + folder: "network" + # This section builds out the service account more information can be found here: https://kubernetes.io/docs/concepts/security/service-accounts/ serviceAccount: # Specifies whether a service account should be created