prometheus 配置介绍

prometheus 配置介

prometheus 配置分global、alerting、rule_files、scrape_configs

1、global(全局配置)

scrape_interval:拉取metric值得间隔时间

evaluation_interval:控制rules文件的频率,prometheus使用规则产生新的时间序列数据或者产生警报。

2、alerting(报警定义)

设定alertmanager和prometheus交互的接口,即alertmanager监听的ip地址和端口。

3、rule_files

rule配置,首次读取默认加载,之后根据evaluation_interval设定的周期加载。

4、scrape_configs

配置拉取目录

  • 静态配置样例,增加本机自己的node_exporter监控点,配置后需要重启应用,或者向prometheus进程发送SIGHUP信号

  • 过滤收集指定监控项,下面样例只收集cpu、mem、disk信息

热加载更新配置

热更新加载方法有两种:

  1. kill -HUP pid
  2. curl -X POST http://IP/-/reload

使用上面第二种方式需要启动 Prometheus 的时候,添加 --web.enable-lifecycle 参数

nohup /usr/local/prometheus/bin/prometheus --config.file=/usr/local/prometheus/conf/prometheus.yml --storage.tsdb.path=/usr/local/prometheus/data --web.enable-lifecycle &

配置文件检查方式

./promtool check config /usr/local/prometheus/conf/prometheus.yml 

原文地址:https://www.cnblogs.com/shhnwangjian/p/10589314.html