Add pushgateway to prometheus

This commit is contained in:
IamTheFij 2023-05-09 15:56:20 -07:00
parent 69c8322d50
commit 5169aecc6d
1 changed files with 41 additions and 13 deletions

View File

@ -11,12 +11,17 @@ job "prometheus" {
host_network = "wesher"
to = 9090
}
port "pushgateway" {
host_network = "wesher"
static = 9091
}
}
# ephemeral_disk {
# migrate = true
# sticky = true
# }
ephemeral_disk {
migrate = true
sticky = true
}
service {
name = "prometheus"
@ -30,6 +35,12 @@ job "prometheus" {
]
}
service {
name = "pushgateway"
provider = "nomad"
port = "pushgateway"
}
task "prometheus" {
driver = "docker"
@ -37,18 +48,12 @@ job "prometheus" {
image = "prom/prometheus:v2.43.0"
ports = ["web"]
args = [
"--config.file=/etc/prometheus/config/prometheus.yml",
"--config.file=${NOMAD_TASK_DIR}/prometheus.yml",
"--storage.tsdb.path=${NOMAD_ALLOC_DIR}/data/tsdb",
"--web.listen-address=0.0.0.0:9090",
"--web.console.libraries=/usr/share/prometheus/console_libraries",
"--web.console.templates=/usr/share/prometheus/consoles",
]
mount {
type = "bind"
target = "/etc/prometheus/config"
source = "local/config"
}
}
template {
@ -62,7 +67,13 @@ scrape_configs:
- job_name: prometheus
static_configs:
- targets:
- 0.0.0.0:9090
- 127.0.0.1:9090
- job_name: "pushgateway"
honor_labels: true
static_configs:
- targets:
- 127.0.0.1:9091
- job_name: "nomad_client"
metrics_path: "/v1/metrics"
@ -101,7 +112,7 @@ scrape_configs:
EOF
change_mode = "signal"
change_signal = "SIGHUP"
destination = "local/config/prometheus.yml"
destination = "${NOMAD_TASK_DIR}/prometheus.yml"
}
resources {
@ -109,5 +120,22 @@ scrape_configs:
memory = 300
}
}
task "pushgateway" {
driver = "docker"
config {
image = "prom/pushgateway"
ports = ["pushgateway"]
args = [
"--persistence.file=${NOMAD_ALLOC_DIR}/pushgateway-persistence",
]
}
resources {
cpu = 50
memory = 50
}
}
}
}