Add a static metric to add labels

80 views
Skip to first unread message

Nicolai von Neudeck

unread,
Aug 17, 2018, 8:17:26 AM8/17/18
to Prometheus Users
Hi everyone!

To configure useful alerts I need a reliable source for some labels that don’t change.
So that I can make alerts that show me metrics who *don’t* return timeseries with a certain labelset *anymore*.

Is there a nice way to add a constant metric via config to prometheus to get these labels? It should not be actually scraped but just given to prometheus via config.

E.g. the query:

places

should return:

places{city="Berlin",country="Germany",continent="Europe"} 1
places{city="Capetown",country="South Africa",continent="Africa"} 1
places{city="Cluj-Napoca",country="Romania",continent="Europe"} 1
places{city="Cairo",country="Egypt",continent="Africa"} 1
places{city="Jerusalem",country="Israel",continent="Asia"} 1
places{city="Woodlands",country="Singapore",continent="Asia"} 1
places{city="Quebec",country="Canada",continent="North America"} 1
places{city="La Paz",country="Bolivia",continent="South America"} 1
places{city="Mexico City",country="Mexico",continent="North America"} 1
places{city="Brisbane",country="Australia",continent="Australasia"} 1
places{city="Suva",country="Fiji",continent="Australasia"} 1
places{city="Montevideo",country="Uruguay",continent="South America"} 1

Have a nice weekend!

Nicolai von Neudeck

Ben Kochie

unread,
Aug 17, 2018, 8:29:52 AM8/17/18
to Nicolai von Neudeck, Prometheus Users
Those can be configured as recording rules.

- record: places
  expr: 1
  labels:
    city: Berlin
    country: Germany
    continent: Europe

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/f9a03f7a-f9e1-4d30-b99c-a8c6b81b46e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nicolai von Neudeck

unread,
Aug 17, 2018, 8:51:38 AM8/17/18
to Prometheus Users
Thank you very much Ben,

I have no idea how I could have overlooked that.
I’m sorry to have caused you unnecessary labour.
Have a wonderful weekend!

Nicolai
Reply all
Reply to author
Forward
0 new messages