# Metricbeat Promethes merging queries

**URL:** <https://discuss.elastic.co/t/metricbeat-promethes-merging-queries/334704>\
**Category:** Beats\
**Tags:** beats-module, metricbeat\
**Created:** [May 30, 2023, 4:56pm UTC](https://discuss.elastic.co/t/metricbeat-promethes-merging-queries/334704 "2023-05-30T16:56:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![evileric77](https://avatars.discourse-cdn.com/v4/letter/e/ebca7d/32.png) [@evileric77](https://discuss.elastic.co/u/evileric77)\
**Post date:** [May 30, 2023, 4:56pm UTC](https://discuss.elastic.co/t/metricbeat-promethes-merging-queries/334704/1 "2023-05-30T16:56:07Z")

</div>

This has been mentioned before here:

> [@Prometheus collector query defined once, applied everywhere](https://discuss.elastic.co/t/prometheus-collector-query-defined-once-applied-everywhere/327400):
>
> 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 …

But as there is no resolution there I'm posting here and will open an issue on github shortly. With the Prometheus module if you define 2 items that leverage the module, metricbeat (as a result of composing it seems) merges it and causes invalid queries to result. In my case this is scraping a rook-ceph instance and a custom vsphere exporter:

prometheus-rook-ceph.yml

```auto
    # Module: prometheus
    # Docs: https://www.elastic.co/guide/en/beats/metricbeat/8.4/metricbeat-metricset-prometheus-remote_write.html
    - module: prometheus
      metrics_path: /metrics
      period: 30s
      hosts: ["rook-ceph-mgr.rook-ceph:9283"]
      tags: ["prometheus"]
      processors:
      - add_fields:
          target: ''
          fields:
            type: 'ceph-prometheus'
            site: "${SITE}"

```

prometheus-vmware-exporter.yml

```auto
    # /usr/share/metricbeat/modules.d/
    # Module: prometheus
    # Docs: https://www.elastic.co/guide/en/beats/metricbeat/8.4/metricbeat-metricset-prometheus-remote_write.html
    - module: prometheus
      metrics_path: /metrics
      query: 
        vsphere_host: "dev-esxi01.mydomain.net"
      period: 30s
      hosts: ["vmware-exporter:9272"]
      tags: ["prometheus"]
      processors:
      - add_fields:
          target: ''
          fields:
            type: 'vmware-exporter'
            site: "${SITE}"

```

The expected behavior is that metricbeat scrapes each endpoint individually. What actually happens is the configs are errantly merged in some way resulting in errantly querying the bare /metrics endpoint for ceph mgr:  
`http://rook-ceph-mgr.rook-ceph:9283/metrics?vsphere_host=dev-esxi01.mydomain.net`

---

<div class="post-metadata">

**Author:** ![evileric77](https://avatars.discourse-cdn.com/v4/letter/e/ebca7d/32.png) [@evileric77](https://discuss.elastic.co/u/evileric77)\
**Post date:** [May 31, 2023, 2:34pm UTC](https://discuss.elastic.co/t/metricbeat-promethes-merging-queries/334704/2 "2023-05-31T14:34:02Z")

</div>

After looking at the code this seems more related to the use of global vars and pointers in the metricbeat prometheus module itself. I'm reading through the code more but I do believe this is an issue that stems from the way the code in Go is written. [beats/collector.go at main · elastic/beats · GitHub](https://github.com/elastic/beats/blob/main/metricbeat/module/prometheus/collector/collector.go)

---

<div class="post-metadata">

**Author:** ![evileric77](https://avatars.discourse-cdn.com/v4/letter/e/ebca7d/32.png) [@evileric77](https://discuss.elastic.co/u/evileric77)\
**Post date:** [June 5, 2023, 8:59pm UTC](https://discuss.elastic.co/t/metricbeat-promethes-merging-queries/334704/3 "2023-06-05T20:59:19Z")

</div>

I guess this module doesn't get much use since there is 0 traction in here regarding this issue from myself and one other person. Probably solved many times via workaround with multiple metricbeat instances running.

---

<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:** [July 3, 2023, 10:59pm UTC](https://discuss.elastic.co/t/metricbeat-promethes-merging-queries/334704/4 "2023-07-03T22:59:37Z")

</div>

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