Promtheus的时序数据库在存储了大量的数据后,每次重启Prometheus进程的时间会越来越慢。 而在日常运维工作中会经常调整Prometheus的配置信息。
Prometheus提供了在运行时热加载配置信息的功能。
- 查看Prometheus的进程id,发送 SIGHUP 信号
- 发送一个POST请求到 /-/reload ,需要在启动时给定 --web.enable-lifecycle 选项
prometheus支持服务发现(也是运维最佳实践经常采用的):
- file_sd_configs
- azure_sd_configs
- consul_sd_configs
- dns_sd_configs
- ec2_sd_configs
- openstack_sd_configs
- gce_sd_configs
- kubernetes_sd_configs
- marathon_sd_configs
- nerve_sd_configs
- serverset_sd_configs
- triton_sd_configs
参考
Prometheus、Grafana安装-部署-nginx代理-监控linux
详解Prometheus自动发现之file_sd_config
Prometheus 基于文件的服务发现 file_sd_configs
Prometheus之配置详解
Prometheus配置的热加载
操作
基于文件发现
原配置

本文介绍了Prometheus的配置热加载功能,允许在不重启进程的情况下更新配置。内容涉及如何通过发送SIGHUP信号或POST请求实现配置刷新,并展示了基于文件的服务发现(file_sd_configs)配置示例,包括创建子配置文件和更新Prometheus主配置文件的过程。最后,通过热加载重新加载配置并验证监控目标是否生效。
最低0.47元/天 解锁文章
1162





