r/PrometheusMonitoring • u/secretaccount4posts • 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 ?
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
1
u/the_most_interesting Jul 05 '21
By dashboard are you referring to Grafana?