如何重载Prometheus配置
Reloading Prometheus’ Configuration
A common question from new users is if they need to restart Prometheus every time they change the configuration. The good news is that you don’t, allowing your monitoring to continue uninterrupted as your system changes.
There are two ways to ask Prometheus to reload it’s configuration, a SIGHUP
and the POSTing to the /-/reload
handler.
To send a SIGHUP, first determine the process id of Prometheus. This may be in a file such as /var/run/prometheus.pid
, or you can use tools such as pgrep to find it. Then use the kill command to send the signal:
1kill -HUP 1234
Alternatively, you can send a HTTP POST to the Prometheus web server:
1curl -X POST :9090/-/reload
Note that as of Prometheus 2.0, the --web.enable-lifecycle
command line flag must be passed for HTTP reloading to work.
If the reload is successful Prometheus will log that it has updated its targets:
1INFO[0248] Loading configuration file prometheus.yml source=main.go:196
2INFO[0248] Stopping target manager... source=targetmanager.go:203
3INFO[0248] Target manager stopped. source=targetmanager.go:216
4INFO[0248] Starting target manager... source=targetmanager.go:114
If there’s a syntax error the logs will something look like this:
1INFO[0296] Loading configuration file prometheus.yml source=main.go:196
2ERRO[0296] Couldn't load configuration (-config.file=prometheus.yml): yaml: line 1: mapping values are not allowed in this context source=main.go:208
You can use the promtool
command that comes with Prometheus to syntax check your configuration and rules.
捐赠本站(Donate)
如您感觉文章有用,可扫码捐赠本站!(If the article useful, you can scan the QR code to donate))
- Author: shisekong
- Link: https://blog.361way.com/reloading-prometheus-configuration/6801.html
- License: This work is under a 知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议. Kindly fulfill the requirements of the aforementioned License when adapting or creating a derivative of this work.