gpt4 book ai didi

prometheus - 如何从 Prometheus v2 中删除时间序列,特别是一系列警报

转载 作者:行者123 更新时间:2023-12-04 17:30:33 31 4
gpt4 key购买 nike

我们正在处理警报,因此需要不时清除我们通过调用 HTTP API 所做的旧警报,以删除存储警报的伪时间序列,例如:

DELETE https://prometheus/api/v1/series?match[]={__name__="ALERTS"}

我们最近将 Prometheus 服务器从 1.8 升级到 2.2.1。

现在调用这个端点给出
{
"status": "error",
"errorType": "internal",
"error": "not implemented"
}

我做了一些研究,并在不同的地方找到了一个解决方案,我将在下面的答案中进行总结,以防它对我的 StackOverflowers 同事有用

最佳答案

首先,在 Prometheus 2 中默认没有启用管理 API。这必须通过使用选项启动服务器来激活

--web.enable-admin-api

v2 中有一个新端点位于
https://prometheus/api/v2/admin/tsdb/delete_series

这需要一个 POST指定搜索条件,例如对于名称为 ALERTS 的时间序列其中警报名称是 MyTestAlert , 发表以下 application/jsondelete_series端点,来自选择的工具(在 Mac 上用 Postman 6 测试)
{
"matchers": [{
"type": "EQ",
"name": "__name__",
"value": "ALERTS"
},
{
"type": "EQ",
"name": "alertname",
"value": "MyTestAlert"
}]
}

为了完整性和释放保存警报的磁盘空间, POST一个空的有效载荷
https://prometheus/api/v2/admin/tsdb/clean_tombstones

答案汇总自:
  • https://prometheus.io/docs/prometheus/latest/querying/api/
  • https://github.com/prometheus/prometheus/issues/3584
  • https://groups.google.com/forum/#!msg/prometheus-users/ToMKsb9fYp8/az6afuX3CgAJ
  • 关于prometheus - 如何从 Prometheus v2 中删除时间序列,特别是一系列警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49859360/

    31 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com