# Prometheus collector query defined once, applied everywhere

**URL:** <https://discuss.elastic.co/t/prometheus-collector-query-defined-once-applied-everywhere/327400>\
**Category:** Beats\
**Tags:** beats-module, metricbeat\
**Created:** [March 9, 2023, 10:33pm UTC](https://discuss.elastic.co/t/prometheus-collector-query-defined-once-applied-everywhere/327400 "2023-03-09T22:33:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeanfabrice](https://avatars.discourse-cdn.com/v4/letter/j/f6c823/32.png) [@jeanfabrice](https://discuss.elastic.co/u/jeanfabrice)\
**Post date:** [March 9, 2023, 10:33pm UTC](https://discuss.elastic.co/t/prometheus-collector-query-defined-once-applied-everywhere/327400/1 "2023-03-09T22:33:31Z")

</div>

Hi,

I'm using Metricbeat 8.6.2 and I'm trying to collect Prometheus metrics using the official [Prom snmp exporter](https://github.com/prometheus/snmp_exporter). This particular exporter requires passing a URL query string to configure the snmp endpoint to collect the metrics from.

As an example, this exporter URL: `http//snmpexporter:9116/snmp/?target=192.168.10.14&module=synology` makes the snmp exporter return snmp metrics from IP `192.168.10.14` and the `synology` MIB module.

Here is a sample configuration which collects Prometheus metrics from 2 different exporters:

- the SNMP exporter (see above for details) with 192.168.10.14 configured as the snmp target
- the embedded Canonical MaaS exporter running on host 192.168.10.4

```auto
metricbeat:
  modules:
  - module: prometheus
    period: 30s
    metricsets: ["collector"]
    hosts: ["snmpexporter:9116"]
    metrics_path: /snmp
    query:
      target: 192.168.10.14
      module: synology
  - module: prometheus
    period: 30s
    metricsets: ["collector"]
    hosts: ["192.168.10.4:5240"]
    use_types: true
    rate_counters: false
    metrics_path: /MAAS/metrics

```

The issue is that the `query` parameter which is defined **only** in the first Prometheus module configuration (snmp), is also applied transparently to the second Prometheus configuration (MaaS). See:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/8/48d36b31988634de6fcb9704ef7a45c313c17328.png)

Defining an empty `query` parameter for the second Prometheus configuration does not help much (and would not be a scalable solution when using autodiscover and hints autodiscover)

Any idea what's wrong with my configuration?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 7, 2023, 12:33am UTC](https://discuss.elastic.co/t/prometheus-collector-query-defined-once-applied-everywhere/327400/2 "2023-04-07T00:33:49Z")

</div>

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