Skip to content

Instantly share code, notes, and snippets.

@dsouzajude
Created September 3, 2020 11:12
Show Gist options
  • Select an option

  • Save dsouzajude/2dfd727449591d73b2c14ae0f14fa1d1 to your computer and use it in GitHub Desktop.

Select an option

Save dsouzajude/2dfd727449591d73b2c14ae0f14fa1d1 to your computer and use it in GitHub Desktop.
Prometheus Config with Consul SD
global:
scrape_interval: 10s
external_labels:
Environment: sandbox
Region: eu-west-1
Source: prometheus
scrape_configs:
- job_name: consul-services
metrics_path: "/metrics"
consul_sd_configs:
- server: 127.0.0.1:8500
datacenter: eu-west-1
relabel_configs:
# Filter in only proxy services
# The "IsProxy" tag needs to be set for the Envoy Proxy Sidecar containers
- source_labels: [__meta_consul_tags]
regex: .*,IsProxy:yes,.*
action: keep
# Use the Consul's service name as the job name
- source_labels: [__meta_consul_service]
target_label: job
# Replace the service's ports with the proxy's prometheus exposed port
- source_labels: ['__address__']
separator: ':'
regex: '(.*):(.*)'
target_label: '__address__'
replacement: '${1}:9102'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment