I'm using Prometheus and I need to monitor multiple ports, but I couldn't find information about that. Blackbox exporter docs aren't enough because that only pertains to monitoring one port.

I'm using Ubuntu Server.


You can specify the port in the list of targets. Take the official example:

  - job_name: 'blackbox'
    metrics_path: /probe
      module: [http_2xx]  # Look for a HTTP 200 response.
      - targets:
        - http://prometheus.io    # Target to probe with http.
        - https://prometheus.io   # Target to probe with https.
        - http://example.com:8080 # Target to probe with http on port 8080.
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement:  # Blackbox exporter.

You can just specify one target for each port like:

      - targets:
        - http://example.com:1234
        - http://example.com:4567
        - http://example.com:8901

This example uses the http_2xx probe, but same applies to other probe modules too.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.