Grafana:数据源(Prometheus)查询403

Grafana: Datasource (Prometheus ) query 403

从 grafana 查询数据源时一些指标得到 403

curl --location --request GET 'https://xxx.xxx.xxx/api/datasources/proxy/1/api/v1/query?query=sum(kube_pod_container_status_restarts_total%7Bnamespace%3D%22default%22%2C%20container%3D~%22al-agent-container%22%2C%20pod%3D%22al-agent-container-hlrz2%22%7D)&time=1607489911' \
> --header 'Accept: application/json' \
> --header 'Content-Type: application/json; charset=UTF-8' \
> --header 'Authorization: Bearer xxx' \
> --data-raw ''
<html>
<head><title>403 Forbidden</title></head>
<body>
<center><h1>403 Forbidden</h1></center>
</body>
</html>

当使用相同的查询从 Prometheus 服务器端点查询时,它解析为 200:

curl --location --request GET 'http://kube-system-prometheus-server.kube-system.svc.cluster.local/api/v1/query_range?query=sum(kube_pod_container_resource_requests_cpu_cores%7Bnamespace%3D%22default%22%2C%20pod%3D~%22al-agent-container-hlrz2%22%7D)&start=1607488035&end=1607489835&step=15' \
> --header 'Accept: application/json' \
> --header 'Content-Type: application/json; charset=UTF-8'
{"status":"success","data":{"resultType":"matrix","result":[]}}

Grafana 版本:v6.6.2 (3fa63cfc34)

Prometheus 没有任何身份验证, 此问题仅针对少数指标,并非针对所有指标。

从其配置部分测试数据源时。它表明一切正常。

有没有人对此有任何想法?

我发现了这个问题,

我在条目 LB 中启用了 WAF,我已删除并检查它是否有效。 WAF 将其视为 SQL 注入并因此阻止它。

在我看来,您无法从 Grafana 获取数据。因为 Grafana 没有 DB 地方来存储数据。它将使用任何其他来源的现有数据库来绘制基于时间的序列。