Skip to content

Commit

Permalink
fix(prometheus): fix prometheus template to scrape all consul nodes
Browse files Browse the repository at this point in the history
Signed-off-by: Bruce Becker <[email protected]>
  • Loading branch information
Bruce Becker committed Jul 6, 2021
1 parent 83abcb7 commit 6697c45
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions prometheus.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ job "prometheus" {
network {
port "prometheus_ui" {
static = 9090
to = 9090
}
}

Expand All @@ -38,6 +37,25 @@ job "prometheus" {
}
}

template {
change_mode = "noop"
destination = "local/webserver_alert.yml"

data = <<EOH
---
groups:
- name: prometheus_alerts
rules:
- alert: Webserver down
expr: absent(up{job="webserver"})
for: 10s
labels:
severity: critical
annotations:
description: "Our webserver is down."
EOH
}

template {
change_mode = "noop"
destination = "local/prometheus.yml"
Expand All @@ -49,18 +67,20 @@ global:
evaluation_interval: 5s
scrape_configs:
- job_name: 'instance_metrics'
static_configs:
- targets:
{{ range nodes }}
- {{ .Address}}:9100
{{ end }}
- job_name: 'nomad_metrics'
consul_sd_configs:
- server: '{{ env "NOMAD_IP_prometheus_ui" }}:8500'
- server: '{{ env "CONSUL_HTTP_ADDR" }}'
services: ['nomad-client', 'nomad']
relabel_configs:
- source_labels: ['__meta_consul_tags']
regex: '(.*)http(.*)'
action: keep
scrape_interval: 5s
metrics_path: /v1/metrics
params:
Expand Down

0 comments on commit 6697c45

Please sign in to comment.