Grafana is perhaps the most popular, powerful visualization software available. It can be used to monitor a Kubernetes cluster, home-assistant, and just about anything else. Using Grafana+Docker can be tricky, though.
This is one of several posts on containerization of common, useful software.
Docker Considerations
There is an excellent Grafana helm chart in the stable repo already, making it exceptionally easy to deploy on Kubernetes. All I can really add is some thoughts about dashboards and persistence…
There are several different ways to ensure that the Grafana dashboards stick around between restarts. The most straightforward is simply to add persistence.enabled: true
to the values.yaml
used when deploying the helm chart. If you have a persistent volume, this will prevent work from being lost (I like using the nfs-client-provisioner for home/local clusters).
However, when running Grafana in several different clusters/environments, it can be nice to pre-populate the dashboards. This can be done in values.yaml by loading directly from gnet:
dashboardProviders:
dashboardproviders.yaml:
apiVersion: 1
providers:
- name: 'gnet'
orgId: 1
folder: 'Grafana Labs'
type: file
disableDeletion: true
updateIntervalSeconds: 15
editable: true
options:
path: /var/lib/grafana/dashboards/gnet
dashboards:
gnet:
kubernetes-prometheus:
gnetId: 315
revision: 1
datasource: Prometheus
Or by downloading json files directly:
dashboardProviders:
dashboardproviders.yaml:
apiVersion: 1
providers:
- name: 'zaneclaes'
orgId: 1
folder: ''
type: file
disableDeletion: true
updateIntervalSeconds: 15
editable: true
options:
path: /var/lib/grafana/dashboards/zaneclaes
dashboards:
zane:
kubernetes:
url: https://raw.githubusercontent.com/zaneclaes/grafana-dashboards/master/kubernetes.json
ingress:
url: https://raw.githubusercontent.com/zaneclaes/grafana-dashboards/master/virtual-hosts.json
Accessing via IFrames
To allow embedding of Grafana within an iframe, bypassing the login so that visitors may see the charts, first the grafana.ini
must be modified in values.yaml
:
grafana.ini:
security:
allow_embedding: true
"auth.anonymous":
enabled: true
Caution: this will allow anyone who can access the server to see the dashboards.
However, it’s useful if you’d like to embed Grafana into a Home-Assistant panel… in which case, you may find this tutorial on Home Assistant Grafana Dashboards useful.
My Deployment Files(s)
admin: existingSecret: grafana-sec userKey: GRAFANA_USERNAME passwordKey: GRAFANA_PASSWORD service: type: NodePort nodePort: 32000 datasources: datasources.yaml: apiVersion: 1 datasources: - name: Prometheus type: prometheus url: http://prometheus-server access: proxy isDefault: true plugins: - grafana-piechart-panel dashboardProviders: dashboardproviders.yaml: apiVersion: 1 providers: - name: 'zaneclaes' orgId: 1 folder: '' type: file disableDeletion: true updateIntervalSeconds: 15 editable: true options: path: /var/lib/grafana/dashboards/zaneclaes - name: 'gnet' orgId: 1 folder: 'Grafana Labs' type: file disableDeletion: true updateIntervalSeconds: 15 editable: true options: path: /var/lib/grafana/dashboards/gnet dashboards: gnet: envoy-service: gnetId: 7250 datasource: Prometheus envoy-global: gnetId: 7253 datasource: Prometheus zaneclaes: kubernetes: url: https://raw.githubusercontent.com/zaneclaes/grafana-dashboards/master/kubernetes.json ingress: url: https://raw.githubusercontent.com/zaneclaes/grafana-dashboards/master/virtual-hosts.json home-assistant: url: https://raw.githubusercontent.com/zaneclaes/grafana-dashboards/master/home-assistant.json