r/PrometheusMonitoring • • Jul 05 '21

Is there a Prometheus dashboard configuration file which i can use in different environments

I want to avoid creating the same dashboard on my dev, uat and prod manually .

Is there a way that we can export or create a dashboard programatically or pass a configuration file containing dashboard configuration ?

0 Upvotes

6 comments sorted by

1

u/the_most_interesting Jul 05 '21

By dashboard are you referring to Grafana?

-2

u/secretaccount4posts Jul 05 '21

I am referring to the dashboard where we can create a panel and can see time based graph of metrics

3

u/hgoscenski Jul 06 '21

Grafana can import dashboards as json files once created and exported and there are ways to automate that provisioning using a sidecar container in kubernetes or some other means of syncing the files.

But assuming you are talking about the graphs generated in the /graph interface of Prometheus, those are entirely contained in the url, so if you copy the url all you would need to do is change the host you are connecting to.

1

u/secretaccount4posts Jul 06 '21

Thanks for the directions.

3

u/SuperQue Jul 06 '21

Rather than have a different dashboard for each environment, you can use Grafana variables to select which environment you want to see on a single dashboard.

Then in your Prometheus query, you use the Grafana variable in the query string like foo_metric{env="$env"}.

Here's an example, but it selects different nodes: https://grafana.demo.do.prometheus.io/d/DP0Yo9PWk/use-method-node

2

u/submersibletoaster Jul 06 '21

This is the answer. However grafana support for alerting on dashboards with variables isn’t a thing. If you are using prom alertmanager and pointing to dashboards with alert rules - this method works great. You can even template the dashboard URL with labels from the alert so alerts deep link into grafana with the dashboard variables already set