98 lines
1.9 KiB
HCL
98 lines
1.9 KiB
HCL
job "prometheus" {
|
|
datacenters = ["homelab"]
|
|
type = "service"
|
|
|
|
group "prometheus" {
|
|
count = 1
|
|
|
|
network {
|
|
port "prometheus_ui" {
|
|
static = 9090
|
|
}
|
|
}
|
|
|
|
restart {
|
|
attempts = 2
|
|
interval = "30m"
|
|
delay = "15s"
|
|
mode = "fail"
|
|
}
|
|
|
|
ephemeral_disk {
|
|
size = 300
|
|
}
|
|
|
|
task "prometheus" {
|
|
template {
|
|
change_mode = "noop"
|
|
destination = "local/prometheus.yml"
|
|
|
|
data = <<EOH
|
|
---
|
|
global:
|
|
scrape_interval: 10s
|
|
evaluation_interval: 10s
|
|
|
|
scrape_configs:
|
|
|
|
- job_name: 'nomad_metrics'
|
|
|
|
consul_sd_configs:
|
|
- server: 'consul.service.consul:8500'
|
|
services: ['nomad-client', 'nomad']
|
|
|
|
relabel_configs:
|
|
- source_labels: ['__meta_consul_tags']
|
|
regex: '(.*)http(.*)'
|
|
action: keep
|
|
|
|
scrape_interval: 5s
|
|
metrics_path: /v1/metrics
|
|
params:
|
|
format: ['prometheus']
|
|
- job_name: 'traefik-local'
|
|
consul_sd_configs:
|
|
- server: 'consul.service.consul:8500'
|
|
services: ['traefik-local-admin','traefik-admin']
|
|
|
|
|
|
EOH
|
|
}
|
|
|
|
driver = "docker"
|
|
|
|
config {
|
|
image = "prom/prometheus:latest"
|
|
args = [
|
|
"--config.file=/etc/prometheus/prometheus.yml",
|
|
"--storage.tsdb.path=/prometheus",
|
|
"--storage.tsdb.retention.time=15d",
|
|
]
|
|
volumes = [
|
|
"local/prometheus.yml:/etc/prometheus/prometheus.yml",
|
|
"/mnt/diskstation/nomad/prometheus:/prometheus"
|
|
]
|
|
|
|
ports = ["prometheus_ui"]
|
|
}
|
|
|
|
service {
|
|
name = "prometheus"
|
|
tags = ["urlprefix-/"]
|
|
port = "prometheus_ui"
|
|
|
|
check {
|
|
name = "prometheus_ui port alive"
|
|
type = "http"
|
|
path = "/-/healthy"
|
|
interval = "10s"
|
|
timeout = "2s"
|
|
}
|
|
}
|
|
resources {
|
|
memory = 200
|
|
}
|
|
}
|
|
}
|
|
}
|