问题
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.
回答1:
I found here this solution: {__name__=~"metricA|metricB|metricC",container_name=~"frontend|backend|db"}
.
回答2:
You can use the or
operator, however this does not generalise as it ignores metric names. I'd suggest making multiple queries to the API.
来源:https://stackoverflow.com/questions/47406624/how-to-execute-multiple-queries-in-one-call-in-prometheus