当前位置: 首页 > news >正文

云原生监控系统 Prometheus大总结 20250909

本章内容如下:

Prometheus 介绍
Prometheus 部署和配置
Node Exporter 采集数据
Pushgateway 采集数据
PromQL 查询语言
Grafana 图形化展示
Prometheus 标签管理
Prometheus 告警机制
Prometheus 服务发现
各种 Exporter 高级功能
Prometheus 实现容器监控
Prometheus 联邦 Federation
Prometheus 远程存储 VictoriaMetrics
Kubernetes 集成 Prometheus

1.Prometheus 介绍

官方文档:

https://prometheus.io/docs/
https://prometheus.io/docs/introduction/overview/
Prometheus 的主要模块包括:
●prometheus 时序数据存储、监控指标管理
●可视化
Prometheus web UI : 集群状态管理、promQL
Grafana:非常全面的可视化套件
●数据采集
Exporter: 为当前的客户端暴露出符合 Prometheus 规格的数据指标,Exporter 以守护进程的模式运行井开始采集数据,Exporter 本身也是一个http_server 可以对http请求作出响应返回数据 (K/V形式的metrics)
Pushgateway : 拉模式下数据的采集工具
●监控目标 服务发现 :文件方式、dns方式、console方式、k8s方式
●告警: alertmanager
Prometheus 由几个主要的软件组件组成,其职责概述如下:

工作流程

●Prometheus server 定期从配置好的 jobs 或者 exporters 中拉取Pull metrics,或者接收来自
  Pushgateway 发过来的 metrics,或者从其他的 Prometheus server 中拉 metrics
●Prometheus server 在本地存储收集到的 metrics,并运行已定义好的 alert rules,记录新的时间    序列或者向 Alertmanager 推送警报,实现一定程度上的完全冗余功能。
●Alertmanager 根据配置文件,对接收到的警报进行去重分组,根据路由配置,向对应主机发出      告警。
●集成Grafana或其他API作为图形界面,用于可视化收集的数据。


Prometheus 只负责时序型指标数据的采集及存储

2.Prometheus 部署和配置

①ubuntu包安装

apt install prometheus            其他安装略

#访问如下链接可以看到如下显示
http://<prometheus服务器IP>:9090

#浏览器访问prometheus的指标:
http://<prometheus服务器IP>:9090/metrics

Dashboard 菜单说明

我们选择一个监控项"scrape_duration_seconds",然后点击"Execute",查看效果

查看所有的监控项: 10.0.0.203:9090/api/v1/label/__name__/values

API访问

https://prometheus.io/docs/prometheus/latest/management_api/
https://prometheus.io/docs/prometheus/latest/querying/api/

注意:{ip:port} Prometheus所在的IP和端口
●健康检查 GET {ip:port}/-/healthy  该端点始终返回200,应用于检查Prometheus的运行状况。
●准备检查 GET {ip:port}/-/ready    当Prometheus准备服务流量(即响应查询)时,此端点返回200
●加载配置 PUT {ip:port}/-/reload   POST {ip:port}/-/reload
●关闭服务  PUT {ip:port}/-/quit      POST {ip:port}/-/quit

[root@ubuntu2204 ~]#cat /lib/systemd/system/prometheus.service
......
[Service]
ExecStart=/usr/local/prometheus/bin/prometheus --
config.file=/usr/local/prometheus/conf/prometheus.yml --web.enable-lifecycle
......

[root@ubuntu2204 ~]#curl http://prometheus.wang.org:9090/-/healthy
[root@ubuntu2204 ~]#curl http://prometheus.wang.org:9090/-/ready

优化配置
Prometheus 命令支持选项如下:
https://prometheus.io/docs/prometheus/latest/command-line/prometheus/

②Node Exporter 安装

安装 Node Exporter 用于收集各 node 主机节点上的监控指标数据,监听端口为9100
 
