grafana
The leading tool for querying and visualizing time series and metrics.
About this chart
Grafana Helm Chart
The leading tool for querying and visualizing time series and metrics.
Source Code
Requirements
Kubernetes: ^1.25.0-0
Installing the Chart
OCI Registry
OCI registries are preferred in Helm as they implement unified storage, distribution, and improved security.
helm install RELEASE-NAME oci://ghcr.io/grafana-community/helm-charts/grafana
HTTP Registry
helm repo add grafana-community https://grafana-community.github.io/helm-charts
helm repo update
helm install RELEASE-NAME grafana-community/grafana
Uninstalling the Chart
To remove all of the Kubernetes objects associated with the Helm chart release:
helm delete RELEASE-NAME
Changelog
See the changelog.
Upgrading
A major chart version change (like v1.2.3 -> v2.0.0) indicates that there is an incompatible breaking change needing manual actions.
To 14.6.0
The default liveness probe calls /healthz instead of /api/health. /api/health returns 503
while the database is unreachable or the apiserver is still starting, so a database outage
failed the liveness probe on every replica and the kubelet restarted them all. /healthz only
checks that the web server is up. The readiness probe still calls /api/health, so a pod that
cannot reach the database still stops receiving traffic.
To keep the previous behavior, set livenessProbe.httpGet.path: /api/health.
To 14.4.0
Pod templates no longer carry helm.sh/chart. The label changed on every chart version
bump, and because it sat inside the pod template it rolled the Grafana pods on upgrade
even when neither the configuration nor the image had changed. It remains on the objects
themselves, so kubectl get deploy -L helm.sh/chart is unaffected.
If you group metrics by pod label (kube_pod_labels joined on label_helm_sh_chart, for
example), those series stop being populated for Grafana pods. Use the object-level label,
or add the value you need through extraLabels.
To 4.0.0 (And 3.12.1)
This version requires Helm >= 2.12.0.
To 5.0.0
You have to add --force to your helm upgrade command as the labels of the chart have changed.
To 6.0.0
This version requires Helm >= 3.1.0.
To 7.0.0
For consistency with other Helm charts, the global.image.registry parameter was renamed
to global.imageRegistry. If you were not previously setting global.image.registry, no action
is required on upgrade. If you were previously setting global.image.registry, you will
need to instead set global.imageRegistry.
To 10.0.0
Static alerting resources now support Helm templating. This means that alerting resources loaded from external files (alerting.*.files) are now processed by the Helm template engine.
If you already use template expressions intended for Alertmanager (for example, {{ $labels.instance }}), these must now be escaped to avoid unintended Helm or Go template evaluation. To escape them, wrap the braces with an extra layer like this:
{{ "{{" }} $labels.instance {{ "}}" }}
This ensures the expressions are preserved for Alertmanager instead of being rendered by Helm.
To 11.0.0
The minimum required Kubernetes version is now 1.25. All references to deprecated APIs have been removed.
To 12.0.0
Grafana 13 is configured by default. Grafana 13 explicit requires an image renderer token, which will be generated by the chart if not provided.
To 13.0.0
The Grafana container now runs with readOnlyRootFilesystem: true and uses the distroless image tag by default.
/tmp is now mounted as an emptyDir volume by default and must be removed from your extraVolumeMounts.
The distroless image does not include Grafana's Docker /run.sh entrypoint. As a result, GF_*__FILE environment variables and the deprecated GF_INSTALL_PLUGINS environment variable are not supported with distroless image tags. The chart fails validation when GF_*__FILE is combined with a distroless tag.
Replace GF_*__FILE variables with Grafana's native file provider. For example, replace:
env:
GF_DATABASE_PASSWORD__FILE: /etc/secrets/database/password
with:
env:
GF_DATABASE_PASSWORD: $__file{/etc/secrets/database/password}
Continue mounting the referenced secret file with extraSecretMounts or extraVolumeMounts. To install plugins, use the chart's plugins value or env.GF_PLUGINS_PREINSTALL_SYNC instead of env.GF_INSTALL_PLUGINS.
If you need to control the version of bundled plugins, like Elasticsearch, set shadowBundledPlugins: true.
set -x is no longer enabled by default when downloading dashboards. Add x to defaultShellOptions to enable command tracing.
To 14.0.0
The chart now ships a values.schema.json, and Helm validates the supplied values against it on install, upgrade, template and lint. Values that used to render despite having the wrong type are now rejected with an error such as at '/replicas': got string, want null or integer. Fix the type in your values before upgrading. Common cases:
- A numeric
image.tag(e.g.11.2). Quote it:tag: "11.2". - A non-string label or annotation value, including
serviceMonitor.labels.release(e.g.release: 1). Quote it. - Quoted numbers or booleans for numeric or boolean settings, e.g.
service.port: "80",autoscaling.maxReplicas: "5",goMemLimit.factor: "0.8"orpersistence.enabled: "true". Remove the quotes (or use--setinstead of--set-string).
Keys that are not declared in values.yaml are still accepted.
extraContainers now also accepts a list of containers in addition to a string.
Configuration
Grafana is primarily configured through grafana.ini. The grafana.ini key in values.yaml maps directly to the Grafana configuration file and supports all settings documented in the official Grafana configuration reference.
The chart ships a values.schema.json. Helm validates the supplied values against it on install, upgrade, template and lint, and fails early when a known value has the wrong type (for example replicas: "two" or a non-string annotation value). Keys that are not declared in values.yaml are still accepted.
Example ingress with path
With grafana 6.3 and above
grafana.ini:
server:
domain: monitoring.example.com
root_url: "%(protocol)s://%(domain)s/grafana"
serve_from_sub_path: true
ingress:
enabled: true
hosts:
- "monitoring.example.com"
path: "/grafana"
Example of extraVolumeMounts and extraVolumes
Configure additional volumes with extraVolumes and volume mounts with extraVolumeMounts.
Example for extraVolumeMounts and corresponding extraVolumes:
extraVolumeMounts:
- name: plugins
mountPath: /var/lib/grafana/plugins
subPath: configs/grafana/plugins
readOnly: false
- name: dashboards
mountPath: /var/lib/grafana/dashboards
readOnly: false
extraVolumes:
- name: plugins
existingClaim: existing-grafana-claim
- name: dashboards
hostPath: /usr/shared/grafana/dashboards
Volumes default to emptyDir. Set to persistentVolumeClaim,
hostPath, csi, or configMap for other types. For a
persistentVolumeClaim, specify an existing claim name with
existingClaim.
Import dashboards
There are a few methods to import dashboards to Grafana. Below are some examples and explanations as to how to use each method:
dashboards:
default:
some-dashboard:
json: |
{
"annotations":
...
# Complete json file here
...
"title": "Some Dashboard",
"uid": "abcd1234",
"version": 1
}
custom-dashboard:
# This is a path to a file inside the dashboards directory inside the chart directory
file: dashboards/custom-dashboard.json
prometheus-stats:
# Ref: https://grafana.com/dashboards/2
# title: My Custom Title # optional; when set for a downloaded dashboard (gnetId or url), overrides the title displayed in Grafana
gnetId: 2
revision: 2
datasource: Prometheus
loki-dashboard-quick-search:
gnetId: 12019
revision: 2
datasource:
- name: DS_PROMETHEUS
value: Prometheus
- name: DS_LOKI
value: Loki
local-dashboard:
url: https://github.com/cloudnative-pg/grafana-dashboards/blob/main/charts/cluster/grafana-dashboard.json
# redirects to:
# https://raw.githubusercontent.com/cloudnative-pg/grafana-dashboards/refs/heads/main/charts/cluster/grafana-dashboard.json
# default: -skf
# -s - silent mode
# -k - allow insecure (eg: non-TLS) connections
# -f - fail fast
# -L - follow HTTP redirects
curlOptions: -Lf
BASE64 dashboards
Dashboards could be stored on a server that does not return JSON directly and instead of it returns a base64 encoded file (e.g. Gerrit) A new parameter has been added to the URL use case so if you specify a b64content value equals to true after the URL entry a base64 decoding is applied before save the file to disk. If this entry is not set or is equals to false not decoding is applied to the file before saving it to disk.
Gerrit use case
Gerrit API for download files has the following schema: https://yourgerritserver/a/{project-name}/branches/{branch-id}/files/{file-id}/content where {project-name} and {file-id} usually has '/' in their values and so they MUST be replaced by %2F so if project-name is user/repository, branch-id is master and file-id is equals to dir1/dir2/dashboard the URL value is https://yourgerritserver/a/user%2Frepo/branches/master/files/dir1%2Fdir2%2Fdashboard/content
Sidecar for dashboards
If the parameter sidecar.dashboards.enabled is set, a sidecar container is deployed in the grafana
pod. This container watches all configmaps (or secrets) in the cluster and filters out the ones with
a label as defined in sidecar.dashboards.label. The files defined in those configmaps are written
to a folder and accessed by grafana. Changes to the configmaps are monitored and the imported
dashboards are deleted/updated.
A recommendation is to use one configmap per dashboard, as a reduction of multiple dashboards inside one configmap is currently not properly mirrored in grafana.
Example dashboard config:
apiVersion: v1
kind: ConfigMap
metadata:
name: sample-grafana-dashboard
labels:
grafana_dashboard: "1"
data:
k8s-dashboard.json: |-
# [...]
Sidecar for datasources
If the parameter sidecar.datasources.enabled is set, an init container is deployed in the grafana
pod. This container lists all secrets (or configmaps, though not recommended) in the cluster and
filters out the ones with a label as defined in sidecar.datasources.label. The files defined in
those secrets are written to a folder and accessed by grafana on startup. Using these YAML files,
the data sources in grafana can be imported.
Should you aim for reloading datasources in Grafana each time the config is changed, set sidecar.datasources.skipReload: false and adjust sidecar.datasources.reloadURL to http://<svc-name>.<namespace>.svc.cluster.local/api/admin/provisioning/datasources/reload.
Secrets are recommended over configmaps for this usecase because datasources usually contain private data like usernames and passwords. Secrets are the more appropriate cluster resource to manage those.
Example values to add a postgres datasource as a kubernetes secret:
apiVersion: v1
kind: Secret
metadata:
name: grafana-datasources
labels:
grafana_datasource: 'true' # default value for: sidecar.datasources.label
stringData:
pg-db.yaml: |-
apiVersion: 1
datasources:
- name: My pg db datasource
type: postgres
url: my-postgresql-db:5432
user: db-readonly-user
secureJsonData:
password: 'SUperSEcretPa$$word'
jsonData:
database: my_datase
sslmode: 'disable' # disable/require/verify-ca/verify-full
maxOpenConns: 0 # Grafana v5.4+
maxIdleConns: 2 # Grafana v5.4+
connMaxLifetime: 14400 # Grafana v5.4+
postgresVersion: 1000 # 903=9.3, 904=9.4, 905=9.5, 906=9.6, 1000=10
timescaledb: false
# <bool> allow users to edit datasources from the UI.
editable: false
Example values to add a datasource adapted from Grafana:
datasources:
datasources.yaml:
apiVersion: 1
datasources:
- # <string, required> name of the datasource. Required
name: Graphite
# <string, required> datasource type. Required
type: graphite
# <string, required> access mode. proxy or direct (Server or Browser in the UI). Required
access: proxy
# <int> org id. will default to orgId 1 if not specified
orgId: 1
# <string> url
url: http://localhost:8080
# <string> database password, if used
password:
# <string> database user, if used
user:
# <string> database name, if used
database:
# <bool> enable/disable basic auth
basicAuth:
# <string> basic auth username
basicAuthUser:
# <string> basic auth password
basicAuthPassword:
# <bool> enable/disable with credentials headers
withCredentials:
# <bool> mark as default datasource. Max one per org
isDefault:
# <map> fields that will be converted to json and stored in json_data
jsonData:
graphiteVersion: "1.1"
tlsAuth: true
tlsA
Deploy grafana with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has grafana on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartgrafana is pinned at v14.6.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply