Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prometheus: grouping metrics by metric names

Tags:

Is there a way to group all metrics of an app by metric names? A portion from a query listing all metrics for an app (i.e. {app="bar"}) :

ch_qos_logback_core_Appender_all_total{affiliation="foo",app="bar", instance="baz-3-dasp",job="kubernetes-service-endpoints",kubernetes_name="bar",kubernetes_namespace="foobarz",kubernetes_node="mypaas-dev-node3.fud.com",updatedBy="janedoe"}   44 ch_qos_logback_core_Appender_debug_total{affiliation="foo",app="bar", instance="baz-3-dasp",job="kubernetes-service-endpoints",kubernetes_name="bar",kubernetes_namespace="foobarz",kubernetes_node="mypaas-dev-node23.fud.com",updatedBy="deppba"} 32 

I have also tried to use wildcard in the metric name, prometheus is complaining about that. Looking at the metrics, I can see that some of them have dynamic names, most probably delivered by dropwizard metrics. What I ultimately want is a list of all available metrics.

like image 656
naimdjon Avatar asked Mar 06 '18 16:03

naimdjon


People also ask

How do you join two metrics Prometheus?

PromQL supports the ability to join two metrics together: You can append a label set from one metric and append it to another at query time. This can be useful in Prometheus rule evaluations, since it lets you generate a new metric for a series by appending labels from another info metric.

How do I add labels to Prometheus metrics?

Unfortunately, it is not possible to change the labels on old metrics in Prometheus. The storage is only updated by new scrapes and then it becomes immutable.

How do you name metrics?

Universal: Metric names are made up of words separated by underscores. Words use only lowercase letters and numbers (7bit ASCII). Metrics names should start with a letter. Any other punctuation or symbols are proscribed as they might have special use in a downstream system.


1 Answers

The following query lists all available metrics:

sum by(__name__)({app="bar"}) 

Where bar is the application name, as you can see in the log entries posted in the question.

like image 75
naimdjon Avatar answered May 20 '23 05:05

naimdjon