diff --git a/charts/prometheus-mixin/Chart.yaml b/charts/prometheus-mixin/Chart.yaml index 4da37f20..a3619793 100644 --- a/charts/prometheus-mixin/Chart.yaml +++ b/charts/prometheus-mixin/Chart.yaml @@ -31,12 +31,12 @@ keywords: # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.4.0 +version: 1.5.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. -appVersion: 2.48.0 +appVersion: 2.54.1 maintainers: - name: nlamirault @@ -60,4 +60,4 @@ annotations: url: https://keybase.io/nlamirault/pgp_keys.asc artifacthub.io/changes: | - kind: changed - description: prometheus-mixin v2.48.0 + description: prometheus-mixin v2.54.1 diff --git a/charts/prometheus-mixin/dashboards/prometheus-remote-write.json b/charts/prometheus-mixin/dashboards/prometheus-remote-write.json index c9a7ff37..c860c0fc 100644 --- a/charts/prometheus-mixin/dashboards/prometheus-remote-write.json +++ b/charts/prometheus-mixin/dashboards/prometheus-remote-write.json @@ -54,7 +54,7 @@ "steppedLine": false, "targets": [ { - "expr": "(\n prometheus_remote_storage_highest_timestamp_in_seconds{cluster=~\"$cluster\", instance=~\"$instance\"} \n- \n ignoring(remote_name, url) group_right(instance) (prometheus_remote_storage_queue_highest_sent_timestamp_seconds{cluster=~\"$cluster\", instance=~\"$instance\"} != 0)\n)\n", + "expr": "(\n prometheus_remote_storage_highest_timestamp_in_seconds{cluster=~\"$cluster\", instance=~\"$instance\"} \n- \n ignoring(remote_name, url) group_right(instance) (prometheus_remote_storage_queue_highest_sent_timestamp_seconds{cluster=~\"$cluster\", instance=~\"$instance\", url=~\"$url\"} != 0)\n)\n", "format": "time_series", "intervalFactor": 2, "legendFormat": "{{cluster}}:{{instance}} {{remote_name}}:{{url}}", @@ -135,7 +135,7 @@ "steppedLine": false, "targets": [ { - "expr": "clamp_min(\n rate(prometheus_remote_storage_highest_timestamp_in_seconds{cluster=~\"$cluster\", instance=~\"$instance\"}[5m]) \n- \n ignoring (remote_name, url) group_right(instance) rate(prometheus_remote_storage_queue_highest_sent_timestamp_seconds{cluster=~\"$cluster\", instance=~\"$instance\"}[5m])\n, 0)\n", + "expr": "clamp_min(\n rate(prometheus_remote_storage_highest_timestamp_in_seconds{cluster=~\"$cluster\", instance=~\"$instance\"}[5m]) \n- \n ignoring (remote_name, url) group_right(instance) rate(prometheus_remote_storage_queue_highest_sent_timestamp_seconds{cluster=~\"$cluster\", instance=~\"$instance\", url=~\"$url\"}[5m])\n, 0)\n", "format": "time_series", "intervalFactor": 2, "legendFormat": "{{cluster}}:{{instance}} {{remote_name}}:{{url}}", @@ -229,7 +229,7 @@ "steppedLine": false, "targets": [ { - "expr": "rate(\n prometheus_remote_storage_samples_in_total{cluster=~\"$cluster\", instance=~\"$instance\"}[5m])\n- \n ignoring(remote_name, url) group_right(instance) (rate(prometheus_remote_storage_succeeded_samples_total{cluster=~\"$cluster\", instance=~\"$instance\"}[5m]) or rate(prometheus_remote_storage_samples_total{cluster=~\"$cluster\", instance=~\"$instance\"}[5m]))\n- \n (rate(prometheus_remote_storage_dropped_samples_total{cluster=~\"$cluster\", instance=~\"$instance\"}[5m]) or rate(prometheus_remote_storage_samples_dropped_total{cluster=~\"$cluster\", instance=~\"$instance\"}[5m]))\n", + "expr": "rate(\n prometheus_remote_storage_samples_in_total{cluster=~\"$cluster\", instance=~\"$instance\"}[5m])\n- \n ignoring(remote_name, url) group_right(instance) (rate(prometheus_remote_storage_succeeded_samples_total{cluster=~\"$cluster\", instance=~\"$instance\", url=~\"$url\"}[5m]) or rate(prometheus_remote_storage_samples_total{cluster=~\"$cluster\", instance=~\"$instance\", url=~\"$url\"}[5m]))\n- \n (rate(prometheus_remote_storage_dropped_samples_total{cluster=~\"$cluster\", instance=~\"$instance\", url=~\"$url\"}[5m]) or rate(prometheus_remote_storage_samples_dropped_total{cluster=~\"$cluster\", instance=~\"$instance\", url=~\"$url\"}[5m]))\n", "format": "time_series", "intervalFactor": 2, "legendFormat": "{{cluster}}:{{instance}} {{remote_name}}:{{url}}", @@ -324,7 +324,7 @@ "steppedLine": false, "targets": [ { - "expr": "prometheus_remote_storage_shards{cluster=~\"$cluster\", instance=~\"$instance\"}", + "expr": "prometheus_remote_storage_shards{cluster=~\"$cluster\", instance=~\"$instance\", url=~\"$url\"}", "format": "time_series", "intervalFactor": 2, "legendFormat": "{{cluster}}:{{instance}} {{remote_name}}:{{url}}", @@ -405,7 +405,7 @@ "steppedLine": false, "targets": [ { - "expr": "prometheus_remote_storage_shards_max{cluster=~\"$cluster\", instance=~\"$instance\"}", + "expr": "prometheus_remote_storage_shards_max{cluster=~\"$cluster\", instance=~\"$instance\", url=~\"$url\"}", "format": "time_series", "intervalFactor": 2, "legendFormat": "{{cluster}}:{{instance}} {{remote_name}}:{{url}}", @@ -486,7 +486,7 @@ "steppedLine": false, "targets": [ { - "expr": "prometheus_remote_storage_shards_min{cluster=~\"$cluster\", instance=~\"$instance\"}", + "expr": "prometheus_remote_storage_shards_min{cluster=~\"$cluster\", instance=~\"$instance\", url=~\"$url\"}", "format": "time_series", "intervalFactor": 2, "legendFormat": "{{cluster}}:{{instance}} {{remote_name}}:{{url}}", @@ -567,7 +567,7 @@ "steppedLine": false, "targets": [ { - "expr": "prometheus_remote_storage_shards_desired{cluster=~\"$cluster\", instance=~\"$instance\"}", + "expr": "prometheus_remote_storage_shards_desired{cluster=~\"$cluster\", instance=~\"$instance\", url=~\"$url\"}", "format": "time_series", "intervalFactor": 2, "legendFormat": "{{cluster}}:{{instance}} {{remote_name}}:{{url}}", @@ -661,7 +661,7 @@ "steppedLine": false, "targets": [ { - "expr": "prometheus_remote_storage_shard_capacity{cluster=~\"$cluster\", instance=~\"$instance\"}", + "expr": "prometheus_remote_storage_shard_capacity{cluster=~\"$cluster\", instance=~\"$instance\", url=~\"$url\"}", "format": "time_series", "intervalFactor": 2, "legendFormat": "{{cluster}}:{{instance}} {{remote_name}}:{{url}}", @@ -742,7 +742,7 @@ "steppedLine": false, "targets": [ { - "expr": "prometheus_remote_storage_pending_samples{cluster=~\"$cluster\", instance=~\"$instance\"} or prometheus_remote_storage_samples_pending{cluster=~\"$cluster\", instance=~\"$instance\"}", + "expr": "prometheus_remote_storage_pending_samples{cluster=~\"$cluster\", instance=~\"$instance\", url=~\"$url\"} or prometheus_remote_storage_samples_pending{cluster=~\"$cluster\", instance=~\"$instance\", url=~\"$url\"}", "format": "time_series", "intervalFactor": 2, "legendFormat": "{{cluster}}:{{instance}} {{remote_name}}:{{url}}", @@ -1011,7 +1011,7 @@ "steppedLine": false, "targets": [ { - "expr": "rate(prometheus_remote_storage_dropped_samples_total{cluster=~\"$cluster\", instance=~\"$instance\"}[5m]) or rate(prometheus_remote_storage_samples_dropped_total{cluster=~\"$cluster\", instance=~\"$instance\"}[5m])", + "expr": "rate(prometheus_remote_storage_dropped_samples_total{cluster=~\"$cluster\", instance=~\"$instance\", url=~\"$url\"}[5m]) or rate(prometheus_remote_storage_samples_dropped_total{cluster=~\"$cluster\", instance=~\"$instance\", url=~\"$url\"}[5m])", "format": "time_series", "intervalFactor": 2, "legendFormat": "{{cluster}}:{{instance}} {{remote_name}}:{{url}}", @@ -1092,7 +1092,7 @@ "steppedLine": false, "targets": [ { - "expr": "rate(prometheus_remote_storage_failed_samples_total{cluster=~\"$cluster\", instance=~\"$instance\"}[5m]) or rate(prometheus_remote_storage_samples_failed_total{cluster=~\"$cluster\", instance=~\"$instance\"}[5m])", + "expr": "rate(prometheus_remote_storage_failed_samples_total{cluster=~\"$cluster\", instance=~\"$instance\", url=~\"$url\"}[5m]) or rate(prometheus_remote_storage_samples_failed_total{cluster=~\"$cluster\", instance=~\"$instance\", url=~\"$url\"}[5m])", "format": "time_series", "intervalFactor": 2, "legendFormat": "{{cluster}}:{{instance}} {{remote_name}}:{{url}}", @@ -1173,7 +1173,7 @@ "steppedLine": false, "targets": [ { - "expr": "rate(prometheus_remote_storage_retried_samples_total{cluster=~\"$cluster\", instance=~\"$instance\"}[5m]) or rate(prometheus_remote_storage_samples_retried_total{cluster=~\"$cluster\", instance=~\"$instance\"}[5m])", + "expr": "rate(prometheus_remote_storage_retried_samples_total{cluster=~\"$cluster\", instance=~\"$instance\", url=~\"$url\"}[5m]) or rate(prometheus_remote_storage_samples_retried_total{cluster=~\"$cluster\", instance=~\"$instance\", url=~\"$url\"}[5m])", "format": "time_series", "intervalFactor": 2, "legendFormat": "{{cluster}}:{{instance}} {{remote_name}}:{{url}}", @@ -1254,7 +1254,7 @@ "steppedLine": false, "targets": [ { - "expr": "rate(prometheus_remote_storage_enqueue_retries_total{cluster=~\"$cluster\", instance=~\"$instance\"}[5m])", + "expr": "rate(prometheus_remote_storage_enqueue_retries_total{cluster=~\"$cluster\", instance=~\"$instance\", url=~\"$url\"}[5m])", "format": "time_series", "intervalFactor": 2, "legendFormat": "{{cluster}}:{{instance}} {{remote_name}}:{{url}}", diff --git a/charts/prometheus-mixin/dashboards/prometheus.json b/charts/prometheus-mixin/dashboards/prometheus.json index 3cc21b06..4de16eab 100644 --- a/charts/prometheus-mixin/dashboards/prometheus.json +++ b/charts/prometheus-mixin/dashboards/prometheus.json @@ -80,6 +80,21 @@ "type": "number", "unit": "s" }, + { + "alias": "Cluster", + "colorMode": null, + "colors": [], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "link": false, + "linkTargetBlank": false, + "linkTooltip": "Drill down", + "linkUrl": "", + "pattern": "cluster", + "thresholds": [], + "type": "number", + "unit": "short" + }, { "alias": "Instance", "colorMode": null, @@ -139,18 +154,16 @@ ], "targets": [ { - "expr": "count by (job, instance, version) (prometheus_build_info{job=~\"$job\", instance=~\"$instance\"})", + "expr": "count by (cluster, job, instance, version) (prometheus_build_info{cluster=~\"$cluster\", job=~\"$job\", instance=~\"$instance\"})", "format": "table", "instant": true, - "intervalFactor": 2, "legendFormat": "", "refId": "A" }, { - "expr": "max by (job, instance) (time() - process_start_time_seconds{job=~\"$job\", instance=~\"$instance\"})", + "expr": "max by (cluster, job, instance) (time() - process_start_time_seconds{cluster=~\"$cluster\", job=~\"$job\", instance=~\"$instance\"})", "format": "table", "instant": true, - "intervalFactor": 2, "legendFormat": "", "refId": "B" } @@ -236,10 +249,9 @@ "steppedLine": false, "targets": [ { - "expr": "sum(rate(prometheus_target_sync_length_seconds_sum{job=~\"$job\",instance=~\"$instance\"}[5m])) by (scrape_job) * 1e3", + "expr": "sum(rate(prometheus_target_sync_length_seconds_sum{cluster=~\"$cluster\",job=~\"$job\",instance=~\"$instance\"}[5m])) by (cluster, job, scrape_job, instance) * 1e3", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{scrape_job}}", + "legendFormat": "{{cluster}}:{{job}}:{{instance}}:{{scrape_job}}", "legendLink": null } ], @@ -311,10 +323,9 @@ "steppedLine": false, "targets": [ { - "expr": "sum(prometheus_sd_discovered_targets{job=~\"$job\",instance=~\"$instance\"})", + "expr": "sum by (cluster, job, instance) (prometheus_sd_discovered_targets{cluster=~\"$cluster\", job=~\"$job\",instance=~\"$instance\"})", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "Targets", + "legendFormat": "{{cluster}}:{{job}}:{{instance}}", "legendLink": null } ], @@ -398,10 +409,9 @@ "steppedLine": false, "targets": [ { - "expr": "rate(prometheus_target_interval_length_seconds_sum{job=~\"$job\",instance=~\"$instance\"}[5m]) / rate(prometheus_target_interval_length_seconds_count{job=~\"$job\",instance=~\"$instance\"}[5m]) * 1e3", + "expr": "rate(prometheus_target_interval_length_seconds_sum{cluster=~\"$cluster\", job=~\"$job\",instance=~\"$instance\"}[5m]) / rate(prometheus_target_interval_length_seconds_count{cluster=~\"$cluster\", job=~\"$job\",instance=~\"$instance\"}[5m]) * 1e3", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{interval}} configured", + "legendFormat": "{{cluster}}:{{job}}:{{instance}} {{interval}} configured", "legendLink": null } ], @@ -473,38 +483,33 @@ "steppedLine": false, "targets": [ { - "expr": "sum by (job) (rate(prometheus_target_scrapes_exceeded_body_size_limit_total[1m]))", + "expr": "sum by (cluster, job, instance) (rate(prometheus_target_scrapes_exceeded_body_size_limit_total{cluster=~\"$cluster\",job=~\"$job\",instance=~\"$instance\"}[1m]))", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "exceeded body size limit: {{job}}", + "legendFormat": "exceeded body size limit: {{cluster}} {{job}} {{instance}}", "legendLink": null }, { - "expr": "sum by (job) (rate(prometheus_target_scrapes_exceeded_sample_limit_total[1m]))", + "expr": "sum by (cluster, job, instance) (rate(prometheus_target_scrapes_exceeded_sample_limit_total{cluster=~\"$cluster\",job=~\"$job\",instance=~\"$instance\"}[1m]))", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "exceeded sample limit: {{job}}", + "legendFormat": "exceeded sample limit: {{cluster}} {{job}} {{instance}}", "legendLink": null }, { - "expr": "sum by (job) (rate(prometheus_target_scrapes_sample_duplicate_timestamp_total[1m]))", + "expr": "sum by (cluster, job, instance) (rate(prometheus_target_scrapes_sample_duplicate_timestamp_total{cluster=~\"$cluster\",job=~\"$job\",instance=~\"$instance\"}[1m]))", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "duplicate timestamp: {{job}}", + "legendFormat": "duplicate timestamp: {{cluster}} {{job}} {{instance}}", "legendLink": null }, { - "expr": "sum by (job) (rate(prometheus_target_scrapes_sample_out_of_bounds_total[1m]))", + "expr": "sum by (cluster, job, instance) (rate(prometheus_target_scrapes_sample_out_of_bounds_total{cluster=~\"$cluster\",job=~\"$job\",instance=~\"$instance\"}[1m]))", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "out of bounds: {{job}}", + "legendFormat": "out of bounds: {{cluster}} {{job}} {{instance}}", "legendLink": null }, { - "expr": "sum by (job) (rate(prometheus_target_scrapes_sample_out_of_order_total[1m]))", + "expr": "sum by (cluster, job, instance) (rate(prometheus_target_scrapes_sample_out_of_order_total{cluster=~\"$cluster\",job=~\"$job\",instance=~\"$instance\"}[1m]))", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "out of order: {{job}}", + "legendFormat": "out of order: {{cluster}} {{job}} {{instance}}", "legendLink": null } ], @@ -576,10 +581,9 @@ "steppedLine": false, "targets": [ { - "expr": "rate(prometheus_tsdb_head_samples_appended_total{job=~\"$job\",instance=~\"$instance\"}[5m])", + "expr": "rate(prometheus_tsdb_head_samples_appended_total{cluster=~\"$cluster\", job=~\"$job\",instance=~\"$instance\"}[5m])", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{job}} {{instance}}", + "legendFormat": "{{cluster}} {{job}} {{instance}}", "legendLink": null } ], @@ -663,10 +667,9 @@ "steppedLine": false, "targets": [ { - "expr": "prometheus_tsdb_head_series{job=~\"$job\",instance=~\"$instance\"}", + "expr": "prometheus_tsdb_head_series{cluster=~\"$cluster\",job=~\"$job\",instance=~\"$instance\"}", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{job}} {{instance}} head series", + "legendFormat": "{{cluster}} {{job}} {{instance}} head series", "legendLink": null } ], @@ -738,10 +741,9 @@ "steppedLine": false, "targets": [ { - "expr": "prometheus_tsdb_head_chunks{job=~\"$job\",instance=~\"$instance\"}", + "expr": "prometheus_tsdb_head_chunks{cluster=~\"$cluster\",job=~\"$job\",instance=~\"$instance\"}", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{job}} {{instance}} head chunks", + "legendFormat": "{{cluster}} {{job}} {{instance}} head chunks", "legendLink": null } ], @@ -825,10 +827,9 @@ "steppedLine": false, "targets": [ { - "expr": "rate(prometheus_engine_query_duration_seconds_count{job=~\"$job\",instance=~\"$instance\",slice=\"inner_eval\"}[5m])", + "expr": "rate(prometheus_engine_query_duration_seconds_count{cluster=~\"$cluster\",job=~\"$job\",instance=~\"$instance\",slice=\"inner_eval\"}[5m])", "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{job}} {{instance}}", + "legendFormat": "{{cluster}} {{job}} {{instance}}", "legendLink": null } ], @@ -900,9 +901,8 @@ "steppedLine": false, "targets": [ { - "expr": "max by (slice) (prometheus_engine_query_duration_seconds{quantile=\"0.9\",job=~\"$job\",instance=~\"$instance\"}) * 1e3", + "expr": "max by (slice) (prometheus_engine_query_duration_seconds{quantile=\"0.9\",cluster=~\"$cluster\", job=~\"$job\",instance=~\"$instance\"}) * 1e3", "format": "time_series", - "intervalFactor": 2, "legendFormat": "{{slice}}", "legendLink": null } @@ -966,7 +966,7 @@ "value": "default" }, "hide": 0, - "label": "Data Source", + "label": "Data source", "name": "datasource", "options": [], "query": "prometheus", @@ -974,6 +974,30 @@ "regex": "", "type": "datasource" }, + { + "allValue": ".+", + "current": { + "selected": true, + "text": "All", + "value": "$__all" + }, + "datasource": "$datasource", + "hide": 0, + "includeAll": true, + "label": "cluster", + "multi": true, + "name": "cluster", + "options": [], + "query": "label_values(prometheus_build_info{job=\"prometheus\"}, cluster)", + "refresh": 1, + "regex": "", + "sort": 2, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, { "allValue": ".+", "current": { @@ -988,7 +1012,7 @@ "multi": true, "name": "job", "options": [], - "query": "label_values(prometheus_build_info{job=\"prometheus\"}, job)", + "query": "label_values(prometheus_build_info{cluster=~\"$cluster\"}, job)", "refresh": 1, "regex": "", "sort": 2, @@ -1012,7 +1036,7 @@ "multi": true, "name": "instance", "options": [], - "query": "label_values(prometheus_build_info{job=~\"$job\"}, instance)", + "query": "label_values(prometheus_build_info{cluster=~\"$cluster\", job=~\"$job\"}, instance)", "refresh": 1, "regex": "", "sort": 2, diff --git a/charts/prometheus-mixin/templates/alerts.yaml b/charts/prometheus-mixin/templates/alerts.yaml index 3fa6e934..d15d4b59 100644 --- a/charts/prometheus-mixin/templates/alerts.yaml +++ b/charts/prometheus-mixin/templates/alerts.yaml @@ -1,3 +1,4 @@ +{{ if .Values.monitor.enabled -}} --- apiVersion: monitoring.coreos.com/v1 kind: PrometheusRule @@ -8,6 +9,7 @@ metadata: {{- include "prometheus-mixin.annotations" . | indent 4 }} labels: {{- include "prometheus-mixin.labels" . | indent 4 }} + app.kubernetes.io/component: metrics {{- if .Values.monitor.additionalLabels }} {{- toYaml .Values.monitor.additionalLabels | nindent 4 }} {{- end }} @@ -35,6 +37,15 @@ spec: for: 20m labels: severity: warning + - alert: PrometheusKubernetesListWatchFailures + annotations: + description: Kubernetes service discovery of Prometheus {{`{{`}}.instance{{`}}`}} is experiencing {{`{{`}} printf "%.0f" $value {{`}}`}} failures with LIST/WATCH requests to the Kubernetes API in the last 5 minutes. + summary: Requests in Kubernetes SD are failing. + expr: | + increase(prometheus_sd_kubernetes_failures_total{job="prometheus"}[5m]) > 0 + for: 15m + labels: + severity: warning - alert: PrometheusNotificationQueueRunningFull annotations: description: Alert notification queue of Prometheus {{`{{`}}.instance{{`}}`}} is running full. @@ -100,7 +111,7 @@ spec: summary: Prometheus is not ingesting samples. expr: | ( - rate(prometheus_tsdb_head_samples_appended_total{job="prometheus"}[5m]) <= 0 + sum without(type) (rate(prometheus_tsdb_head_samples_appended_total{job="prometheus"}[5m])) <= 0 and ( sum without(scrape_job) (prometheus_target_metadata_cache_entries{job="prometheus"}) > 0 @@ -266,3 +277,4 @@ spec: for: 15m labels: severity: critical +{{- end }} diff --git a/charts/prometheus-mixin/templates/configmap-dashboards.yaml b/charts/prometheus-mixin/templates/configmap-dashboards.yaml index c63d3868..d81e1948 100644 --- a/charts/prometheus-mixin/templates/configmap-dashboards.yaml +++ b/charts/prometheus-mixin/templates/configmap-dashboards.yaml @@ -1,24 +1,50 @@ ---- +{{ if .Values.grafanaDashboard.enabled -}} {{- $files := .Files.Glob "dashboards/*.json" }} {{- if $files }} +--- apiVersion: v1 kind: ConfigMapList items: {{- range $path, $fileContents := $files }} -{{- $dashboardName := regexReplaceAll "(^.*/)(.*)\\.json$" $path "${2}" }} +{{- $dashboardName := regexReplaceAll "(^.*/)(.*)\\.json$" $path "${2}" | lower }} - apiVersion: v1 kind: ConfigMap metadata: - name: {{ printf "dashboard-prometheus-mixin-%s" $dashboardName | trunc 63 | trimSuffix "-" }} - namespace: {{ include "prometheus-mixin.namespace" $ }} annotations: - grafana-folder: {{ $.Values.grafana.folder }} + grafana-folder: {{ $.Values.grafanaDashboard.folder }} {{- include "prometheus-mixin.annotations" $ | indent 6 }} labels: grafana-dashboard: {{ $dashboardName }} {{- include "prometheus-mixin.labels" $ | indent 6 }} + app.kubernetes.io/component: dashboard + name: {{ printf "dashboard-%s" $dashboardName | trunc 63 | trimSuffix "-" }} + namespace: {{ include "prometheus-mixin.namespace" $ }} data: {{ $dashboardName }}.json: |- {{ $.Files.Get $path | indent 6}} {{- end }} +{{ if $.Values.grafanaDashboard.grafanaOperator.enabled -}} +{{- range $path, $fileContents := $files }} +{{- $dashboardName := regexReplaceAll "(^.*/)(.*)\\.json$" $path "${2}" }} +--- +apiVersion: grafana.integreatly.org/v1beta1 +kind: GrafanaDashboard +metadata: + labels: + {{- include "prometheus-mixin.labels" $ | indent 4 }} + app.kubernetes.io/component: dashboard + name: {{ printf "%s" $dashboardName | trunc 63 | trimSuffix "-" | lower }} + namespace: {{ $.Release.Namespace }} +spec: + allowCrossNamespaceImport: {{ $.Values.grafanaDashboard.grafanaOperator.allowCrossNamespaceImport }} + folder: {{ $.Values.grafanaDashboard.folder }} + instanceSelector: + matchLabels: + {{- toYaml $.Values.grafanaDashboard.grafanaOperator.matchLabels | nindent 6 }} + configMapRef: + name: {{ printf "dashboard-%s" $dashboardName | trunc 63 | trimSuffix "-" }} + key: {{ $dashboardName }}.json +{{- end }} +{{- end }} +{{- end }} {{- end }}