Skip to content

Commit

Permalink
✨ add optional Grafana dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
DrPsychick committed Dec 22, 2024
1 parent 760a89a commit 653013f
Show file tree
Hide file tree
Showing 5 changed files with 322 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sickhub/mtr-exporter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions sickhub/mtr-exporter/ci/test-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ volumeMounts:
volumes:
- name: test
emptyDir: {}
grafanaDashboards:
enabled: true
299 changes: 299 additions & 0 deletions sickhub/mtr-exporter/files/mtr-exporter.json
Original file line number Diff line number Diff line change
@@ -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": ""
}
15 changes: 15 additions & 0 deletions sickhub/mtr-exporter/templates/dashboard.yaml
Original file line number Diff line number Diff line change
@@ -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}}
5 changes: 5 additions & 0 deletions sickhub/mtr-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 653013f

Please sign in to comment.