I have a PostgreSQL cluster I am going to monitor with Grafana 7.2.0 and Prometheus. In particular, I want to show on three SingleStat (one for node) of the same dashboard who is the master, replica-sync, and replica-potential.
I have the following metrics to understand who is master and replica (notice the field role).
patroni_patroni_info{group="testdb",instance="host0:9547",job="db-test",name="my-node-0",role="master",scope="main",state="running",version="2000.0.1"} 1
patroni_patroni_info{group="testdb",instance="host1:9547",job="db-test",name="my-node-1",role="replica",scope="main",state="running",version="2000.0.1"} 1
patroni_patroni_info{group="testdb",instance="host2:9547",job="db-test",name="my-node-2",role="replica",scope="main",state="running",version="2000.0.1"} 1
the problem is that information about who is the replica sync is in another prometheus metrics (notice the field sync_state):
patroni_replication_info{application_name="patroni1", client_addr="10.0.0.1", group="testdb", instance="host0:9547",job="db-test",name="cfdb-node-0",state="streaming",sync_priority="1",sync_state="potential",usename="backup_user"} 1
patroni_replication_info{application_name="patroni2", client_addr="192.10.9.1", group="testdb",instance="host0:9547", job="db-test",name="cfdb-node-0",state="streaming",sync_priority="1",sync_state="sync",usename="backup_user"}
As you can notice node0 is the master, node1 is replica-potential, and node2 is replica-sync. My problem is that I do not know how to combine these metrics in Grafana SingleStat in order to show:
- Master
- Replica-Sync
- Replica-Async
SingleStat in Grafana 7.2.0 uses Transformation to combine queries but it seems they don't fit my needs. Moreover, it is impossible to make join because there are no common fields. Can someone help me with this?