Skip to content

Latest commit

 

History

History
55 lines (41 loc) · 2.3 KB

File metadata and controls

55 lines (41 loc) · 2.3 KB

Kubernetes controller that watches dashboard configurations defined as configmaps and adds/updates/deletes them to/from grafana

  • Access to the Kubernetes API is expected to be granted by the local kubeconfig file.
  • You can use equality-based labelSelectors to select the configmaps to watch for dashboard descriptions.
  • The controller requires access to the Grafana API, either using an api key or basic auth

Configuration

Configuration can be specified in 2 ways:

  • using command line arguments (use --help to see the complete usage instructions)
  • using environment variables:
Env Variable Description Default Example
CONFIGMAP_SELECTOR optional kube-api compatible labelSelector "" "role=grafana-dashboard,app=awesome-app"
GRAFANA_API_URL required Grafana's api base URL null http://grafana.monitoring.svc.cluster.local/api/
GRAFANA_API_KEY required unless using basic auth Grafana API Key (get one at <YOU-GRAFANA-INSTANCE-URL>/org/apikeys) null "eyJrIjoiWlc4VjZaaFlZbWhwdzFiNVlHbXRn....."
GRAFANA_BASIC_AUTH_USERNAME required if using basic auth Grafana username null "mbenabda"
GRAFANA_BASIC_AUTH_PASSWORD required if using basic auth Grafana plain text password null "1234"

Caveat

Because grafana API uses title-derived slugs to identify dashboards, and in order not to have to manage state for this controller: once a dashboard is managed, its title must not be changed.

To update a managed dashboard's title:

  • delete the corresponding configmap from kubernetes
  • change the title in the configmap's dashboard json desciption
  • apply the configmap manifest

Run on Docker

docker run \
       -v $HOME/.kube/:/root/.kube:ro \
       mbenabda/k8s-grafana-dashboards-controller:0.1.1 \
       --grafana-url http://grafana:3000 \
       --grafana-user johndoe \
       --grafana-password s3cr3t \
       --selector role=grafana-dashboard

Run on Kubernetes

Take a look at the example deployment

Contributing

Contributions are welcome !