How to execute multiple queries in one call in Prometheus

蓝咒 提交于 2020-12-08 05:59:52

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!