Cleanup metrics handling

This commit is contained in:
Daniel Berteaud 2024-03-27 13:26:29 +01:00
parent 81b7e1beee
commit 24e9853c98
7 changed files with 26 additions and 19 deletions

View File

@ -11,6 +11,8 @@ job "postgres-manage" {
region = "global"
group "manage" {
network {
mode = "bridge"

View File

@ -6,6 +6,13 @@ job "postgres" {
priority = 80
constraint {
operator = "distinct_hosts"
value = "true"
}
group "server" {
ephemeral_disk {
@ -13,14 +20,6 @@ job "postgres" {
size = 101
}
constraint {
operator = "distinct_hosts"
value = "true"
}
count = "1"
network {
mode = "bridge"
@ -43,8 +42,13 @@ job "postgres" {
name = "postgres"
port = 5432
meta {
alloc = "${NOMAD_ALLOC_INDEX}"
job = "${NOMAD_JOB_NAME}"
alloc = "${NOMAD_ALLOC_INDEX}"
datacenter = "${NOMAD_DC}"
group = "${NOMAD_GROUP_NAME}"
job = "${NOMAD_JOB_NAME}"
namespace = "${NOMAD_NAMESPACE}"
node = "${node.unique.name}"
region = "${NOMAD_REGION}"
}
connect {

View File

@ -5,6 +5,8 @@ job "postgres-upgrade" {
region = "global"
type = "batch"
meta {

View File

@ -11,12 +11,10 @@ job "[[ .instance ]]" {
size = 101
}
[[ template "common/constraints" $c ]]
count = "[[ $c.recovery | ternary 1 $c.count ]]"
network {
mode = "bridge"
[[- if $c.prometheus.enabled ]]
[[- if conv.ToBool $c.prometheus.enabled ]]
port "metrics" {}
port "patroni-metrics" {}
[[- end ]]
@ -92,7 +90,7 @@ job "[[ .instance ]]" {
enable_tag_override = true
}
[[- if $c.prometheus.enabled ]]
[[- if conv.ToBool $c.prometheus.enabled ]]
# This service is just used to expose patroni metrics
service {
name = "[[ .instance ]]-patroni[[ $c.consul.suffix ]]"
@ -321,7 +319,7 @@ _EOT
}
[[- end ]]
[[- if and $c.prometheus.enabled (not .pg.server.recovery) ]]
[[- if and (conv.ToBool $c.prometheus.enabled) (not .pg.server.recovery) ]]
[[ $e := merge .pg.exporter .pg . ]]
[[ template "common/task.metrics_proxy" merge (dict "prometheus" (dict "additional_proxy_conf" (tmpl.Exec "postgres/nginx_patroni.conf.tpl" $e))) $c ]]

View File

@ -63,7 +63,7 @@ pg:
value: true
# In recovery mode, neither patroni nor postgres will be started. The container will start and wait for manual recovery
recovery: False
recovery: false
# Recovery configuration to pass to patroni config
recovery_conf: {}
@ -146,6 +146,7 @@ pg:
- postgres
prometheus:
enabled: '[[ .prometheus.available ]]'
metrics_url: http://localhost:9187
# Backup service uses pgbackrest to perform
@ -158,7 +159,7 @@ pg:
# pgbackrest based backups
pgbackrest:
enabled: False
enabled: false
# Schedules for backups. Empty string to disable
cron:
@ -168,7 +169,7 @@ pg:
# pg_dump based backups
dumps:
enabled: False
enabled: false
format: custom
compression: 6
cron: 39 03 * * *
@ -180,7 +181,7 @@ pg:
memory_max: 256
# Postgres exporter for prometheus
# Only used if prometheus.enabled is True
# Only used if prometheus.enabled is true
exporter:
# Image to use
image: quay.io/prometheuscommunity/postgres-exporter:latest