欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 汽车 > 新车 > promethus基础

promethus基础

2025/4/29 5:37:09 来源:https://blog.csdn.net/mingzirenyichang/article/details/147339160  浏览:    关键词:promethus基础

1.下载prometheus并解压
在这里插入图片描述
主要配置prometheus.yml文件
在scrape_configs配置项下添加配置(hadoop202是主机名):
scrape_configs:

  • job_name: ‘prometheus’
    static_configs:
    • targets: [‘hadoop202:9090’]

添加 PushGateway 监控配置

  • job_name: ‘pushgateway’
    static_configs:
    • targets: [‘hadoop202:9091’]
    •   labels:
      
      instance: pushgateway

添加 Node Exporter 监控配置

  • job_name: ‘node exporter’
    static_configs:
    • targets: [‘hadoop202:9100’, ‘hadoop203:9100’, ‘hadoop204:9100’]
      解压启动node_exporter后,浏览器可访问该地址。
      在这里插入图片描述

设置node_exporter开机自启动并分发给另外的机器
创建service文件node_exporter.service修改执行地址
[atguigu@hadoop202 module] sudo vim /usr/lib/systemd/system/node_exporter.service

[Unit]
Description=node_export
Documentation=https://github.com/prometheus/node_exporter
After=network.target

[Service]
Type=simple
User=atguigu
ExecStart= /opt/module/node_exporter-1.2.2/node_exporter
Restart=on-failure

[Install]
WantedBy=multi-user.target

设为开机自启动(所有机器都执行)
[atguigu@hadoop202 module] sudo systemctl enable node_exporter.service
启动服务(所有机器都执行)
[atguigu@hadoop202 module] sudo systemctl start node_exporter.service
2.后台启动prometheus
nohup ./prometheus --config.file=./prometheus.yml
在这里插入图片描述
启动完成http://192.168.126.5:9090/可以访问
在这里插入图片描述
启动pushgateway—:9091前边记得加空格
nohup ./pushgateway --web.listen-address :9091 > .pushgateway.log 2>&1 &
在这里插入图片描述
启动后状态全部正常
在这里插入图片描述
3.promql简单查询–瞬时向量,也可以通过正则表达式查询
在这里插入图片描述
4.时间向量–5h表示5小时内的
在这里插入图片描述
5时间位移操作–统计前一天的数据(5小时)
在这里插入图片描述
6.聚合操作
sum(prometheus_http_requests_total)
7.正则匹配多个值
prometheus_http_requests_total{code=~“302|400”}
8.启动grafana
在这里插入图片描述
访问grafana
http://192.168.126.5:3000/
默认密码admin

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词