Skip to content

Instantly share code, notes, and snippets.

@v0112358
Created February 18, 2022 07:33
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 v0112358/aec2f996126298e46607b0e4a8b439ed to your computer and use it in GitHub Desktop.
Save v0112358/aec2f996126298e46607b0e4a8b439ed to your computer and use it in GitHub Desktop.
Prometheus-Consul-Postgres.yml
global:
scrape_interval: 10s
external_labels:
Environment: sandbox
Region: gcp
Source: prometheus
scrape_configs:
- job_name: consul-services
metrics_path: "/metrics"
consul_sd_configs:
- server: 127.0.0.1:8500
datacenter: gcp
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: .*,postgresql_server,.*
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}:9187'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment