How to add label to vector

83 views
Skip to first unread message

Shannon Carey

unread,
Sep 24, 2020, 12:55:53 PM9/24/20
to Prometheus Users
I am using "absent_over_time(...) OR vector(0)", so that if everything is OK (metrics are present) I will get a series with a name on it in my graph so that I can still see the series in the resulting visualization, rather than getting none back and having the legend be entirely blank.

However, I can't see a way to add labels to the vector(0). Is there a way?

Thanks!

Brian Candler

unread,
Sep 24, 2020, 4:17:35 PM9/24/20
to Prometheus Users
absent_over_time(...) produces labels in some circumstances, but not in others:

I presume your expression is also one that has no labels, because otherwise the "OR" condition wouldn't work.

Anyway, this seems to work:

label_replace(vector(0), "foo", "bar", "__name__", ".*")

Or maybe a recording rule is cleaner.
Reply all
Reply to author
Forward
0 new messages