【问题标题】:prometheus eating huge memory普罗米修斯吃掉巨大的内存
【发布时间】:2020-05-06 06:57:48
【问题描述】:

使用 prometheus 操作符部署在 kubernetes 上的 Prometheus 占用了太多内存,目前约为 12G。我看到/prometheus/wal 目录在 ~12G。我已经删除了所有 *.tmp 文件,但这无济于事。 无法找出解决此问题的方法。有什么建议吗??

【问题讨论】:

    标签: kubernetes prometheus-operator wal


    【解决方案1】:

    减少您的保留时间或减少您的时间序列数量。

    【讨论】:

    • 保留期是30天,但是和内存有什么关系呢?
    • 如何减少时间序列的数量?
    【解决方案2】:

    在谷歌上挖掘了几天,我发现有很多未使用的指标我们可以删除样本[1]。
    在普罗米修斯目录中搜索了采样率非常高的度量标准的使用- 查询以查找 prometheus 指标 -

    topk(20, count by (__name__, job)({__name__=~".+"}))
    

    如果您在列表中找到了 tcp 或 udp 指标。尝试在 prometheus 上执行这些指标,如果值为零,那么这些指标可以安全删除,因为这些指标已经在 CAdvisor 级别被禁用,因为它们会产生大量样本。
    bash 命令来检查这些指标在 prometheus 或 grafana 中的任何地方的使用-

    cd <prometheus dir>
    grep -irn <metric_name>
    

    如果没有在任何地方使用,则只需为该特定作业添加删除操作。
    注意-您将在最初执行的 promQL 查询中获得jobname

    我正在使用 prometheus 运算符,因此我必须为此编辑相应的 servicemonitor 定义。如果您以正常方式部署 prometheus,则可能需要编辑 prometheus.yaml 文件。

    metric_relabel_configs:
       - source_labels: [ __name__ ]
         regex: 'metric_name'
         action: drop
    

    参考:-
    [1] https://www.robustperception.io/dropping-metrics-at-scrape-time-with-prometheus

    [2]计算所需RAM的公式-
    https://www.robustperception.io/how-much-ram-does-prometheus-2-x-need-for-cardinality-and-ingestion

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-22
      • 1970-01-01
      • 1970-01-01
      • 2017-09-03
      • 1970-01-01
      • 2022-10-17
      • 2022-12-02
      • 2022-12-17
      相关资源
      最近更新 更多