2

I'm using Pushgateway with Prometheus and everything is OK but after a couple of weeks Pushgateway collapses ... giving it a look there are tons of metrics that are not used anymore and delete them manually is practically impossible ... so ->

There is a way to expire Pushgateway metrics with a TTL or some other retention settings like by size or by time ? ... or maybe both ?

NOTE: I read at the mailing list of Prometheus a lot of people requiring something like this from one year ago or more ... and the only answer so far is -> this is not the Promethean way to do it ... really ? ... common, if this is a real pain for a lot of people maybe there should be a better way (even if it's not the Promethean way)

4

2 回答 2

2

假设您想在组太旧时删除与组相关的指标(对于给定的太旧定义),您拥有push_time_seconds由 pushgateway 自动定义的指标。

push_time_seconds{instance="foo",job="bar",try="longtime"} 1.598280005888635e+09

使用此信息,您可以编写一个脚本来请求/获取此指标并使用该值标识旧的数据组 ( {instance="foo",job="bar",try="longtime"})。该 API 可让您删除与旧数据相关的指标:

 curl -X DELETE http://pushgateway:9091/metrics/job/bar/instance/foo/try/longtime

这可以在几行 bash 脚本或 python 中完成。

于 2020-08-24T14:53:01.730 回答
1

没有得到 Prometheus 团队的正面回应。所以实施相同。

https://github.com/dinumathai/pushgateway

docker pull dmathai/prom-pushgateway-ttl:latest docker run -d -p 9091:9091 dmathai/prom-pushgateway-ttl:latest --metric.timetolive=60s

于 2021-04-07T13:43:43.027 回答