【问题标题】:Delete time series metrics Prometheus by certain time period按特定时间段删除时间序列指标 Prometheus
【发布时间】:2020-04-04 07:10:33
【问题描述】:

我在https://www.shellhacks.com/prometheus-delete-time-series-metrics/ 上读到,可以删除我们在 Prometheus 上不需要的时间序列指标。

但是无论如何要在特定时间段内删除它们;说在周一至周五下午 5 点到早上 6 点等期间删除指标?

【问题讨论】:

    标签: prometheus prometheus-node-exporter prometheus-blackbox-exporter


    【解决方案1】:

    来自 TSDB 管理 API 的 Prometheus 官方文档:

    网址查询参数:

    • match[]=:选择要删除的系列的重复标签匹配器参数。至少一个 match[] 参数必须是 提供。
    • start=:开始时间戳。可选,默认为最短时间。
    • end=: 结束时间戳。可选,默认为最大可能时间。

    不提及开始和结束时间将清除所有数据 数据库中匹配的系列。

    参考here

    【讨论】:

      【解决方案2】:

      根据上面的回复,您可以查看文档。你也可以使用这个招摇规范:https://stoic-kare-8f0c7d.netlify.app/#/TSDB%20Admin%20API/deleteSeriesPOST

      生成您的 cURL,否则修改下面提供的示例 cURL:

      http://localhost:9090/api/v1/admin/tsdb/delete_series?match[]={__name__=~".+"}&start=2021-01-01T07:30:00+00:00&end=2021-01-01T22:30:00+00:00
      

      请注意,上面的匹配将删除所有内容,即存储的每个时间序列。 您所追求的可能是一个 cronjob,它运行一个脚本,上面的 cURL 相应地修改了您想要的 match 以及与您的时间段匹配的 start 和 end 日期。

      之后记得运行

      http://localhost:9090/api/v1/admin/tsdb/clean_tombstones
      

      实际删除数据。

      【讨论】:

        猜你喜欢
        • 2020-05-21
        • 2022-11-22
        • 1970-01-01
        • 1970-01-01
        • 2014-03-23
        • 2016-09-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多