Skip to content

Commit

Permalink
feat(alloy): Enable Grafana Operator (#738)
Browse files Browse the repository at this point in the history
* feat(alloy): Enable Grafana Operator

Signed-off-by: Nicolas Lamirault <[email protected]>
  • Loading branch information
nlamirault authored May 16, 2024
1 parent 66328d8 commit 04175c2
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 8 deletions.
2 changes: 1 addition & 1 deletion charts/alloy-mixin/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ keywords:
- prometheus
- monitoring-mixin
- portefaix
version: 0.1.0
version: 0.2.0
appVersion: 1.0.0

maintainers:
Expand Down
8 changes: 6 additions & 2 deletions charts/alloy-mixin/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# alloy-mixin

![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.0.0](https://img.shields.io/badge/AppVersion-1.0.0-informational?style=flat-square)
![Version: 0.2.0](https://img.shields.io/badge/Version-0.2.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.0.0](https://img.shields.io/badge/AppVersion-1.0.0-informational?style=flat-square)

A Helm chart for Alloy mixin

Expand All @@ -23,7 +23,11 @@ A Helm chart for Alloy mixin
| 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 | `"opentelemetry"` | Grafana folder in which to store the dashboards |
| grafanaDashboard.enabled | bool | `true` | |
| grafanaDashboard.folder | string | `"opentelemetry"` | Grafana folder in which to store the dashboards |
| grafanaDashboard.grafanaOperator.allowCrossNamespaceImport | bool | `true` | |
| grafanaDashboard.grafanaOperator.enabled | bool | `false` | |
| grafanaDashboard.grafanaOperator.matchLabels | object | `{}` | Selected labels for Grafana instance |
| monitor.additionalLabels | object | `{}` | Additional labels to add to resources managed by the Prometheus Operator |

----------------------------------------------
Expand Down
32 changes: 28 additions & 4 deletions charts/alloy-mixin/templates/configmap-dashboards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
#
# SPDX-License-Identifier: Apache-2.0

---
{{ if .Values.grafanaDashboard.enabled -}}
{{- $files := .Files.Glob "dashboards/*.json" }}
{{- if $files }}
---
apiVersion: v1
kind: ConfigMapList
items:
Expand All @@ -25,15 +26,38 @@ items:
- apiVersion: v1
kind: ConfigMap
metadata:
name: {{ printf "dashboard-%s" $dashboardName | trunc 63 | trimSuffix "-" }}
namespace: {{ include "alloy-mixin.namespace" $ }}
annotations:
grafana-folder: {{ $.Values.grafana.folder }}
grafana-folder: {{ $.Values.grafanaDashboard.folder }}
labels:
grafana-dashboard: {{ $dashboardName }}
{{- include "alloy-mixin.labels" $ | indent 6 }}
name: {{ printf "dashboard-%s" $dashboardName | trunc 63 | trimSuffix "-" }}
namespace: {{ include "alloy-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 "alloy-mixin.labels" $ | indent 4 }}
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 }}
8 changes: 7 additions & 1 deletion charts/alloy-mixin/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ monitor:
additionalLabels: {}
# release: kube-prometheus-stack

grafana:
grafanaDashboard:
enabled: true
# -- Grafana folder in which to store the dashboards
folder: opentelemetry
grafanaOperator:
enabled: false
allowCrossNamespaceImport: true
# -- Selected labels for Grafana instance
matchLabels: {}

0 comments on commit 04175c2

Please sign in to comment.