<p>You can do this similarly to how it's done in <a href="https://github.com/prometheus/blackbox_exporter#prometheus-configuration" rel="nofollow noreferrer">blackbox_exporter</a>: list identifying information of your targets in the <code>target</code> block, and then use relabeling to replace scraping address with address of your actual exporter and to place targets into parameters of scraping request.</p>
<pre class="lang-yaml prettyprint-override"><code>scrape_configs:
  - job_name: 'myjob'
    static_configs:
      - targets:  # Targets to probe using parameters
        - 372c43937e6acd56073246ffdf0e95597480cdba24688cc331d77a8c3c07e1a9   
        - be007691832f4002a86cf0148768a3b039304e9b1fa7ae91a032b0beddc152b2
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_instance
      - source_labels: [__param_instance]
        target_label: instance
      - target_label: __address__
        replacement: example.com  # The exporter's real address
</code></pre>
<p>please notice here: <code>__param_instance</code> is a label that will be used during scraping as URL parameter with name <code>instance</code>.</p>
<p>Here replacement config does:</p>
<ol>
<li>puts ids from target list into parameter <code>instance</code>,</li>
<li>puts content of that parameter into final label <code>instance</code> (otherwise content of <code>__address__</code> will be used),</li>
<li>puts address of actual target into label <code>__address__</code> to be used bu scraping.</li>
</ol>

CC BY-SA 4.0
2023-09-19T15:18:26.360Z
2023-09-19T15:18:26.360Z
markalex
<p>I have an application that has two instances running and each request runs on a different machine.</p>
<p>I am monitoring an event with a counter in my application and each instance runs it's own counter using prometheus-net. It would be great if prometheus-net was using a caching mechanism other that in-memory, maybe a redis, so whenever prometheus scrap /metrics, it gets the same data each time.</p>
<p>Unfortunately, each scrap request from prometheus runs on a different machine and it's like I have two counters.</p>
<p>I need a way to tell to prometheus to scrap two urls and I will find a way to combine them.</p>
<p>Unfortunately, the way to access directly the web app instance is by using parameters.</p>
<p>The urls looks like that:</p>
<pre><code>https://example.com/metrics?instance=dba246887a8c3c07e1a9cc331d7372c43937e6acd56073246ffdf0e95597480c
https://example.com/metrics?instance=be007691832f4002a86cf0148768a3b039304e9b1fa7ae91a032b0beddc152b2
</code></pre>
<p>That way I cannot use the following code since I cannot add full url here.</p>
<pre><code> static_configs:
      - targets: ['example.com']
</code></pre>
<p>I tried the following but it didn't created two 'instances' at the label <code>instance</code></p>
<pre><code>- job_name: 'example'
    scrape_interval: 30s
    params:
      -instance: ['372c43937e6acd56073246ffdf0e95597480cdba24688cc331d77a8c3c07e1a9','be007691832f4002a86cf0148768a3b039304e9b1fa7ae91a032b0beddc152b2']
    static_configs:
      - targets: ['example.com']
    metrics_path: /metrics
    scheme: https
</code></pre>

<prometheus>
Prometheus and Azure WebApps: How to monitor multiple instances with prometheus
Menelaos Vergis
# Prometheus and Azure WebApps: How to monitor multiple instances with prometheus

(Asked by: username_0 on 2023-09-17)

I have an application that has two instances running and each request runs on a different machine.
I am monitoring an event with a counter in my application and each instance runs it's own counter using prometheus-net. It would be great if prometheus-net was using a caching mechanism other that in-memory, maybe a redis, so whenever prometheus scrap /metrics, it gets the same data each time.
Unfortunately, each scrap request from prometheus runs on a different machine and it's like I have two counters.
I need a way to tell to prometheus to scrap two urls and I will find a way to combine them.
Unfortunately, the way to access directly the web app instance is by using parameters.
The urls looks like that:
https://example.com/metrics?instance=dba246887a8c3c07e1a9cc331d7372c43937e6acd56073246ffdf0e95597480c
https://example.com/metrics?instance=be007691832f4002a86cf0148768a3b039304e9b1fa7ae91a032b0beddc152b2

That way I cannot use the following code since I cannot add full url here.
 static_configs:
      - targets: ['example.com']

I tried the following but it didn't created two 'instances' at the label instance
- job_name: 'example'
    scrape_interval: 30s
    params:
      -instance: ['372c43937e6acd56073246ffdf0e95597480cdba24688cc331d77a8c3c07e1a9','be007691832f4002a86cf0148768a3b039304e9b1fa7ae91a032b0beddc152b2']
    static_configs:
      - targets: ['example.com']
    metrics_path: /metrics
    scheme: https

**Tags:** prometheus


---

## 1 answers

### Answer by username_1 on 2023-09-19. Score: 1

You can do this similarly to how it's done in blackbox_exporter: list identifying information of your targets in the target block, and then use relabeling to replace scraping address with address of your actual exporter and to place targets into parameters of scraping request.
scrape_configs:
  - job_name: 'myjob'
    static_configs:
      - targets:  # Targets to probe using parameters
        - 372c43937e6acd56073246ffdf0e95597480cdba24688cc331d77a8c3c07e1a9   
        - be007691832f4002a86cf0148768a3b039304e9b1fa7ae91a032b0beddc152b2
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_instance
      - source_labels: [__param_instance]
        target_label: instance
      - target_label: __address__
        replacement: example.com  # The exporter's real address

please notice here: __param_instance is a label that will be used during scraping as URL parameter with name instance.
Here replacement config does:

puts ids from target list into parameter instance,
puts content of that parameter into final label instance (otherwise content of __address__ will be used),
puts address of actual target into label __address__ to be used bu scraping.


---

