【问题标题】:Grafana:数据源(Prometheus)查询 403
【发布时间】:2021-03-20 12:00:40
【问题描述】:

从 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 没有任何身份验证, 这个问题只针对少数指标而不是所有指标。

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

有人对此有任何想法吗?

【问题讨论】:

    标签: grafana grafana-api


    【解决方案1】:

    我发现了这个问题,

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      • 这个解决了,我正在通过grafanas API查询grafana中添加的数据源。
      • 请您在这里分享步骤,这对我的grafana研究非常有用。我不确定如何使用 grafana API 的
      猜你喜欢
      • 2020-08-03
      • 1970-01-01
      • 2018-04-18
      • 2019-10-15
      • 2020-05-07
      • 2019-08-21
      • 1970-01-01
      • 2020-02-25
      • 2022-01-23
      相关资源
      最近更新 更多