How to define multiple ports in Prometheus EC2 Service Discovery Config (ec2_sd_config)

Viewed 406

The EC2 SD config accepts the following parameters.

ec2_sd_configs:
  - region: us-west-2
    access_key: OMITTED
    secret_key: OMITTED
    port: 9101

I want to scrape metrics from ports 9101 and 9182. To do this i defined the ec2_sd_config twice and list access and secret keys twice. Is there a way I can add multiple ports from one config?

    ec2_sd_configs:
      - region: us-west-2
        access_key:
        secret_key:
        port: 9101
​
      - region: us-west-2
        access_key:
        secret_key:
        port: 9182
1 Answers

ec2_sd_configs is meant for instance discovery, not process discovery.

For example, running a node or process exporter on each EC2 machine, hosted on a single port, on every instance.

You'll need to use a separate service discovery mechanism such as the http / Consul one to more dynamically gather/discover separate process ports on every instance.

Related