Export Postgres metrics to Prometheus.

This commit is contained in:
2023-08-15 06:09:38 +01:00
parent e6c6f45e25
commit 8a86983931

View File

@@ -6,6 +6,9 @@ job "postgres" {
port "db" { port "db" {
to = 5432 to = 5432
} }
port "exporter" {
to = 9187
}
} }
task "postgres" { task "postgres" {
@@ -18,7 +21,7 @@ job "postgres" {
} }
env { env {
POSTGRES_PASSWORD = "Faelaishewohlees4nei" POSTGRES_PASSWORD = "${var.pg_password}"
} }
service { service {
@@ -37,5 +40,29 @@ job "postgres" {
memory = 512 memory = 512
} }
} }
task "exporter" {
driver = "docker"
config {
image = "quay.io/prometheuscommunity/postgres-exporter"
ports = ["exporter"]
}
env {
DATA_SOURCE_NAME = "postgresql://postgres:${var.pg_password}@${NOMAD_ADDR_db}/postgres?sslmode=disable"
}
service {
name = "postgres-exporter"
port = "exporter"
tags = ["metrics"]
}
}
} }
} }
variable "pg_password" {
type = string
default = "Faelaishewohlees4nei"
}