From b3079717f963027efee5e0f35c69fb632bb0bd50 Mon Sep 17 00:00:00 2001
From: Ofer Ziss <91005344+oferziss-armis@users.noreply.github.com>
Date: Wed, 13 Nov 2024 01:40:54 -0800
Subject: [PATCH] mimir-mixin - Support for specific additional labels on
 resoruces (#916)

* Adds Support for specifying additional labels to be added only to recording rules / alerting rules

Signed-off-by: Ofer Ziss <ofer.ziss@armis.com>
---
 charts/mimir-mixin/Chart.yaml            |  2 +-
 charts/mimir-mixin/README.md             | 33 ++++++++++++------------
 charts/mimir-mixin/templates/alerts.yaml |  3 +++
 charts/mimir-mixin/templates/rules.yaml  |  3 +++
 charts/mimir-mixin/values.yaml           | 10 +++++++
 5 files changed, 34 insertions(+), 17 deletions(-)

diff --git a/charts/mimir-mixin/Chart.yaml b/charts/mimir-mixin/Chart.yaml
index 05959b42..86b2e89a 100644
--- a/charts/mimir-mixin/Chart.yaml
+++ b/charts/mimir-mixin/Chart.yaml
@@ -28,7 +28,7 @@ keywords:
   - monitoring-mixin
   - mimir
   - portefaix
-version: 1.6.0
+version: 1.6.1
 appVersion: 2.9.0
 
 maintainers:
diff --git a/charts/mimir-mixin/README.md b/charts/mimir-mixin/README.md
index 85c62df7..cde143fa 100644
--- a/charts/mimir-mixin/README.md
+++ b/charts/mimir-mixin/README.md
@@ -1,6 +1,6 @@
 # mimir-mixin
 
-![Version: 1.4.0](https://img.shields.io/badge/Version-1.4.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.0.0](https://img.shields.io/badge/AppVersion-2.0.0-informational?style=flat-square)
+![Version: 1.6.0](https://img.shields.io/badge/Version-1.6.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.9.0](https://img.shields.io/badge/AppVersion-2.9.0-informational?style=flat-square)
 
 A Helm chart for Grafana Mimir mixin
 
@@ -8,24 +8,25 @@ A Helm chart for Grafana Mimir mixin
 
 ## Maintainers
 
-| Name       | Email                         | Url |
-| ---------- | ----------------------------- | --- |
-| nlamirault | <nicolas.lamirault@gmail.com> |     |
+| Name | Email | Url |
+| ---- | ------ | --- |
+| nlamirault | <nicolas.lamirault@gmail.com> |  |
 
 ## Source Code
 
-- <https://github.com/nlamirault/portefaix-hub/tree/master/charts/kubernetes-mixin>
+* <https://github.com/nlamirault/portefaix-hub/tree/master/charts/kubernetes-mixin>
 
 ## Values
 
-| Key                      | Type   | Default        | Description                                                              |
-| ------------------------ | ------ | -------------- | ------------------------------------------------------------------------ |
-| additionalAnnotations    | object | `{}`           | Additional annotations to add to all resources                           |
-| additionalLabels         | object | `{}`           | Additional labels to add to all resources                                |
-| fullnameOverride         | string | `""`           | Provide a name to substitute for the full names of resources             |
-| grafana.folder           | string | `"monitoring"` |                                                                          |
-| monitor.additionalLabels | object | `{}`           | Additional labels to add to resources managed by the Prometheus Operator |
-
----
-
-Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)
+| Key | Type | Default | Description |
+|-----|------|---------|-------------|
+| additionalAnnotations | object | `{}` | Additional annotations to add to all resources |
+| additionalLabels | object | `{}` | Additional labels to add to all resources |
+| alerts.additionalLabels | object | `{}` | Additional labels to add to alert resources managed by the Prometheus Operator |
+| fullnameOverride | string | `""` | Provide a name to substitute for the full names of resources |
+| grafana.folder | string | `"monitoring"` |  |
+| monitor.additionalLabels | object | `{}` | Additional labels to add to resources managed by the Prometheus Operator |
+| recordings.additionalLabels | object | `{}` | Additional labels to add to recording rule resources managed by the Prometheus Operator |
+
+----------------------------------------------
+Autogenerated from chart metadata using [helm-docs v1.10.0](https://github.com/norwoodj/helm-docs/releases/v1.10.0)
diff --git a/charts/mimir-mixin/templates/alerts.yaml b/charts/mimir-mixin/templates/alerts.yaml
index ff63e808..97f8e803 100644
--- a/charts/mimir-mixin/templates/alerts.yaml
+++ b/charts/mimir-mixin/templates/alerts.yaml
@@ -11,6 +11,9 @@ metadata:
     {{- if .Values.monitor.additionalLabels }}
     {{- toYaml .Values.monitor.additionalLabels | nindent 4 }}
     {{- end }}
+    {{- if .Values.alerts.additionalLabels }}
+    {{- toYaml .Values.alerts.additionalLabels | nindent 4 }}
+    {{- end }}
 spec:
   groups:
       - name: mimir_alerts
diff --git a/charts/mimir-mixin/templates/rules.yaml b/charts/mimir-mixin/templates/rules.yaml
index b9aff928..a3982380 100644
--- a/charts/mimir-mixin/templates/rules.yaml
+++ b/charts/mimir-mixin/templates/rules.yaml
@@ -11,6 +11,9 @@ metadata:
     {{- if .Values.monitor.additionalLabels }}
     {{- toYaml .Values.monitor.additionalLabels | nindent 4 }}
     {{- end }}
+    {{- if .Values.recordings.additionalLabels }}
+    {{- toYaml .Values.recordings.additionalLabels | nindent 4 }}
+    {{- end }}
 spec:
   groups:
       - name: mimir_api_1
diff --git a/charts/mimir-mixin/values.yaml b/charts/mimir-mixin/values.yaml
index ae87ec64..26796791 100644
--- a/charts/mimir-mixin/values.yaml
+++ b/charts/mimir-mixin/values.yaml
@@ -34,6 +34,16 @@ monitor:
   additionalLabels: {}
     # release: kube-prometheus-stack
 
+alerts:
+  # -- Additional labels to add to alert resources managed by the Prometheus Operator
+  additionalLabels: {}
+    # release: kube-prometheus-stack
+
+recordings:
+  # -- Additional labels to add to recording rule resources managed by the Prometheus Operator
+  additionalLabels: {}
+    # release: kube-prometheus-stack
+
 grafana:
   # Grafana folder in which to store the dashboards
   folder: monitoring