0

I'm using prometheus and grafana to monitor the neo4j database cluster.I wanted to create a dynamic dashboard based on the DBNAME as a variable. Below is the query I'm using to populate a panel. Here the graph_db is the DBName and only this changes for multiple databases. Is there a way to change the metric name dynamically using variable.

neo4j_graph_db_transaction_last_closed_tx_id_total{job='$job', instance=~"$neo4j_instance"} --> For graph_db neo4j_system_transaction_last_closed_tx_id_total{job='$job', instance=~"$neo4j_instance"} --> For system

dmkvl
  • 732
  • 5
  • 13

1 Answers1

1

I have found the solution in grafana we can subsitute the variables and use like this to solve the problem. I'm using the latest stable version of Grafana and it worked for me.

neo4j_${var}_transaction_last_closed_tx_id_total{job='$job', instance=~"$neo4j_instance"}

  • Is there anyway to change the value of var depending on the value of job. From the above example If the job is neo4j I want var to be igraph_db_transaction, if job is system I want var to be system_transaction – Rrrrr May 21 '20 at 06:19
  • Yes you can create a variable based on other variables. Create a new variable like var=${job}_transaction. It will do the trick. Even I'm using the below statement to create a new variable. query_result(neo4j_${DBNAME}_causal_clustering_core_is_leader{job="$job"} == 1) – Tamilvanan Varatharajan May 23 '20 at 09:27