【问题标题】:Prometheus PushGateway inactive instance data clearancePrometheus PushGateway 非活动实例数据清关
【发布时间】:2018-01-11 13:04:35
【问题描述】:

对于已停用(例如,实例在异常情况下关闭)且不使用人工干预的应用,清除 PushGateway 中的陈旧数据的可靠方法是什么?

【问题讨论】:

    标签: prometheus prometheus-pushgateway


    【解决方案1】:

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

    工作名称:sample_job

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

    成功码 - 202

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

    工作名称:sample_job

    InstnaceId = 20148

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

    成功码 - 202


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

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

      • 谢谢!问题是,这是一种解决方法,因为 Prometheus 位于允许的网络之外,无法直接访问我的应用程序。因此,通过应用程序将指标推送到 PushGateway 并且 Prometheus 取消 PushGateway 似乎是目前唯一的方法。
      • 建议在正在抓取的内容旁边直接运行 Prometheus,这样可以避免这个问题。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-20
      • 2022-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多