[metricset prometheus collector] Multiple match query

Dear Metricbeat experts,

I am using metricset prometheus collector and using the following query to scrape data from prometheus. And I found only the last query ('match[]': '{job="jobC"}') take effect.
Can I use multiple query for metricset prometheus collector? If YES, could u please kindly let me know how? If NO, do u have any suggestion for my requirement?

module: prometheus

period: 10s
hosts: ["localhost:9090"]
metrics_path: '/federate'
headers:
accept: "text/plain"
query:
'match[]': '{job="jobA",cluster_arn=".*clusterA"}'
'match[]': '{job="jobB",cluster_arn=".*clusterB"}'
'match[]': '{job="jobC"}'

Thanks,
Roy

Hey @Roy_Zhang,

it seems that no. A quick workaround would be to define multiple metricset instances like:

module: prometheus
period: 10s
hosts: ["localhost:9090"]
metrics_path: '/federate'
headers:
accept: "text/plain"
query:
'match[]': '{job="jobA",cluster_arn=".*clusterA"}'

module: prometheus
period: 10s
hosts: ["localhost:9090"]
metrics_path: '/federate'
headers:
accept: "text/plain"
query:
'match[]': '{job="jobB",cluster_arn=".*clusterB"}'
...

Your question though is quite interesting and I would try to dive deeper in this, and come back to this thread. Thank you!

Thanks @ChrsMark!

Do u mean starting multiple Metricbeat process? Or define multiple modules in modules.d/prometheus.yml?

For me, I started multiple Metricbeat process and it can work. If I can start only on Metricbeat process, it would be great.

Thanks,
Roy

Hey!

You can start only one Metricbeat and define multiple collector metricsets in modules.d/prometheus.yml as you pointed.

Thanks @ChrsMark! Let me have a try.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.