Skip to content

Instantly share code, notes, and snippets.

@anthonydahanne
Created May 26, 2020 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonydahanne/014ab52f69c3e50aad8bff65d4b5ddf0 to your computer and use it in GitHub Desktop.
Save anthonydahanne/014ab52f69c3e50aad8bff65d4b5ddf0 to your computer and use it in GitHub Desktop.
Configure Prometheus for AWS EC2 discovery

I had trouble figuring out how to configure Prometheus EC2 instances discovery once, so I'm sharing this gist that includes some sample config that worked fine for me with Prometheus v2.17.2!

Good luck!

global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
scrape_configs:
- job_name: 'node'
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: '/metrics'
scheme: http
ec2_sd_configs:
- region: eu-west-1
profile: '${INSTANCE_PROFILE_ARN}'
port: 9009
relabel_configs:
- source_labels: [__meta_ec2_tag_Namespace]
regex: '${NAMESPACE}'
action: keep
- source_labels: [__meta_ec2_tag_Environment]
regex: '${ENVIRONMENT}'
action: keep
#Use the instance ID as the instance label
- source_labels: [__meta_ec2_tag_Name]
target_label: instance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment