using multiple targets with prometheus

57 views
Skip to first unread message

Rayn doll

unread,
Sep 6, 2020, 2:47:00 AM9/6/20
to Prometheus Users
We need to monitor several of target with prometheus, when we have a short list of targets 
it was not a problem to modify, however we need to add many targets (50-70 new targets) from diffrent clusters
My question if there is a more elegant way to achieve this 
instead of using it like this

    - job_name: blackbox-http # To get metrics about the exporter’s targets
      metrics_path: /probe
      params:
        module: [http_2xx]
      static_configs:
        - targets:
          - http://clusterA   
          - https://clusterA   
          - http://clusterB 
          - http://clusterC 
          - http://clusterC 
            ...

maybe to mount additional files for each cluster , I mean to provide a file with targets for clusterA only and new file for clusterB only etc, is it possible ?

Brian Candler

unread,
Sep 6, 2020, 3:31:21 AM9/6/20
to Prometheus Users
Yes, use file_sd_configs instead of static_configs.

    file_sd_configs:
      - files:
        - /etc/prometheus/targets.d/cluster_a.yml
        - /etc/prometheus/targets.d/cluster_b.yml

This has the additional advantage that prometheus automatically detects whenever these files change - you don't need to send it a signal to re-read them.

Rayn doll

unread,
Sep 6, 2020, 7:30:15 AM9/6/20
to Prometheus Users
Thanks a lot! could you please provide some file same, how it looks like? 

ב-יום ראשון, 6 בספטמבר 2020 בשעה 10:31:21 UTC+3, b.ca...@pobox.com כתב/ה:

Brian Candler

unread,
Sep 6, 2020, 11:06:01 AM9/6/20
to Prometheus Users
There is an example (in JSON format) in the section I linked to:

But YAML is also permitted.  In your case it might look like this:
Reply all
Reply to author
Forward
0 new messages