Does the order of labels matter?

133 views
Skip to first unread message

Andrii Babanin

unread,
Sep 28, 2023, 5:41:20 AM9/28/23
to Prometheus Users
Hi

I'm working on a proprietary metrics framework that exposes the metrics page for Prometheus to scrape from.

I wonder if will it affect the Prometheus server if I change the order of labels. For instance,

In framework v1 I expose metrics with unordered labels:

test_counter{instance="test:80",error="false",app_name="TestApp"}

In framework v2 labels are lexicographically  sorted:

test_counter{app_name="TestApp",error="false",instance="test:80"}


Does the order of metrics important? 
Will Prometheus be able to continue scraping my metric endpoint with no issues?

TIA

Ben Kochie

unread,
Sep 28, 2023, 5:44:26 AM9/28/23
to Andrii Babanin, Prometheus Users
No, the order of labels doesn't matter. Either at ingestion time or at query time.

Note that `instance` is a reserved label name for Prometheus. Prometheus injects the `instance` label for you, the app does not need to know anything about instance or other deployment topology information. This is handled by service discovery.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/98998994-47c5-4004-a4e9-8df2abd6a35dn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages