Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql grafana postgres数据源测试返回;公制请求错误“;_Postgresql_Docker_Grafana_Prometheus_Timescaledb - Fatal编程技术网

Postgresql grafana postgres数据源测试返回;公制请求错误“;

Postgresql grafana postgres数据源测试返回;公制请求错误“;,postgresql,docker,grafana,prometheus,timescaledb,Postgresql,Docker,Grafana,Prometheus,Timescaledb,我已经部署了一个docker容器,使用Postgres的TimescaleDB扩展作为Prometheus收集的度量的持久存储。这包括在单独的容器中部署Prometheus Postgres适配器。然后我在第三个容器中部署了grafana 在TimescaleDB容器中,我可以执行查询: SELECT time_bucket('5 minutes', time) AS five_min_bucket, name, avg(value) FROM metrics WHERE (name='node

我已经部署了一个docker容器,使用Postgres的TimescaleDB扩展作为Prometheus收集的度量的持久存储。这包括在单独的容器中部署Prometheus Postgres适配器。然后我在第三个容器中部署了grafana

在TimescaleDB容器中,我可以执行查询:

SELECT time_bucket('5 minutes', time) AS five_min_bucket, name, avg(value)
FROM metrics
WHERE (name='node_load5' OR name='node_memory_Active_bytes') AND
      time > NOW() - interval '1 day'
GROUP BY five_min_bucket,name
ORDER BY five_min_bucket;
它从
度量值表中返回以下行:

   five_min_bucket     |           name           |        avg
------------------------+--------------------------+-------------------
 2019-07-13 16:15:00+00 | node_load5               |  1.84263157894737
 2019-07-13 16:15:00+00 | node_memory_Active_bytes |  1055776552.42105
 2019-07-13 16:20:00+00 | node_load5               |  1.62533333333333
 2019-07-13 16:20:00+00 | node_memory_Active_bytes |      1070225817.6
 2019-07-13 16:25:00+00 | node_load5               |  1.06166666666667
 2019-07-13 16:25:00+00 | node_memory_Active_bytes |  1084650018.13333
 2019-07-13 16:30:00+00 | node_load5               | 0.593333333333333
 2019-07-13 16:30:00+00 | node_memory_Active_bytes |  1093145668.26667
 2019-07-13 16:35:00+00 | node_load5               | 0.322333333333333
 2019-07-13 16:35:00+00 | node_memory_Active_bytes |  1108816145.06667
 2019-07-13 16:40:00+00 | node_load5               | 0.180666666666667
 2019-07-13 16:40:00+00 | node_memory_Active_bytes |      1125213388.8
 2019-07-13 16:45:00+00 | node_load5               |             0.126
 2019-07-13 16:45:00+00 | node_memory_Active_bytes |  1134488098.13333
 2019-07-13 16:50:00+00 | node_load5               | 0.133333333333333
 2019-07-13 16:50:00+00 | node_memory_Active_bytes |        1162440704
(16 rows)
grafana容器的运行方式为:

docker run \
-d \
-p 3000:3000 \
--name=grafana \
-v grafana-storage:/var/lib/grafana \
-e "GF_INSTALL_PLUGINS=grafana-kubernetes-app" \
 grafana/grafana
当我启动浏览器以
http://104.XX.XX.XX:3000
我可以登录到web ui并为postgres定义数据源,但我收到了错误“Metric request error”

我在其容器中查找grafana日志,路径
/var/log/grafana
为空。这是执行
docker inspect
命令时指示的日志位置

使用Chrome,我可以检查控制台,它报告服务器响应的内部错误为500

在主机上,我可以确认docker代理正在侦听端口5432

sudo netstat -antp | grep "5432"
tcp        0      0 172.17.0.1:49486        172.17.0.2:5432         ESTABLISHED 60631/docker-proxy
tcp6       0      0 :::5432                 :::*                    LISTEN      60631/docker-proxy
tcp6       0      0 10.0.0.4:5432           172.18.0.2:38568        ESTABLISHED 60631/docker-proxy

如何让grafana获取存储在postgres数据库中的度量?

好的,看起来我忘记了包含
--network prometheus\u timescale\u network
参数,该参数在构建容器时使用桥接驱动程序,在使用
--network prometheus_timescale_network
部署所有容器之后,我仍然会得到错误``{data:{…},状态:500,headers:ƒ,config:{…},statusText:“内部服务器错误”,…}config:{method:“POST”,transformRequest:Array(1),transformResponse:Array(1),paramSerializer:ƒ,jsonpCallbackParam:“回调”,…}数据:{message:“度量请求错误”}头:ƒ(n)状态:500状态文本:“内部服务器错误”xhrStatus:“完成”proto:Object
{data:{…},状态:500,头:ƒ,配置:{…},状态文本:“内部服务器错误”,…}配置:{方法:“POST”,transformRequest:Array(1),transformResponse:Array(1),paramSerializer:ƒ,jsonpCallbackParam:“callback”,…}数据:{message:“Metric request error”}头:ƒ(n)状态:500 statusText:“内部服务器错误”xhrStatus:“完成”uuu proto_u:Object
Ok,看起来我忘记了包含
--network prometheus\u timescale\u network
参数,该参数在构建容器时使用桥接驱动程序,并且将重新部署。在使用
--network prometheus\u timescale\u network
部署所有容器后,我仍然会得到错误``{数据:{…},状态:500,标题:ƒ,配置:{…},状态文本:“内部服务器错误”,…}配置:{method:“POST”,transformRequest:Array(1),transformResponse:Array(1),paramSerializer:ƒ,jsonpCallbackParam:“回调”,…}数据:{消息:“度量请求错误”}标题:ƒ(n)状态:500状态文本:“内部服务器错误”xhrStatus:“完成”proto:Object
{data:{…},status:500,headers:ƒ,config:{…},statusText:“内部服务器错误”,…}config:{method:“POST”,transformRequest:Array(1),transformResponse:Array(1),paramSerializer:ƒ,jsonpCallbackParam:“回调”,…}数据:{消息:“度量请求错误”}headers:ƒ(n)status:500 statusText:“内部服务器错误”xhrStatus:“完成”\uuuu proto\uuuu:Object