FlxPeters / netbox-plugin-prometheus-sd

Provide Prometheus url_sd compatible API Endpoint with data from Netbox
MIT License
137 stars 28 forks source link

multiple exporters on target #59

Closed cervajs closed 2 years ago

cervajs commented 2 years ago

is it possible to scrape multiple exporters on one target? i.e. node_exporter on port 2000, mariadb_exporter on port 2001

how can i define exporter port?

FlxPeters commented 2 years ago

Sure you can have multiple exporters on a target. Just build two separate jobs in Prometheus where the target is included in both queries.

The plugin only provides all available info from netbox as labels. Ports and relabeling is up to your Prometheus config

FlxPeters commented 2 years ago

Closing for now. Please let me know if you need further assistance.

ryantking commented 5 months ago

Hey @FlxPeters a followup question on this issue to confirm my understanding: if I have two exporters running on a host, which I want scraped by two separate jobs, and use a config context like such:

prometheus-plugin-prometheus-sd:
  - metrics_path: /pve # pve-exporter
    port: 9221
  - port: 9100 # node-exporter

Then a scrape config:

scrape_configs:
  - job_name: node-exporter
    http_sd_configs:
    - url: https://netbox.example.com/api/plugins/prometheus-sd/devices/?role=virt_host
  - job_name: pve-exporter
    http_sd_configs:
    - url: https://netbox.example.com/api/plugins/prometheus-sd/devices/?role=virt_host

As it stands, since both targets are included in the discovery, both scrape configs will scrape both exporters, causing duplication with different job labels.

The way to make this behave the way I would want, each job would have to use relabeling to only keep the metrics that have the correct name, e.g. node_XXX metrics for node-exporter and pve_XXX for pve-exporter?