Prometheus reload配置
近期在对Prometheus进行线上环境配置时,领导说最好不要重启,因为会中断数据。
如果不能restart只能找办法进行reload,经过查询发现有以下两种方式可以进行reload配置。
方式一: ExecReload=/bin/kill -HUP $MAINPID
root@grafana:~# cat /etc/systemd/system/prometheus.service;
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/
After=network.target
[Service]
ExecStart=/usr/local/bin/prometheus --web.enable-lifecycle --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/etc/prometheus/data --web.listen-address=0.0.0.0:9090
WorkingDirectory=/etc/prometheus/
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target
重载命令
systemctl reload prometheus
方式二: --web.enable-lifecycle
root@grafana:~# cat /etc/systemd/system/prometheus.service;
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/
After=network.target
[Service]
ExecStart=/usr/local/bin/prometheus --web.enable-lifecycle --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/etc/prometheus/data --web.listen-address=0.0.0.0:9090
WorkingDirectory=/etc/prometheus/
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target
重载命令
curl -X POST http://localhost:9090/-/reload
一个人花在影响自己未来命运的工作选择上的精力,竟比花在购买穿了一年就会扔掉的衣服上的心思要少得多,这是一件多么奇怪的事情,尤其是当他未来的幸福和富足要全部依赖于这份工作时。