Pushgateway的使⽤

一、Pushgateway 二进制安装(不用 Docker、不用联网)

复制代码
cd /usr/local
wget https://github.com/prometheus/pushgateway/releases/download/v1.5.1/pushgateway-1.5.1.linux-amd64.tar.gz
tar zxvf pushgateway-1.5.1.linux-amd64.tar.gz
mv pushgateway-1.5.1.linux-amd64 pushgateway
cd pushgateway

二、后台启动 Pushgateway(端口 9091)

复制代码
nohup ./pushgateway --web.listen-address=":9091" --persistence.file="pushgateway.data" >/dev/null 2>&1 &

三、验证是否启动成功

复制代码
curl 127.0.0.1:9091/metrics

出现指标 = 成功。


四、把 Pushgateway 加入 prometheus.yml

编辑你找到的配置文件:

复制代码
vi /etc/prometheus/prometheus.yml

scrape_configs 下面添加:

复制代码
- job_name: 'pushgateway'
    static_configs:
      - targets: ['192.168.52.130:9091']
    honor_labels: true

五、重启 Prometheus

复制代码
systemctl restart prometheus

浏览器访问 IP:9091 验证pushgateway⻚⾯即可


六、推送数据示例

示例 1:最简单推送指标

复制代码
echo "test_metric 100" | curl --data-binary @- http://192.168.52.130:9091/metrics/job/test_job

示例 2:带标签推送

复制代码
echo "test_metric{instance=\"server-130\",job=\"push_test\"} 88" | curl --data-binary @- http://192.168.52.130:9091/metrics/job/push_test/instance/server-130

示例 3:删除数据

复制代码
curl -X DELETE http://192.168.52.130:9091/metrics/job/push_test/instance/server-130

七、Grafana 出图(可视化)

  1. 打开 Grafana:http://192.168.52.130:3000
  2. 导入面板:11434(Pushgateway 官方面板)
  3. 数据源选择 Prometheus
  4. 立刻出现:
    • 推送速率
    • 推送时间
    • 任务状态
    • 自定义指标图表

八、完成验证

  1. Prometheus targets 里出现 pushgateway (UP)
  2. 能执行推送 / 删除命令
  3. Grafana 面板正常出图
相关推荐
EterNity_TiMe_18 小时前
别让告警变成噪音:用Prometheus和Alertmanager搭一套可远程查看的监控系统
数据库·人工智能·ai·postgresql·prometheus·cpolar
Elastic 中国社区官方博客20 小时前
使用 Elasticsearch 作为 Grafana 的直接替代 Prometheus 后端
大数据·数据库·sql·elasticsearch·搜索引擎·grafana·prometheus
查拉图斯特拉面条2 天前
使用 k6 编写登录与业务场景脚本并进行性能测试及 Grafana 可视化实战
grafana
spider_xcxc2 天前
Prometheus + Grafana流程搭建总结
grafana·prometheus·云计算运维
c_zyer2 天前
一站式可观测新选择:OpenObserve 深度对标 ELK / Grafana+Prometheus / Netdata,附Docker一键部署实战
elk·grafana·prometheus·netdata·openobserve
Waay3 天前
面试口述版:个人对 Prometheus 完整理解
运维·学习·云原生·面试·职场和发展·kubernetes·prometheus
qq_349447954 天前
十二、k8s中prometheus配置文件如何热加载
容器·kubernetes·prometheus
孫治AllenSun4 天前
【Prometheus & Grafana】搭建可视化监控平台
grafana·prometheus
维C°4 天前
Grafana 上时间筛选
grafana
chen_ke_hao5 天前
Prometheus + Grafana监控平台-显卡集群监控
grafana·prometheus