stable/prometheus-operator - adding persistent grafana dashboards

8/2/2019

I am trying to add a new dashboard to the below helm chart

https://github.com/helm/charts/tree/master/stable/prometheus-operator

The documentation is not very clear.

I have added a config map to the name space like the below -

apiVersion: v1
kind: ConfigMap
metadata:
  name: sample-grafana-dashboard
  namespace: monitoring
  labels:
     grafana_dashboard: "1"
data:
  etcd-dashboard.json: |-
{JSON}

According to the documentation, this should just be "picked" up and added, but its not. https://github.com/helm/charts/tree/master/stable/grafana#configuration

The sidecar option in my values.yaml looks like -

grafana:
  enabled: true

  ## Deploy default dashboards.
  ##
  defaultDashboardsEnabled: true

  adminPassword: password

  ingress:
    ## If true, Grafana Ingress will be created
    ##
    enabled: false

    ## Annotations for Grafana Ingress
    ##
    annotations: {}
      # kubernetes.io/ingress.class: nginx
      # kubernetes.io/tls-acme: "true"

    ## Labels to be added to the Ingress
    ##
    labels: {}

    ## Hostnames.
    ## Must be provided if Ingress is enable.
    ##
    # hosts:
    #   - grafana.domain.com
    hosts: []

    ## Path for grafana ingress
    path: /

    ## TLS configuration for grafana Ingress
    ## Secret must be manually created in the namespace
    ##
    tls: []
    # - secretName: grafana-general-tls
    #   hosts:
    #   - grafana.example.com
  #dashboardsConfigMaps:
    #sidecarProvider: sample-grafana-dashboard
  sidecar:
    dashboards:
      enabled: true
      label: grafana_dashboard

I have also tried adding this to the value.yml

dashboardsConfigMaps:
   - sample-grafana-dashboard

Which, doesn't work.

Does anyone have any experience with adding your own dashboards to this helm chart as I really am at my wits end.

-- TheOne745665
grafana
kubernetes-helm

2 Answers

8/6/2019

To sum up: For sidecar you need only one option set to true - grafana.sidecar.dashboards.enabled

  1. Install prometheus-operator witch sidecard enabled:

helm install stable/prometheus-operator --name prometheus-operator --set grafana.sidecar.dashboards.enabled=true --namespace monitoring

  1. Add new dashboard, for example MongoDB_Overview:
wget https://raw.githubusercontent.com/percona/grafana-dashboards/master/dashboards/MongoDB_Overview.json
kubectl -n monitoring create cm grafana-mongodb-overview --from-file=MongoDB_Overview.json
  1. Now the tricky part, you have to set a correct label for your configmap, by default grafana.sidecar.dashboards.label is set tografana_dashboard, so:
kubectl -n monitoring label cm grafana-mongodb-overview grafana_dashboard=mongodb-overview

Now you should find your newly added dashboard in grafana, moreover every confimap with label grafana_dashboard will be processed as dashboard.

The dashboard is persisted and safe, stored in configmap.

-- FL3SH
Source: StackOverflow

12/30/2019

If you do not change the settings in the helm chart. The default user/password for grafana is: user: admin password: prom-operator

-- Jingjun Long
Source: StackOverflow