Interview Prep/Monitoring & Observability/Prometheus scraping and targets

EC2 targets are discovered but all scrape the public IP and time out

IntermediateTroubleshootingPrometheus scraping and targets
Answer

Likely causes → Relabeling uses __meta_ec2_public_ip, or the default address is wrong for your network path.

Diagnose → Look at discovered labels on /service-discovery and compare __address__ with __meta_ec2_private_ip.

Fix →

relabel_configs:
  - source_labels: [__meta_ec2_private_ip]
    target_label: __address__
    replacement: '${1}:9100'
  - source_labels: [__meta_ec2_tag_Name]
    target_label: instance

Prevent → Template SD jobs and review relabeling against the SD page before merging.

All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on Prometheus scraping and targets