【问题标题】:Context Deadline Exceeded - prometheus超过上下文截止日期 - 普罗米修斯
【发布时间】:2018-09-23 20:19:14
【问题描述】:

我有许多工作的 Prometheus 配置,我在其中通过 HTTP 抓取指标。但我有一份工作需要通过 HTTPS 抓取指标。

当我访问时:

https://ip-address:port/metrics

我可以看到指标。 我在 prometheus.yml 配置中添加的作业是:

- job_name: 'test-jvm-metrics'
    scheme: https
    static_configs:
      - targets: ['ip:port']

当我重新启动 Prometheus 时,我可以在我的目标上看到一条错误消息:

超出上下文期限

我已经读到scrape_timeout 可能是问题所在,但我已将其设置为 50 秒,但仍然是同样的问题。

什么可能导致此问题以及如何解决? 谢谢!

【问题讨论】:

    标签: monitoring prometheus


    【解决方案1】:

    可能默认的 scrape_timeout 值对你来说太短了

    [ scrape_timeout: <duration> | default = 10s ]
    

    为 scrape_timeout 设置更大的值。

    scrape_configs:
      - job_name: 'prometheus'
    
        scrape_interval: 5m
        scrape_timeout: 1m
    

    看这里https://github.com/prometheus/prometheus/issues/1438

    【讨论】:

      【解决方案2】:

      我过去也遇到过同样的问题。就我而言,问题出在证书上,我通过添加来解决它:

       tls_config:
            insecure_skip_verify: true
      

      你可以试试,也许会奏效。

      【讨论】:

      • 这对我不起作用。我试图把 tls_config 标签。然而问题还是一样:(
      • 我的问题正好相反,insecure_skip_verify 导致 redis 插件出现问题。虽然insecure_skip_verify 是一个高级配置而不是tls_config 下的子项。
      【解决方案3】:

      我遇到了类似的问题,所以我尝试延长我的 scrape_timeout 但它没有做任何事情 - 但是使用 promtool 解释了问题

      我有问题的工作是这样的:

      - job_name: 'slow_fella'
        scrape_interval: 10s
        scrape_timeout: 90s
        static_configs:
        - targets: ['192.168.1.152:9100']
          labels:
            alias: sloooow    
      

      像这样检查你的配置:

      /etc/prometheus $ promtool check config prometheus.yml
      

      结果说明问题并指出如何解决:

      Checking prometheus.yml
        FAILED: parsing YAML file prometheus.yml: scrape timeout greater than scrape interval for scrape config with job name "slow_fella"
      

      只需确保您的 scrape_timeout 足够长以适应您所需的 scrape_interval。

      【讨论】:

        【解决方案4】:

        prometheus 服务器无法访问可能是防火墙拒绝规则的抓取端点时,可能会发生这种情况。只需检查在浏览器中使用&lt;url&gt;:9100(这里9100 是正在运行的node_exporter 服务端口)中的url 并检查您是否仍然可以访问?

        【讨论】:

          【解决方案5】:

          由于已达到最大连接数,我遇到了这个问题。我在数据库中增加了 max_connections 参数并释放了一些连接。 然后,Prometheus 能够再次抓取指标。

          【讨论】:

            【解决方案6】:

            就我而言,这是 IPv6 的问题。我已经用 ip6tables 阻止了 IPv6,但它也阻止了 prometheus 流量。正确的 IPv6 设置为我解决了问题

            【讨论】:

            • 你能详细说明一下吗?您是如何检查并修复的?
            【解决方案7】:

            在我的情况下,我不小心在我的 Kubernetes 部署清单上放置了错误的端口,而不是与其关联的服务以及 Prometheus 目标中定义的端口。

            【讨论】:

              【解决方案8】:

              将超时时间增加到 1m 帮助我解决了类似问题

              【讨论】:

                【解决方案9】:

                当我们重新配置 istio-system 命名空间及其 istio-component 时,我们开始面临类似的问题。 我们还通过 prometheus-operator 在启用了 istio-injection 的 monitoring 命名空间中安装了 prometheus

                重新启动监控(已启用 istio-injection)命名空间的 promtheus 组件解决了该问题。

                【讨论】:

                  【解决方案10】:

                  禁用selinux,然后重新启动服务器并再次测试。

                  【讨论】:

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