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 面板正常出图
相关推荐
**蓝桉**1 天前
prometheus监控nginx
nginx·elasticsearch·prometheus
**蓝桉**2 天前
Grafana Redis 监控面板全解析(小白版)
redis·prometheus
小李的便利店2 天前
k8s集群部署Prometheus和Grafana
kubernetes·grafana·prometheus·监控
**蓝桉**2 天前
一键恢复 Redis 运行与 Grafana 监控(免修改 systemd 配置)
redis·bootstrap·grafana
数据知道3 天前
MongoDB性能监控仪表板:Grafana+Prometheus集成实战
mongodb·grafana·prometheus
**蓝桉**3 天前
Prometheus时间出现误差
linux·运维·prometheus
&不羁之风&3 天前
Grafana 配置实战
grafana
zjjsctcdl4 天前
【prometheus】监控MySQL并实现可视化
数据库·mysql·prometheus
数据知道5 天前
详解MongoDB监控体系:Zabbix/Prometheus集成实战指南
mongodb·zabbix·prometheus