0

PushGateway对于已停用(例如,实例在异常情况下关闭)的应用程序(例如,实例在异常情况下关闭)而无需手动参与,什么是清除陈旧数据的可靠方法?

4

2 回答 2

1

您可以使用以下网址清除/删除应用程序的指标数据/作业

工作名称:sample_job

curl --location --request DELETE 'http://localhost:9091/metrics/job/sample_job'

成功代码 - 202

如果您正在运行同一个应用程序的多个实例,您也可以删除单个实例的指标,

工作名称:sample_job

实例 ID = 20148

curl --location --request DELETE 'http://localhost:9091/metrics/job/sample_job/instance/20148'

成功代码 - 202


但唯一的问题可能是,如果应用程序在退出时从 pushGateway 中删除自己的指标,prometheus 可能会丢失它。是的,如果应用程序在 prometheus 抓取 pushgateway 之间退出。

于 2020-01-06T08:47:55.203 回答
0

Pushgateway 用于服务级别的批处理作业,这些作业是独立的,是可以关闭的单个服务实例。您可能想要做的是直接使用 Prometheus 抓取此实例,而不是尝试将 Prometheus 转换为 push。

我建议阅读https://prometheus.io/docs/practices/pushing/

于 2018-01-11T13:07:19.580 回答