prometheus启动后修改配置文件就需要再重启生效
可以通过以下方式 热加载
curl -X POST http://localhost:9090/-/reload
请求接口后返回 Lifecycle API is not enabled. 那么就是启动的时候没有开启热更新配置,需要在启动的命令行增加参数: --web.enable-lifecycle
./prometheus --web.enable-lifecycle --config.file=prometheus.yml
如果已经把promtheus配置到了Linux系统服务系统里面,需要到systemd的system文件夹下修改promtheus对应的.service文件。
大概步骤如下:
然后执行命令
systemctl daemon-reload
systemctl restart prometheus
后面每次修改了prometheus配置文件后,可以调用接口进行配置的热加载:
curl -X POST http://ip:9090/-/reload
参考文章:
prometheus热加载配置文件
https://blog.youkuaiyun.com/qq_21133131/article/details/117568214
Prometheus监控学习笔记之Prometheus如何热加载更新配置
https://www.cnblogs.com/momoyan/p/12039895.html