Prometheus初次使用
1.背景
为了增强新系统的稳定性,需增加监控和预警。
Zabbix vs Prometheus
2.Prometheus试用
# Prometheus collects metrics from targets by scraping metrics HTTP endpoints. Since Prometheus exposes data in the same manner about itself, it can also scrape and monitor its own health.
# (1)编写配置文件
# (2)启动Prometheus 服务,且修改默认端口9090为8072,http://localhost:8072/metrics 或 http://localhost:8072
./prometheus --config.file=prometheus.yml --web.listen-address=0.0.0.0:8072
# (3)表达式
prometheus_target_interval_length_seconds
prometheus_target_interval_length_seconds{quantile="0.99"}
count(prometheus_target_interval_length_seconds)
# (4)启动node_exporter [收集服务器信息]
nohup ./node_exporter --web.listen-address 0.0.0.0:8873
# (5)重新加载配置文件
kill -s SIGHUP [PID]
3.引用
prometheus get start
prometheus端口修改指引
[如何用Prometheus和Grafana实现集群的监控预警?](https://zhuanlan.zhihu.com/p/588254228)
4.问题
# Prometheus relies on accurate time and time drift might cause unexpected query results.
[root@c1 bonc_zj]# ntpdate ntp.aliyun.com
14 Nov 16:53:58 ntpdate[2349]: the NTP socket is in use, exiting
[root@c1 bonc_zj]# service ntpd stop
Redirecting to /bin/systemctl stop ntpd.service
[root@c1 bonc_zj]# ntpdate ntp.aliyun.com
14 Nov 17:05:31 ntpdate[4251]: step time server 203.107.6.88 offset 552.115921 sec
[root@c1 bonc_zj]# date
Tue Nov 14 17:05:33 CST 2023

浙公网安备 33010602011771号