Skip to content

Commit

Permalink
feat: Add Option to Deploy Grafana Dashboards as ConfigMaps for Sidec…
Browse files Browse the repository at this point in the history
…ar Discovery (#220)

* Add grafana dashboard configmaps for the grafana dashboard sidecar

* make docs...again

* changed grafana installation to sidecar approach

* refactroings
  • Loading branch information
Stephan3555 authored Jan 23, 2025
1 parent 0328d1f commit cf83f1f
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 45 deletions.
2 changes: 1 addition & 1 deletion charts/greptimedb-cluster/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: greptimedb-cluster
description: A Helm chart for deploying GreptimeDB cluster in Kubernetes.
type: application
version: 0.2.45
version: 0.2.46
appVersion: 0.11.2
home: https://github.com/GreptimeTeam/greptimedb
sources:
Expand Down
14 changes: 10 additions & 4 deletions charts/greptimedb-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A Helm chart for deploying GreptimeDB cluster in Kubernetes.

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

## Source Code

Expand Down Expand Up @@ -104,6 +104,13 @@ helm uninstall mycluster -n default
| base.podTemplate.securityContext | object | `{}` | The configurations for pod security context. |
| base.podTemplate.serviceAccountName | string | `""` | The global service account |
| base.podTemplate.tolerations | list | `[]` | The pod tolerations |
| dashboards | object | `{"annotations":{},"enabled":false,"extraLabels":{},"label":"grafana_dashboard","labelValue":"1","namespace":""}` | Deploy grafana dashboards for the grafana dashboard sidecar. https://github.com/grafana/helm-charts/tree/main/charts/grafana#sidecar-for-dashboards |
| dashboards.annotations | object | `{}` | Additional annotation for the configmap |
| dashboards.enabled | bool | `false` | Enable the grafana dashboards sidecar. |
| dashboards.extraLabels | object | `{}` | Extra labels for the configmap |
| dashboards.label | string | `"grafana_dashboard"` | The label as defined in the grafana helmchart. https://github.com/grafana/helm-charts/tree/main/charts/grafana#sidecar-for-dashboards |
| dashboards.labelValue | string | `"1"` | The label value as defined in the grafana helmchart. https://github.com/grafana/helm-charts/tree/main/charts/grafana#sidecar-for-dashboards |
| dashboards.namespace | string | `""` | The namespace in which the grafana dashboard configmaps are installed |
| datanode | object | `{"configData":"","configFile":"","logging":{},"podTemplate":{"affinity":{},"annotations":{},"labels":{},"main":{"args":[],"command":[],"env":[],"image":"","livenessProbe":{},"readinessProbe":{},"resources":{"limits":{},"requests":{}},"securityContext":{},"startupProbe":{},"volumeMounts":[]},"nodeSelector":{},"securityContext":{},"serviceAccount":{"annotations":{},"create":false},"tolerations":[],"volumes":[]},"replicas":1,"storage":{"annotations":{},"dataHome":"/data/greptimedb","labels":{},"mountPath":"/data/greptimedb","storageClassName":null,"storageRetainPolicy":"Retain","storageSize":"10Gi"}}` | Datanode configure |
| datanode.configData | string | `""` | Extra raw toml config data of datanode. Skip if the `configFile` is used. |
| datanode.configFile | string | `""` | Extra toml file of datanode. |
Expand Down Expand Up @@ -198,11 +205,9 @@ helm uninstall mycluster -n default
| frontend.replicas | int | `1` | Frontend replicas |
| frontend.service | object | `{}` | Frontend service |
| frontend.tls | object | `{}` | Frontend tls configure |
| grafana | object | `{"adminPassword":"gt-operator","adminUser":"admin","dashboardProviders":{"dashboardproviders.yaml":{"apiVersion":1,"providers":[{"disableDeletion":false,"editable":true,"name":"greptimedb-cluster-metrics","options":{"path":"/var/lib/grafana/dashboards/greptimedb-cluster-metrics"},"orgId":1,"type":"file"},{"disableDeletion":false,"editable":true,"name":"greptimedb-cluster-logs","options":{"path":"/var/lib/grafana/dashboards/greptimedb-cluster-logs"},"orgId":1,"type":"file"},{"disableDeletion":false,"editable":true,"name":"greptimedb-cluster-slow-queries","options":{"path":"/var/lib/grafana/dashboards/greptimedb-cluster-slow-queries"},"orgId":1,"type":"file"}]}},"dashboardsConfigMaps":{"greptimedb-cluster-logs":"greptimedb-cluster-logs-dashboard","greptimedb-cluster-metrics":"greptimedb-cluster-metrics-dashboard","greptimedb-cluster-slow-queries":"greptimedb-cluster-slow-queries-dashboard"},"datasources":{"datasources.yaml":{"datasources":[{"access":"proxy","isDefault":true,"name":"metrics","type":"prometheus","url":"http://mycluster-monitor-standalone.default.svc.cluster.local:4000/v1/prometheus"},{"access":"proxy","database":"public","name":"logs","type":"mysql","url":"mycluster-monitor-standalone.default.svc.cluster.local:4002"},{"access":"proxy","database":"information_schema","name":"information_schema","type":"mysql","url":"mycluster-frontend.default.svc.cluster.local:4002"}]}},"enabled":false,"image":{"registry":"docker.io","repository":"grafana/grafana","tag":"11.1.3"},"initChownData":{"enabled":false},"persistence":{"accessModes":["ReadWriteOnce"],"enabled":true,"size":"10Gi"},"service":{"annotations":{},"enabled":true,"type":"ClusterIP"}}` | Deploy grafana for monitoring. |
| grafana | object | `{"adminPassword":"gt-operator","adminUser":"admin","datasources":{"datasources.yaml":{"datasources":[{"access":"proxy","isDefault":true,"name":"metrics","type":"prometheus","url":"http://mycluster-monitor-standalone.default.svc.cluster.local:4000/v1/prometheus"},{"access":"proxy","database":"public","name":"logs","type":"mysql","url":"mycluster-monitor-standalone.default.svc.cluster.local:4002"},{"access":"proxy","database":"information_schema","name":"information_schema","type":"mysql","url":"mycluster-frontend.default.svc.cluster.local:4002"}]}},"enabled":false,"image":{"registry":"docker.io","repository":"grafana/grafana","tag":"11.1.3"},"initChownData":{"enabled":false},"persistence":{"accessModes":["ReadWriteOnce"],"enabled":true,"size":"10Gi"},"service":{"annotations":{},"enabled":true,"type":"ClusterIP"},"sidecar":{"dashboards":{"enabled":true,"provider":{"allowUiUpdates":true},"searchNamespace":"ALL"}}}` | Deploy grafana for monitoring. |
| grafana.adminPassword | string | `"gt-operator"` | The default admin password for grafana. |
| grafana.adminUser | string | `"admin"` | The default admin username for grafana. |
| grafana.dashboardProviders | object | `{"dashboardproviders.yaml":{"apiVersion":1,"providers":[{"disableDeletion":false,"editable":true,"name":"greptimedb-cluster-metrics","options":{"path":"/var/lib/grafana/dashboards/greptimedb-cluster-metrics"},"orgId":1,"type":"file"},{"disableDeletion":false,"editable":true,"name":"greptimedb-cluster-logs","options":{"path":"/var/lib/grafana/dashboards/greptimedb-cluster-logs"},"orgId":1,"type":"file"},{"disableDeletion":false,"editable":true,"name":"greptimedb-cluster-slow-queries","options":{"path":"/var/lib/grafana/dashboards/greptimedb-cluster-slow-queries"},"orgId":1,"type":"file"}]}}` | The grafana dashboard providers. |
| grafana.dashboardsConfigMaps | object | `{"greptimedb-cluster-logs":"greptimedb-cluster-logs-dashboard","greptimedb-cluster-metrics":"greptimedb-cluster-metrics-dashboard","greptimedb-cluster-slow-queries":"greptimedb-cluster-slow-queries-dashboard"}` | The grafana dashboards configmaps that will be created to store the dashboards. |
| grafana.datasources | object | `{"datasources.yaml":{"datasources":[{"access":"proxy","isDefault":true,"name":"metrics","type":"prometheus","url":"http://mycluster-monitor-standalone.default.svc.cluster.local:4000/v1/prometheus"},{"access":"proxy","database":"public","name":"logs","type":"mysql","url":"mycluster-monitor-standalone.default.svc.cluster.local:4002"},{"access":"proxy","database":"information_schema","name":"information_schema","type":"mysql","url":"mycluster-frontend.default.svc.cluster.local:4002"}]}}` | The grafana datasources. |
| grafana.enabled | bool | `false` | Enable grafana deployment. It needs to enable monitoring `monitoring.enabled: true` first. |
| grafana.image | object | `{"registry":"docker.io","repository":"grafana/grafana","tag":"11.1.3"}` | The grafana image. |
Expand All @@ -219,6 +224,7 @@ helm uninstall mycluster -n default
| grafana.service.annotations | object | `{}` | The annotations for the grafana service. |
| grafana.service.enabled | bool | `true` | Whether to create the service for grafana. |
| grafana.service.type | string | `"ClusterIP"` | The type of the service. |
| grafana.sidecar | object | `{"dashboards":{"enabled":true,"provider":{"allowUiUpdates":true},"searchNamespace":"ALL"}}` | The grafana sidecar settings to import dashboards |
| grpcServicePort | int | `4001` | GreptimeDB grpc service port |
| httpServicePort | int | `4000` | GreptimeDB http service port |
| image.pullSecrets | list | `[]` | The image pull secrets |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
{{- if .Values.grafana.enabled }}
{{- $root := . -}}
{{- range $key, $value := .Values.grafana.dashboardsConfigMaps }}
{{- if or .Values.grafana.enabled .Values.dashboards.enabled }}
{{ $root := . }}
{{- range $path, $_ := .Files.Glob "dashboards/**.json" }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $value }}
namespace: {{ $root.Release.Namespace }}
labels:
component: grafana-dashboards
{{- if $.Values.dashboards.label }}
{{ $.Values.dashboards.label }}: {{ ternary $.Values.dashboards.labelValue "1" (not (empty $.Values.dashboards.labelValue)) | quote }}
{{- end }}
{{- include "greptimedb-cluster.labels" $root | nindent 4 }}
{{- with $.Values.dashboards.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with $.Values.dashboards.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
name: dashboard-{{ (base $path | replace ".json" "" | trunc 63 | replace "_" "-") }}
namespace: {{ $.Values.dashboards.namespace | default $.Release.Namespace }}
data:
{{ $key }}.json: |-
{{ $root.Files.Get (printf "dashboards/%s.json" $key) | indent 4 }}
---
{{ (base $path | replace ".json" "" | trunc 63 | replace "_" "-" | lower | indent 2) }}.json: |
{{ $root.Files.Get $path | indent 4 }}
{{- end }}
{{- end }}
54 changes: 22 additions & 32 deletions charts/greptimedb-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,21 @@ logging:
# -- Sample ratio of slow query log.
sampleRatio: "1.0"

# -- Deploy grafana dashboards for the grafana dashboard sidecar. https://github.com/grafana/helm-charts/tree/main/charts/grafana#sidecar-for-dashboards
dashboards:
# -- Enable the grafana dashboards sidecar.
enabled: false
# -- The namespace in which the grafana dashboard configmaps are installed
namespace: ""
# -- The label as defined in the grafana helmchart. https://github.com/grafana/helm-charts/tree/main/charts/grafana#sidecar-for-dashboards
label: grafana_dashboard
# -- The label value as defined in the grafana helmchart. https://github.com/grafana/helm-charts/tree/main/charts/grafana#sidecar-for-dashboards
labelValue: "1"
# -- Additional annotation for the configmap
annotations: {}
# -- Extra labels for the configmap
extraLabels: {}

# -- Deploy grafana for monitoring.
grafana:
# -- Enable grafana deployment. It needs to enable monitoring `monitoring.enabled: true` first.
Expand All @@ -963,38 +978,13 @@ grafana:
# -- The grafana image tag.
tag: 11.1.3

# -- The grafana dashboard providers.
dashboardProviders:
dashboardproviders.yaml:
apiVersion: 1
providers:
- name: greptimedb-cluster-metrics
orgId: 1
type: file
disableDeletion: false
editable: true
options:
path: /var/lib/grafana/dashboards/greptimedb-cluster-metrics
- name: greptimedb-cluster-logs
orgId: 1
type: file
disableDeletion: false
editable: true
options:
path: /var/lib/grafana/dashboards/greptimedb-cluster-logs
- name: greptimedb-cluster-slow-queries
orgId: 1
type: file
disableDeletion: false
editable: true
options:
path: /var/lib/grafana/dashboards/greptimedb-cluster-slow-queries

# -- The grafana dashboards configmaps that will be created to store the dashboards.
dashboardsConfigMaps:
greptimedb-cluster-metrics: greptimedb-cluster-metrics-dashboard
greptimedb-cluster-logs: greptimedb-cluster-logs-dashboard
greptimedb-cluster-slow-queries: greptimedb-cluster-slow-queries-dashboard
# -- The grafana sidecar settings to import dashboards
sidecar:
dashboards:
enabled: true
searchNamespace: ALL
provider:
allowUiUpdates: true

# -- The grafana datasources.
datasources:
Expand Down

0 comments on commit cf83f1f

Please sign in to comment.