从 Grafana 使用 Prometheus 时有时会出现 405

Sometimes getting 405 when using Prometheus from Grafana

我正在使用来自 Grafana 的 Prometheus 数据源,在查看图表或插入新图表时,有时会收到 200 OK,有时会收到 405 Method not allowed。

很奇怪,它有时只出现,对于随机图,有时只出现在单个仪表板中的某些图。

数据源设置为通过后端代理请求。

Grafana 和 Prometheus 在 Kubernetes 中都是 运行 作为 Google 云中的 StatefulSet。

我正在 localhost:3000 通过 SSH 隧道访问 Kubernetes 中的 pod 的 Grafana,而 Grafana 正在 http://prometheus:9090/.

访问 Prometheus

我已经尝试在数据源设置中将 method 从 GET 更改为 POST,但随后我在每次请求时都收到 405。

http://localhost:3000/api/datasources/proxy/1/api/v1/query_range?query=kafka_topic_highwater{topic="test"}&start=1541499015&end=1541499930&step=15 请求中的原始 headers 是

Host: localhost:3000
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:63.0) Gecko/20100101 Firefox/63.0
Accept: application/json, text/plain, */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://localhost:3000/d/tDB6XEaiz/kafka-realtime-timeseries?orgId=1
X-Grafana-Org-Id: 1
DNT: 1
Connection: keep-alive
Cookie: grafana_user=admin; grafana_remember=asdf8a620; grafana_sess=<secret>

响应是:

HTTP/1.1 405 Method Not Allowed
Cache-Control: no-cache
Content-Length: 19
Content-Type: text/plain; charset=utf-8
Date: Tue, 06 Nov 2018 10:25:22 GMT
Expires: -1
Pragma: no-cache
X-Content-Type-Options: nosniff

知道是什么原因造成的吗?

问题是我在同一个集群中有两个 Prometheus 实例 运行,具有相同的服务名称,因此请求分布在它们之间......其中一个回复了 405,因为它已设置最多将指标直接转发到 StackDriver..