PROMQL replace values

614 views
Skip to first unread message

Pablo Marques

unread,
Dec 15, 2023, 10:34:44 AM12/15/23
to Prometheus Users

Has anyone ever done any logic like this, or would have any idea how I can solve this.

I use WriteLatency{DBInstanceIdentifier=~"aurora-mysql.*"} > 0 to filter who is the master of my database.

The result of Query 1 will be: WriteLatency{DBInstanceIdentifier="aurora-mysql-2"} where aurora-mysql-2 is the master database.

To validate the uptime, I use the following query mysql_global_status_uptime{instance=" <HERE>"}.

I need the result of the DBInstanceIdentifier label in Query 1 to be inserted as a value in Query 2 in the instance field. That way, I can have a query in which I check the uptime of the master database only.

Bryan Boreham

unread,
Dec 15, 2023, 11:38:11 AM12/15/23
to Prometheus Users
I think what you are looking for is to do a "join", which in PromQL terms is some binary expression.

You'd need to do a label_replace from "DBInstanceIdentifier" to "instance"

Also you can do `group by` to reduce one of the values to 1 so you can use * as the binary operator.

Bryan

Reply all
Reply to author
Forward
0 new messages