Build dynamically Grafana datasources in Kubernetes

  • What Grafana version and what operating system are you using?
    9.4.7 (2023-03-16) in Linux on Kubernetes.

  • What are you trying to achieve?
    Build datasources dynamically based on pods/services as an URL and variables for authentication.

  • How are you trying to achieve it?
    Do a research if there as an option to do that in an automatic way.

The question if there is a way to automatically provision datasources for Grafana based on the running pods in a Kubernetes?

  1. We run PostgreSQL instances dynamically in a Kubernetes in a db namespace with a specific set of labels and variables
  2. Grafana run in the same namespace
  3. Grafana sidecar should observe every new pod in this namespace and check for a specific label and variables for authentication
  4. When new pod fit all criterias it should be added to the Grafana list of datasources and removed at pod termination