github 链接   https://github.com/prometheus/node_exporter
官方下载  https://prometheus.io/download/
在需要监控的所有节点主机上进行安装
[root@node1 ~]#wget -P /usr/local/ 
https://github.com/prometheus/node_exporter/releases/download/v1.2.2/node_exporter-
1.2.2.linux-amd64.tar.gz 
[root@node1 ~]#cd /usr/local
[root@node1 local]#tar xvf node_exporter-1.2.2.linux-amd64.tar.gz 
[root@node1 local]#ln -s node_exporter-1.2.2.linux-amd64 node_exporter
[root@node1 local]#cd node_exporter
[root@node1 node_exporter]#mkdir bin
[root@node1 node_exporter]#mv node_exporter bin/
[root@node1 ~]#useradd -r -s /sbin/nologin prometheus 
[root@node1 ~]#chown -R prometheus:prometheus /usr/local/node_exporter/


文章转载自:

http://gJk8x1HK.jwdys.cn
http://DJIVs9XO.jwdys.cn
http://ulyVHebF.jwdys.cn
http://arkC4rxg.jwdys.cn
http://DMSiDC9j.jwdys.cn
http://dEv0zrnC.jwdys.cn
http://MKJWSaKX.jwdys.cn
http://po1eKvXW.jwdys.cn
http://gyrcATDD.jwdys.cn
http://Y8HzNCIb.jwdys.cn
http://5sUvLblV.jwdys.cn
http://xzWeFQYe.jwdys.cn
http://dm3pbrt6.jwdys.cn
http://y9P0CZbo.jwdys.cn
http://bDRAqTWG.jwdys.cn
http://bcZiuhdE.jwdys.cn
http://6p8YFyge.jwdys.cn
http://yxeT8Qy3.jwdys.cn
http://QIWWAmNn.jwdys.cn
http://m9wxT0Aq.jwdys.cn
http://oaUJvPVL.jwdys.cn
http://bwz98r9Z.jwdys.cn
http://YD6WhmRW.jwdys.cn
http://9GaLPg37.jwdys.cn
http://MgqSQsKz.jwdys.cn
http://V36r5cl1.jwdys.cn
http://MAO7QCWQ.jwdys.cn
http://82tzdqSu.jwdys.cn
http://yGKcT84S.jwdys.cn
http://fCnrcyvf.jwdys.cn
http://www.dtcms.com/a/375222.html

相关文章:

  • Python解释器安装配置教程(Windows)
  • Java爬虫获取京东item_get_app数据的实战指南
  • HashMap(JDK1.7到1.8的过渡)
  • 趣味学RUST基础篇(函数式编程迭代器)
  • 抗ASIC、抗GPU 的密码哈希算法(安全密钥派生)Argon2算法
  • Nginx 实战系列(六)—— Nginx 性能优化与防盗链配置指南
  • 深入解析 Apache Flink Checkpoint 与 Savepoint 原理与最佳实践
  • C#WPF控制USB摄像头参数:曝光、白平衡等高级设置完全指南
  • 第2节-过滤表中的行-IN
  • 2025年渗透测试面试题总结-60(题目+回答)
  • 【GD32】ROM Bootloader、自定义Bootloader区别
  • 业务用例和系统用例
  • Google AI Mode 颠覆传统搜索方式,它是有很大可能的
  • MTC出席SAP大消费峰会:行业深度×全球广度×AI创新,助力韧性增长
  • 彩笔运维勇闯机器学习--决策树
  • 成都金牛区哪里租好办公室?国际数字影像产业园享税收优惠
  • vue3 实现将页面生成 pdf 导出(html2Canvas + jspdf)
  • golang 面试常考题
  • 单例模式(C++)
  • All in AI之二:数学体系的建立
  • 【Python】S1 基础篇 P5 字典模块指南
  • MySQL底层架构设计原理详细介绍
  • 《ServiceMesh落地避坑指南:从智慧园区故障看Envoy配置治理》
  • 【ARMv7-M】复位向量与启动过程
  • SQL面试题及详细答案150道(136-150) --- 性能优化与数据库设计篇
  • CMake Qt程序打包与添加图标详细教程
  • 【MySQL】mysql-connector-cpp使用
  • Oracle RAC认证矩阵:规避风险的关键指南
  • CTF-Web手的百宝箱
  • Django高效查询:values_list实战详解