首页/云/可观测性速查/Pushgateway 使用要点与清理
Prometheus 与采集64 条

Pushgateway 使用要点与清理

Pushgateway 保存推送的指标供 Prometheus 抓取;分组由 job 加任意标签组成,同分组重复推送会覆盖;任务结束或下线后要主动清理。

可观测性速查云更新于 2026-10-12

推送与清理

推送与清理
# 推送(以 --data-binary 上传 exposition 格式文本)
printf 'batch_duration_seconds 42.5
' | curl --data-binary @- http://127.0.0.1:9091/metrics/job/etl/instance/worker-1

# 删除整个分组
curl -X DELETE http://127.0.0.1:9091/metrics/job/etl/instance/worker-1
Pushgateway 上的数据不会自动过期,也不会主动清理;配套清理脚本是使用它的前提。

易错点

  • 抓取 Pushgateway 的 job 建议设 honor_labels: true,保留推送时的标签
  • 多个实例用相同分组推送会互相覆盖,分组标签要能唯一区分实例

数据来源与参考

  • Pushgateway 项目文档(github.com/prometheus/pushgateway)
​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