I'm running prometheus inside kubernetes cluster.
I need to send queries to Prometheus every minute, to gather information of many metrics from many containers. There are too match queries, so I must combine them.
I know how I can ask Prometheus for one metric information on multiple containers: my_metric{container_name=~"frontend|backend|db"}
, but I haven't found a way to ask Prometheus for multiple metric information in one query.
I'm looking for the equivalent to 'union' in sql queries.
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.
Prometheus uses the tilde character ~ to indicate a query contains a wildcard. Inside the label-query the "dot plus" ( . + ) character combination is used where all characters are accepted.
PromQL, short for Prometheus Querying Language, is the main way to query metrics within Prometheus. You can display an expression's return either as a graph or export it using the HTTP API. PromQL uses three data types: scalars, range vectors, and instant vectors. It also uses strings, but only as literals.
I found here this solution: {__name__=~"metricA|metricB|metricC",container_name=~"frontend|backend|db"}
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With