On Monday, 20 July 2020 14:17:13 UTC+1, Isaac Graf wrote:
>
> It seems non-optimal to have prometheus scrape  4 different ports on 
> thousands of machines.
>

Non-optimal in what way? The total number of metrics is the same.  Are you 
just worried about opening 4 ports in your firewall?

If so, have a look at exporter_exporter. 
<https://github.com/QubitProducts/exporter_exporter>  This is a simple 
reverse proxy which lets you expose one port, and optionally protect it 
with TLS and/or bearer token and/or source address.  You can then bind the 
individual exporters to 127.0.0.1 so they're not accessible from the 
outside world, and prometheus can scrape the same port multiple times with 
different ?module=XXX.

In the simplest configuration you'd still have multiple scrape jobs, 
because you need to set a different params: module: for each one.  However 
you can combine them into one scrape job by using some rewriting.  
Basically you need to set a "module" label on each target, and then copy it 
to the __param_module label.

- targets:
    - foo
    - bar
  labels:
    module: mod1

- targets:
    - foo
    - bar
  labels:
    module: mod2

and:

    relabel_configs:
      - source_labels: [module]
        target_label: __param_module

      # Optional but recommended: 
see https://www.robustperception.io/controlling-the-instance-label
      # This keeps the exporter port number out of your targets file and 
out of the 'instance' label
      - source_labels: [__address__]
        target_label: instance
      - source_labels: [__address__]
        target_label: __address__
        replacement: '$1:9999'

This doesn't affect the number of scrapes though, it's just a question of 
how you organize your prometheus jobs.

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/287e0f2f-5f68-42f1-ae45-bb022c17dd2ao%40googlegroups.com.

Reply via email to