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 面板正常出图
相关推荐
Elastic 中国社区官方博客10 小时前
两个依赖和一个配置块:通过 Prometheus 远程写入将 Spring Boot 指标发送到 Elasticsearch
大数据·数据库·spring boot·elasticsearch·搜索引擎·全文检索·prometheus
User_芊芊君子1 天前
Prometheus接入Pushgateway实战:二进制与Docker部署、指标推送及远程上报
docker·容器·prometheus
lbb 小魔仙7 天前
OpenClaw + cpolar 实战:远程 NAS、分享小游戏、RDP,再配置公网 AI 入口
数据库·人工智能·redis·oracle·prometheus
zhoupenghui1688 天前
Golang pprof 工具详解:监控、压测与调优实战指南
prometheus·pprof
ggaofeng9 天前
prometheus时序数据库
prometheus
DylanlZhao11 天前
我想看看本地 LLM 给我省了多少钱,于是我监控了它
llm·grafana
A心有千千结13 天前
Nginx网关可观测建设:打通流量入口,加速线上故障诊断
nginx·prometheus·devops
天天喝旺仔13 天前
Prometheus + Grafana 监控告警体系搭建实战:从 Exporter 指标采集、PromQL 查询到 Alertmanager 告警落地
容器·kubernetes·grafana·prometheus·时序数据库
川石课堂软件测试17 天前
涨薪技术|Prometheus之HTTP API中使用PromQL
网络协议·测试工具·jmeter·http·单元测试·postman·prometheus
IT界的老黄牛19 天前
Prometheus TSDB 拆不出来、也存不了一年:4 条外部存储出路 + 容量测算
prometheus·时序数据库·监控·thanos·victoriametrics·remote_write