From 6330dee04f4d5a161629ddbb179f4aa127ce834f Mon Sep 17 00:00:00 2001 From: QuentinBisson Date: Thu, 12 Oct 2023 14:03:24 +0200 Subject: [PATCH] Add cluster-info recording rule Signed-off-by: QuentinBisson --- CHANGELOG.md | 4 +++ .../recording-rules/grafana-cloud.rules.yml | 34 +++++++++++++++++++ helm/prometheus-rules/values.schema.json | 6 ++++ helm/prometheus-rules/values.yaml | 1 + 4 files changed, 45 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0314339fa..790467bcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add recording rules to list all clusters. + ## [2.138.1] - 2023-10-11 ### Fixed diff --git a/helm/prometheus-rules/templates/recording-rules/grafana-cloud.rules.yml b/helm/prometheus-rules/templates/recording-rules/grafana-cloud.rules.yml index e1bdfc241..dfb0fe4a6 100644 --- a/helm/prometheus-rules/templates/recording-rules/grafana-cloud.rules.yml +++ b/helm/prometheus-rules/templates/recording-rules/grafana-cloud.rules.yml @@ -58,6 +58,40 @@ spec: record: aggregation:giantswarm:app_upgrade_available - name: clusters.grafana-cloud.recording rules: + # This recording rule is used to list all clusters. The last expression is used to list vintage MCs + - expr: |- + avg by (cluster_id, customer, installation) ( + label_replace( + capi_cluster_info, + "cluster_id", + "$1", + "name", + "(.*)" + ) >= 1 + or cluster_operator_cluster_status >= 1 + or cluster_service_cluster_info >= 1 + or + label_replace( + label_replace( + label_replace( + vector(1), + "cluster_id", + {{ .Values.managementCluster.name | quote }}, + "", + "" + ), + "customer", + {{ .Values.managementCluster.customer | quote }}, + "", + "" + ), + "installation", + {{ .Values.managementCluster.name | quote }}, + "", + "" + ) + ) + record: aggregation:giantswarm:cluster_info - expr: sum(label_replace(azure_operator_cluster_release{release_version!=""}, "cluster_id", "$1", "exported_cluster_id", "(.*)")) by (release_version, cluster_id) or sum(cluster_service_cluster_info) by (release_version, cluster_id) / 2 or sum(cluster_operator_cluster_status{release_version!=""}) by (release_version, cluster_id) record: aggregation:giantswarm:cluster_release_version - expr: avg_over_time(cluster_operator_cluster_create_transition[1w]) or avg_over_time(azure_operator_cluster_create_transition[1w]) diff --git a/helm/prometheus-rules/values.schema.json b/helm/prometheus-rules/values.schema.json index db0a1f3a3..3d7ef7029 100644 --- a/helm/prometheus-rules/values.schema.json +++ b/helm/prometheus-rules/values.schema.json @@ -5,6 +5,9 @@ "managementCluster": { "type": "object", "properties": { + "customer": { + "type": "string" + }, "name": { "type": "string" }, @@ -14,6 +17,9 @@ "provider": { "type": "object", "properties": { + "flavor": { + "type": "string" + }, "kind": { "type": "string" } diff --git a/helm/prometheus-rules/values.yaml b/helm/prometheus-rules/values.yaml index dc97e7490..9672251be 100644 --- a/helm/prometheus-rules/values.yaml +++ b/helm/prometheus-rules/values.yaml @@ -5,6 +5,7 @@ project: branch: '[[ .Branch ]]' commit: '[[ .SHA ]]' managementCluster: + customer: "" name: "" pipeline: "" provider: