I have this query that shows replication lag of postgresql streaming replication instances:
SELECT mean("replication_lag") FROM "replication_lag" WHERE ("database" != 'kalihomok') AND time >= now() - 24h and time <= now() GROUP BY time(2m), "database" fill(linear)
I also have an alert setup for this:
When there is absolutely no data, then I get an alert about it. When any value goes above threshold, then I also get an alert.
But I would like to get alerts for [[tag_database]] separately.
This one shows my problem. You can see that there is no data for some of the databases:
I would like to get an alert when there is no data for any of the databases. I could get a separate alert for each missing tag_database, or a single alert. It does not really matter.
But I can’t figure out how to do this.
Note: I can tell the names of the databases in advance, but it would also be possible to write a query that returns all database names. But I just can’t create a separate alert for every database, because there will be a dozen of them, and I really don’t want to maintain configuration changes in tens of alert rules…