Prometheus的搭建与使用

一、安装Prometheus

官网下载地址:Download | Prometheus

复制代码
解压:tar -zxvf prometheus-2.19.2.linux-amd64.tar.gz

重命名: mv prometheus-2.19.2.linux-amd64 /home/prometheus

进入对应目录: cd /home/prometheus

查看配置文件:cat prometheus.yml

# 前台启动
./prometheus --config.file=prometheus.yml

# 后台启动
nohup ./prometheus --config.file=prometheus.yml > ./prometheus.log 2>&1 &

验证是否成功:http://***.***.***.***:9090/graph

如果查不到数据可以检查下我们的targets是否有报错

二、安装Grafana

官方下载地址:Download Grafana | Grafana Labs

复制代码
下载:wget https://dl.grafana.com/oss/release/grafana-7.0.5-1.x86_64.rpm 

安装:yum install grafana-7.0.5-1.x86_64.rpm

启动:systemctl daemon-reload
systemctl enable grafana-server.service
systemctl start grafana-server.service

验证是否成功:http://***.***.***.***:3000

默认用户名密码都是admin,初次登录会要求修改默认的登录密码

添加数据源

1.点击DATA SOURCES

2.选择Prometheus

3.Dashboards中import "Prometheus 2.0 Stats"

4.Settings界面填写服务器地址

5.切换界面

五、添加监控项

1.linux

下载node_exporter:

wget https://github.com/prometheus/node_exporter/releases/download/v1.0.1/node_exporter-1.0.1.linux-amd64.tar.gz

解压:tar -zxvf node_exporter-1.0.1.linux-amd64.tar.gz

启动: ./node_exporter &

注释:记得查看防火墙9100端口是否开启

这时候会看到如下警告

复制代码
level=info ts=2020-07-09T02:24:55.402Z caller=tls_config.go:170 msg="TLS is disabled and it cannot be enabled on the fly." http2=false

这是因为Node Exporter 自v1.0.0 版本加了TLS验证(这个在后序篇幅讲,此次跳过)

到官网选择一个喜欢的仪表盘:Dashboards | Grafana Labs

查看id

导入仪表盘

在文本框里输入对应id即可导入

相关推荐
曲幽12 小时前
FastAPI服务半夜又挂了?先别急着重启,查查你的数据库连接池“池子”是不是漏了
python·prometheus·fastapi·web·async·sqlalchemy·connection·pool
Dontla2 天前
高基数(High Cardinality)问题介绍(Prometheus、高基数字段、低基数字段)
前端·数据库·prometheus
川石课堂软件测试2 天前
requests接口自动化测试
数据库·python·功能测试·测试工具·单元测试·grafana·prometheus
没有口袋啦3 天前
基于 Prometheus + Grafana 的云原生立体化监控体系构建
grafana·prometheus
Dontla3 天前
Prometheus介绍(开源系统监控与告警工具)(时间序列数据库TSDB、标签化label-based多维分析、Pull模型、PromQL查询语言)
数据库·开源·prometheus
yunson_Liu5 天前
记一次logrotate.service处理过程
prometheus
TechWJ5 天前
Ansible 跨千台机器批量部署,Node Exporter 监控实现 Prometheus 统一采集
ansible·prometheus
却话巴山夜雨时i6 天前
互联网大厂Java面试:从Spring Boot到Kafka的业务场景深度剖析
spring boot·redis·spring cloud·微服务·kafka·prometheus·java面试
洒满阳光的午后7 天前
我做了一个“能理解业务语义”的可观测性 MCP Server:统一接入 Prometheus、OpenObserve 和 SkyWalking
人工智能·ai·prometheus·skywalking·openobserve·mcp
梵得儿SHI7 天前
SpringCloud 实战落地:可观测性建设(SkyWalking + Prometheus + Grafana)从 0 到 1 生产级部署
grafana·prometheus·springcloud·skywalking·微服务可观测性·线上问题排查