Add logic to Grafana with promtheus data source

  • What Grafana version and what operating system are you using?
    7.5.2
  • What are you trying to achieve?
    Show databases based on ENV selection, like select PROD and it will show the prod databases that are in a custom variable, using prometheus as data source.
  • How are you trying to achieve it?
    Using custom variables to write down the database names.
  • What happened?
    Can’t find a way or lack the experience to do what I need.
  • What did you expect to happen?
    Still trying to figure out if my approach is correct or is there a better approach.
  • Can you copy/paste the configuration(s) that you are having problems with?
    N/A
  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    Nope
  • Did you follow any online instructions? If so, what is the URL?

first, if you are new to Grafana, upgrade immediately. 7.5.2 is too old.

second, check out this dashboard:
https://play.grafana.org/d/000000029/prometheus-demo-dashboard?orgId=1&refresh=5m

also: Here are the docs on template variables. And here is a list of good examples on play.grafana.org that use template variables. You can inspect each dashboard to see just how the variables are constructed.