上下文超出期限 - prometheus

问题描述 投票:0回答:11

我有很多工作的 Prometheus 配置,我通过 HTTP 抓取指标。但我有一项工作需要通过 HTTPS 抓取指标。

当我访问时:

https://ip-address:端口/metrics

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

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

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

超出上下文期限

我读过,也许

scrape_timeout
是问题所在,但我已将其设置为 50 秒,但仍然存在同样的问题。

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

monitoring prometheus
11个回答
35
投票

可能默认的 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


10
投票

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

 tls_config:
      insecure_skip_verify: true

你可以尝试一下,也许会有效果。


5
投票

我遇到了类似的问题,所以我尝试扩展我的

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


1
投票

prometheus
服务器无法到达可能被防火墙拒绝的规则的抓取端点时,可能会发生这种情况。只需在浏览器中使用
<url>:9100
(这里
9100
是node_exporter服务运行端口`)检查一下网址,然后检查是否仍然可以访问?


1
投票

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


0
投票

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


0
投票

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


0
投票

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


0
投票

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

重新启动监控(启用istio注入)命名空间的promtheus组件解决了这个问题。


0
投票

在AWS上,对我来说,在SG中打开端口(用于普罗米修斯),有效


0
投票

对我来说,问题是我在 ec2 实例内运行导出器,但忘记允许安全组中侦听端口的 tcp 连接(还要检查子网的路由)。所以普罗米修斯容器无法连接到我的导出器机器的监听端口。

在 prometheus 容器内,您可以运行 wget exporterIp:listenPort,如果它没有返回任何内容/未连接,则可能存在网络问题。

© www.soinside.com 2019 - 2024. All rights reserved.