feat(prometheus): Add shutdown timeout variable (#220)

In order to allow Prometheus more time to shutdown, especially if
`memory-snapshot-on-shutdown` is used, override the default 90s systemd
shutdown timeout. Otherwise systemd will SIGKILL Prometheus.
* Use 10min shutdown timeout by default.

Signed-off-by: SuperQ <superq@gmail.com>
This commit is contained in:
Ben Kochie 2023-09-27 16:30:36 +02:00 committed by GitHub
parent 643d16c8cd
commit 37d7956dc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 0 deletions

View file

@ -226,3 +226,5 @@ prometheus_alert_rules: # noqa yaml[line-length] # noqa line-length
labels:
severity: warning
# yamllint enable rule:line-length
prometheus_stop_timeout: '600s'

View file

@ -150,3 +150,8 @@ argument_specs:
default:
- "prometheus/targets/*.yml"
- "prometheus/targets/*.json"
prometheus_stop_timeout:
description:
- "How long to wait for Prometheus to shutdown. This is passed as a systemd TimeoutStopSec time spec."
type: "str"
default: "600s"

View file

@ -87,3 +87,4 @@ provisioner:
- target_label: __address__
replacement: 127.0.0.1:9115 # Blackbox exporter.
version: 2.25.2
prometheus_stop_timeout: 1min

View file

@ -42,6 +42,8 @@ def test_files(host, files):
"enable-feature=promql-at-modifier"),
("/etc/systemd/system/prometheus.service",
"enable-feature=remote-write-receiver"),
("/etc/systemd/system/prometheus.service",
"TimeoutStopSec=1min"),
])
def test_file_contents(host, file, content):
f = host.file(file)

View file

@ -85,6 +85,7 @@ Environment="HTTP_PROXY={{ http_proxy }}"{% if https_proxy is defined %} "HTTPS_
SyslogIdentifier=prometheus
Restart=always
TimeoutStopSec={{ prometheus_stop_timeout }}
[Install]
WantedBy=multi-user.target