Skip to content

Commit ae70688

Browse files
committed
configurable prometheus uid
1 parent ab4686e commit ae70688

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

stack/templates/_helpers.tpl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ Expects a dict with keys: global, service
355355
{{- $service := .service -}}
356356
{{- $metricsQuery := printf "sum(rate(nginx_ingress_controller_requests{namespace=\"%s\", service=\"%s\", status=~\"2..\"}[5m]))\n/\nsum(rate(nginx_ingress_controller_requests{namespace=\"%s\", service=\"%s\"}[5m])) * 100" $global.Values.global.argoBuildEnv.appNamespace (include "service.fullname" $service) $global.Values.global.argoBuildEnv.appNamespace (include "service.fullname" $service) -}}
357357
{{- $panelDict := dict
358-
"datasource" (dict "type" "prometheus" "uid" "amp")
358+
"datasource" (dict "type" "prometheus" "uid" $global.Values.global.grafanaDashboard.datasources.prometheus.uid)
359359
"gridPos" (dict "h" 8 "w" 12)
360360
"options" (dict
361361
"legend" (dict
@@ -373,7 +373,7 @@ Expects a dict with keys: global, service
373373
"pluginVersion" "12.1.0"
374374
"targets" (list
375375
(dict
376-
"datasource" (dict "type" "prometheus" "uid" "amp")
376+
"datasource" (dict "type" "prometheus" "uid" $global.Values.global.grafanaDashboard.datasources.prometheus.uid)
377377
"editorMode" "code"
378378
"expr" $metricsQuery
379379
"legendFormat" "__auto"
@@ -396,7 +396,7 @@ Expects a dict with keys: global, service
396396
{{- $service := .service -}}
397397
{{- $metricsQuery := printf "sum(rate(nginx_ingress_controller_requests{namespace=\"%s\", service=\"%s\", status!~\"2..\"}[5m])) by (status)\n/\nsum(rate(nginx_ingress_controller_requests{namespace=\"%s\", service=\"%s\"}[5m])) * 100" $global.Values.global.argoBuildEnv.appNamespace (include "service.fullname" $service) $global.Values.global.argoBuildEnv.appNamespace (include "service.fullname" $service) -}}
398398
{{- $panelDict := dict
399-
"datasource" (dict "type" "prometheus" "uid" "amp")
399+
"datasource" (dict "type" "prometheus" "uid" $global.Values.global.grafanaDashboard.datasources.prometheus.uid)
400400
"gridPos" (dict "h" 8 "w" 12)
401401
"options" (dict
402402
"legend" (dict
@@ -414,7 +414,7 @@ Expects a dict with keys: global, service
414414
"pluginVersion" "12.1.0"
415415
"targets" (list
416416
(dict
417-
"datasource" (dict "type" "prometheus" "uid" "amp")
417+
"datasource" (dict "type" "prometheus" "uid" $global.Values.global.grafanaDashboard.datasources.prometheus.uid)
418418
"editorMode" "code"
419419
"expr" $metricsQuery
420420
"legendFormat" "{{status}}"
@@ -437,7 +437,7 @@ Expects a dict with keys: global, service
437437
{{- $service := .service -}}
438438
{{- $metricsQuery := printf "increase(kube_pod_container_status_restarts_total{namespace=\"%s\", pod=~\"%s-.*\"}[5m])" $global.Values.global.argoBuildEnv.appNamespace (include "service.fullname" $service) -}}
439439
{{- $panelDict := dict
440-
"datasource" (dict "type" "prometheus" "uid" "amp")
440+
"datasource" (dict "type" "prometheus" "uid" $global.Values.global.grafanaDashboard.datasources.prometheus.uid)
441441
"gridPos" (dict "h" 8 "w" 12)
442442
"options" (dict
443443
"legend" (dict
@@ -455,7 +455,7 @@ Expects a dict with keys: global, service
455455
"pluginVersion" "12.1.0"
456456
"targets" (list
457457
(dict
458-
"datasource" (dict "type" "prometheus" "uid" "amp")
458+
"datasource" (dict "type" "prometheus" "uid" $global.Values.global.grafanaDashboard.datasources.prometheus.uid)
459459
"editorMode" "code"
460460
"expr" $metricsQuery
461461
"legendFormat" "{{pod}}"
@@ -478,7 +478,7 @@ Expects a dict with keys: global, service
478478
{{- $service := .service -}}
479479
{{- $metricsQuery := printf "sum(rate(nginx_ingress_controller_request_duration_seconds_sum{namespace=\"%s\", status=\"200\", service=\"%s\"}[5m]))\n/\nsum(rate(nginx_ingress_controller_request_duration_seconds_count{namespace=\"%s\", status=\"200\", service=\"%s\"}[5m]))" $global.Values.global.argoBuildEnv.appNamespace (include "service.fullname" $service) $global.Values.global.argoBuildEnv.appNamespace (include "service.fullname" $service) -}}
480480
{{- $panelDict := dict
481-
"datasource" (dict "type" "prometheus" "uid" "amp")
481+
"datasource" (dict "type" "prometheus" "uid" $global.Values.global.grafanaDashboard.datasources.prometheus.uid)
482482
"gridPos" (dict "h" 8 "w" 12)
483483
"options" (dict
484484
"legend" (dict
@@ -496,7 +496,7 @@ Expects a dict with keys: global, service
496496
"pluginVersion" "12.1.0"
497497
"targets" (list
498498
(dict
499-
"datasource" (dict "type" "prometheus" "uid" "amp")
499+
"datasource" (dict "type" "prometheus" "uid" $global.Values.global.grafanaDashboard.datasources.prometheus.uid)
500500
"editorMode" "code"
501501
"expr" $metricsQuery
502502
"legendFormat" "__auto"
@@ -522,7 +522,7 @@ Expects a dict with keys: global, cronJob
522522
{{- $successQuery := printf "count((kube_job_status_succeeded{namespace=\"%s\", job_name=~\"%s-.*\"} UNLESS kube_job_status_succeeded{namespace=\"%s\", job_name=~\"%s-.*\"} offset $__interval) == 1)" $namespace $cronJobFullname $namespace $cronJobFullname -}}
523523
{{- $failureQuery := printf "count((kube_job_status_failed{namespace=\"%s\", job_name=~\"%s-.*\"} UNLESS kube_job_status_failed{namespace=\"%s\", job_name=~\"%s-.*\"} offset $__interval) == 1)" $namespace $cronJobFullname $namespace $cronJobFullname -}}
524524
{{- $panelDict := dict
525-
"datasource" (dict "type" "prometheus" "uid" "amp")
525+
"datasource" (dict "type" "prometheus" "uid" $global.Values.global.grafanaDashboard.datasources.prometheus.uid)
526526
"gridPos" (dict "h" 8 "w" 12)
527527
"options" (dict
528528
"legend" (dict
@@ -549,15 +549,15 @@ Expects a dict with keys: global, cronJob
549549
"pluginVersion" "12.1.0"
550550
"targets" (list
551551
(dict
552-
"datasource" (dict "type" "prometheus" "uid" "amp")
552+
"datasource" (dict "type" "prometheus" "uid" $global.Values.global.grafanaDashboard.datasources.prometheus.uid)
553553
"editorMode" "code"
554554
"expr" $successQuery
555555
"legendFormat" "Success"
556556
"range" true
557557
"refId" "A"
558558
)
559559
(dict
560-
"datasource" (dict "type" "prometheus" "uid" "amp")
560+
"datasource" (dict "type" "prometheus" "uid" $global.Values.global.grafanaDashboard.datasources.prometheus.uid)
561561
"editorMode" "code"
562562
"expr" $failureQuery
563563
"legendFormat" "Failure"
@@ -646,7 +646,7 @@ Expects a dict with keys: global, cronJob
646646
{{- $namespace := $global.Values.global.argoBuildEnv.appNamespace -}}
647647
{{- $lastSuccessQuery := printf "max(kube_job_status_completion_time{namespace=\"%s\", job_name=~\"%s-.*\"} > 0) * 1000" $namespace $cronJobFullname -}}
648648
{{- $panelDict := dict
649-
"datasource" (dict "type" "prometheus" "uid" "amp")
649+
"datasource" (dict "type" "prometheus" "uid" $global.Values.global.grafanaDashboard.datasources.prometheus.uid)
650650
"gridPos" (dict "h" 8 "w" 6)
651651
"options" (dict
652652
"colorMode" "value"
@@ -664,7 +664,7 @@ Expects a dict with keys: global, cronJob
664664
"pluginVersion" "12.1.0"
665665
"targets" (list
666666
(dict
667-
"datasource" (dict "type" "prometheus" "uid" "amp")
667+
"datasource" (dict "type" "prometheus" "uid" $global.Values.global.grafanaDashboard.datasources.prometheus.uid)
668668
"editorMode" "code"
669669
"expr" $lastSuccessQuery
670670
"legendFormat" "Last Successful Run"
@@ -714,7 +714,7 @@ Expects a dict with keys: global, cronJob
714714
{{- $namespace := $global.Values.global.argoBuildEnv.appNamespace -}}
715715
{{- $avgDurationQuery := printf "avg(kube_job_status_completion_time{namespace=\"%s\", job_name=~\"%s-.*\"} - kube_job_status_start_time{namespace=\"%s\", job_name=~\"%s-.*\"})" $namespace $cronJobFullname $namespace $cronJobFullname -}}
716716
{{- $panelDict := dict
717-
"datasource" (dict "type" "prometheus" "uid" "amp")
717+
"datasource" (dict "type" "prometheus" "uid" $global.Values.global.grafanaDashboard.datasources.prometheus.uid)
718718
"gridPos" (dict "h" 8 "w" 6)
719719
"options" (dict
720720
"colorMode" "value"
@@ -732,7 +732,7 @@ Expects a dict with keys: global, cronJob
732732
"pluginVersion" "12.1.0"
733733
"targets" (list
734734
(dict
735-
"datasource" (dict "type" "prometheus" "uid" "amp")
735+
"datasource" (dict "type" "prometheus" "uid" $global.Values.global.grafanaDashboard.datasources.prometheus.uid)
736736
"editorMode" "code"
737737
"expr" $avgDurationQuery
738738
"legendFormat" "Average Duration"

stack/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,9 @@ global: # @schema description: Global configuration for the stack - this serves
306306

307307
grafanaDashboard:
308308
enabled: false # @schema description: Enable Grafana dashboard (globally, can be overridden per service)
309+
datasources:
310+
prometheus:
311+
uid: "amp" # @schema description: Prometheus datasource UID
309312
instanceSelector: # @schema description: Instance selector for the Grafana dashboard
310313
matchLabels:
311314
name: central-grafana

0 commit comments

Comments
 (0)