Skip to content

Prometheus Service Discovery using DNS

berzdev edited this page Dec 8, 2024 · 1 revision

If you don't want to add your Proxmox Hostadresses in your Prometheus Configuration you can use DNS based Service Discovery

You only need a FQDN that is pointing to all Proxmox hosts, then Prometheus'll automatically detect your hosts and monitor it. Example output from linux command host pve-cluster-01.yr.tld completed after DNS configuration.

pve-cluster-01.yr.tld has address 192.168.1.5
pve-cluster-01.yr.tld has address 192.168.1.6
pve-cluster-01.yr.tld has address 192.168.1.9

Example Configuration in Prometheus:

    scrape_configs:
      - job_name: 'pve'
        dns_sd_configs:
          - names:
            - 'pve-cluster-01.yr.tld' #dns resolves multiple A records (for each host)
            type: 'A'
            port: 9221 #port is not used, this can be any integer
        metrics_path: /pve
        params:
          module: [default]
        relabel_configs:
          - source_labels: [__address__]
            target_label: __param_target
            replacement: '${1}'  # Remove port
            regex: (.+):\d+  # Regex, to get hostname/ip adress
          - source_labels: [__param_target]
            target_label: instance
          - target_label: __address__
            replacement: 127.0.0.1:9221  # PVE exporter.

Now Prometheus should detect all Proxmox hosts based on a DNS query.