How do you name the results of a query?

19 views
Skip to first unread message

Robin Pharaoh

unread,
Apr 9, 2020, 11:55:52 AM4/9/20
to Prometheus Users
If I query:

sum by (status) (some query)

the result is always:

{status="200"}            v1
{status="500"}            v2
...


How do I make the resulting value

200           v1
500           v2
...

This would be super helpful for grafana dashboards where a graph panel is showing a specific value by service name for example.

Brian Candler

unread,
Apr 9, 2020, 12:09:37 PM4/9/20
to Prometheus Users
How to process the results of a prometheus query in grafana is a grafana question.  See:

When you are using dashboard variables set by prometheus queries, you can also use regular expressions to capture values out of the labels.

Robin Pharaoh

unread,
Apr 9, 2020, 12:20:27 PM4/9/20
to Prometheus Users
Thank you for the response. I am looking into the grafana link you sent me, though I do think this is still a prometheus question.

If we are using the prometheus UI, we still see the element / value columns. And I know certain queries will return just a label for the element name, but I can't seem to figure out why they do.

another example is 

sum(max_over_time(http_server_requests_seconds_count{ status="200"}[30m:5m]))

which simply returns

{}          value

Brian Candler

unread,
Apr 9, 2020, 1:29:52 PM4/9/20
to Prometheus Users
Sure: some PromQL functions return no metric name and/or no labels.  That's how those functions operate.

For example, sum(metric) doesn't return any labels, because it's summing together all the timeseries with that particular metric.  Each individual metric, by definition, has a different set of labels.  The sum of those metrics has no identifying labels, since it combines all those metrics.

Matthias Rampke

unread,
Apr 9, 2020, 1:33:44 PM4/9/20
to Robin Pharaoh, Prometheus Users
The Prometheus UI is deliberately not a dashboard. Grafana already does that and much better than we could.

time series identifiers always have a structure like

name{label1="value1",label2="value2"}

with or without a name (both your examples to not have a name); with zero or more label-value pairs (your first example has one, the second example none).

/MR


--
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/527db5d7-54cd-48bb-98ee-a22f97235dc5%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages