docker 上的 grafana 图像渲染器:错误请求

grafana image renderer on docker: bad request

我有一个带有 Grafana 的 docker 堆栈,它的图像渲染器插件配置如下:

grafana:
 image: grafana/grafana
 restart: always
 environment:
  - GF_RENDERING_SERVER_URL=http://renderer:8081/render
  - GF_RENDERING_CALLBACK_URL=http://grafana:3000/
  - GF_LOG_FILTERS= rendering:debug
  ...
  - GF_SERVER_PROTOCOL=https
  - GF_LOG_MODE=file
ports:
  - 6030:3000
networks:
  - tpin_net


renderer:
    image: grafana/grafana-image-renderer
    restart: always
    ports:
      - 8081
    networks:
      - tpin_net

但是在尝试渲染面板时出现错误“渲染失败”。下面来自容器的日志

Grafana

logger=rendering renderer=http t=2022-03-21T19:29:24.36+0000 lvl=info msg=Rendering path="d-solo/PUlb2g27z/healthcheck_dashboard?orgId=1&var-Country=SINGAPOR&var-Customer=SINGTEL&from=1647718128309&to=1647919728309&panelId=4&width=1000&height=500&tz=Asia%2FQatar"
logger=rendering renderer=http t=2022-03-21T19:29:24.37+0000 lvl=dbug msg="calling remote rendering service" url="http://renderer:8081/render?deviceScaleFactor=1.000000&domain=grafana&encoding=&height=500&renderKey=24RLoc72xoFtKjLA4tViQJ4RSuyHHG63&timeout=60&timezone=Asia%2FQatar&url=http%3A%2F%2Fgrafana%3A3000%2Fd-solo%2FPUlb2g27z%2Fhealthcheck_dashboard%3ForgId%3D1%26var-Country%3DSINGAPOR%26var-Customer%3DSINGTEL%26from%3D1647718128309%26to%3D1647919728309%26panelId%3D4%26width%3D1000%26height%3D500%26tz%3DAsia%252FQatar%26render%3D1&width=1000"
logger=rendering renderer=http t=2022-03-21T19:30:02.85+0000 lvl=eror msg="Failed to send request to remote rendering service" error="Get \"http://renderer:8081/render?deviceScaleFactor=1.000000&domain=grafana&encoding=&height=500&renderKey=24RLoc72xoFtKjLA4tViQJ4RSuyHHG63&timeout=60&timezone=Asia%2FQatar&url=http%3A%2F%2Fgrafana%3A3000%2Fd-solo%2FPUlb2g27z%2Fhealthcheck_dashboard%3ForgId%3D1%26var-Country%3DSINGAPOR%26var-Customer%3DSINGTEL%26from%3D1647718128309%26to%3D1647919728309%26panelId%3D4%26width%3D1000%26height%3D500%26tz%3DAsia%252FQatar%26render%3D1&width=1000\": context canceled"
logger=rendering t=2022-03-21T19:30:02.85+0000 lvl=eror msg="Failed to delete render key" error="context canceled"
logger=context t=2022-03-21T19:30:02.85+0000 lvl=eror msg="Rendering failed." error="failed to send request to remote rendering service: Get \"http://renderer:8081/render?deviceScaleFactor=1.000000&domain=grafana&encoding=&height=500&renderKey=24RLoc72xoFtKjLA4tViQJ4RSuyHHG63&timeout=60&timezone=Asia%2FQatar&url=http%3A%2F%2Fgrafana%3A3000%2Fd-solo%2FPUlb2g27z%2Fhealthcheck_dashboard%3ForgId%3D1%26var-Country%3DSINGAPOR%26var-Customer%3DSINGTEL%26from%3D1647718128309%26to%3D1647919728309%26panelId%3D4%26width%3D1000%26height%3D500%26tz%3DAsia%252FQatar%26render%3D1&width=1000\": context canceled"
logger=context t=2022-03-21T19:30:02.85+0000 lvl=eror msg="Request Completed" method=GET path=/render/d-solo/PUlb2g27z/healthcheck_dashboard status=500 remote_addr=10.0.0.2 time_ms=38509 size=1344 referer=
logger=rendering renderer=http t=2022-03-21T19:35:02.04+0000 lvl=info msg=Rendering path="d-solo/PUlb2g27z/healthcheck_dashboard?orgId=1&var-Country=SINGAPOR&var-Customer=SINGTEL&from=1647718128309&to=1647919728309&panelId=4&width=1000&height=500&tz=Asia%2FQatar"
logger=rendering renderer=http t=2022-03-21T19:35:02.05+0000 lvl=dbug msg="calling remote rendering service" url="http://renderer:8081/render?deviceScaleFactor=1.000000&domain=grafana&encoding=&height=500&renderKey=Zxu21wz36qSeCc1slQb6ssPA8Y4i2hTM&timeout=60&timezone=Asia%2FQatar&url=http%3A%2F%2Fgrafana%3A3000%2Fd-solo%2FPUlb2g27z%2Fhealthcheck_dashboard%3ForgId%3D1%26var-Country%3DSINGAPOR%26var-Customer%3DSINGTEL%26from%3D1647718128309%26to%3D1647919728309%26panelId%3D4%26width%3D1000%26height%3D500%26tz%3DAsia%252FQatar%26render%3D1&width=1000"

图像渲染器

rpm_renderer.1.1huzg0b8pqxn@rpm    | {"level":"error","message":"Browser console error","msg":"Failed to load resource: the server responded with a status of 400 (Bad Request)","url":"http://grafana:3000/d-solo/PUlb2g27z/healthcheck_dashboard?orgId=1&var-Country=SINGAPOR&var-Customer=SINGTEL&from=1647718128309&to=1647919728309&panelId=4&width=1000&height=500&tz=Asia%2FQatar&render=1"}
rpm_renderer.1.1huzg0b8pqxn@rpm    | {"failure":"net::ERR_CONNECTION_RESET","level":"error","message":"Browser request failed","method":"GET","url":"http://grafana:3000/d-solo/PUlb2g27z/healthcheck_dashboard?orgId=1&var-Country=SINGAPOR&var-Customer=SINGTEL&from=1647718128309&to=1647919728309&panelId=4&width=1000&height=500&tz=Asia%2FQatar&render=1"}
rpm_renderer.1.1huzg0b8pqxn@rpm    | {"level":"error","message":"Browser console error","msg":"Failed to load resource: net::ERR_CONNECTION_RESET","url":"http://grafana:3000/d-solo/PUlb2g27z/healthcheck_dashboard?orgId=1&var-Country=SINGAPOR&var-Customer=SINGTEL&from=1647718128309&to=1647919728309&panelId=4&width=1000&height=500&tz=Asia%2FQatar&render=1"}
rpm_renderer.1.1huzg0b8pqxn@rpm    | {"err":"TimeoutError: Navigation timeout of 60000 ms exceeded\n    at /usr/src/app/node_modules/puppeteer/lib/cjs/puppeteer/common/LifecycleWatcher.js:107:111","level":"error","message":"Error while trying to prepare page for screenshot","url":"http://grafana:3000/d-solo/PUlb2g27z/healthcheck_dashboard?orgId=1&var-Country=SINGAPOR&var-Customer=SINGTEL&from=1647718128309&to=1647919728309&panelId=4&width=1000&height=500&tz=Asia%2FQatar&render=1"}
rpm_renderer.1.1huzg0b8pqxn@rpm    | {"err":"TimeoutError: waiting for function failed: timeout 60000ms exceeded\n    at new WaitTask (/usr/src/app/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:526:34)\n    at DOMWorld.waitForFunction (/usr/src/app/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:477:26)\n    at Frame.waitForFunction (/usr/src/app/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:993:32)\n    at Page.waitForFunction (/usr/src/app/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:2479:33)\n    at /usr/src/app/build/browser/browser.js:309:33\n    at Browser.<anonymous> (/usr/src/app/build/browser/browser.js:424:24)\n    at Generator.next (<anonymous>)\n    at /usr/src/app/build/browser/browser.js:8:71\n    at new Promise (<anonymous>)\n    at __awaiter (/usr/src/app/build/browser/browser.js:4:12)","level":"error","message":"Error while waiting for the panels to load","url":"http://grafana:3000/d-solo/PUlb2g27z/healthcheck_dashboard?orgId=1&var-Country=SINGAPOR&var-Customer=SINGTEL&from=1647718128309&to=1647919728309&panelId=4&width=1000&height=500&tz=Asia%2FQatar&render=1"}
rpm_renderer.1.1huzg0b8pqxn@rpm    | {"level":"error","message":"Browser console error","msg":"Failed to load resource: the server responded with a status of 400 (Bad Request)","url":"http://grafana:3000/d-solo/PUlb2g27z/healthcheck_dashboard?orgId=1&var-Country=SINGAPOR&var-Customer=SINGTEL&from=1647718128309&to=1647919728309&panelId=4&width=1000&height=500&tz=Asia%2FQatar&render=1"}
rpm_renderer.1.1huzg0b8pqxn@rpm    | {"failure":"net::ERR_CONNECTION_RESET","level":"error","message":"Browser request failed","method":"GET","url":"http://grafana:3000/d-solo/PUlb2g27z/healthcheck_dashboard?orgId=1&var-Country=SINGAPOR&var-Customer=SINGTEL&from=1647718128309&to=1647919728309&panelId=4&width=1000&height=500&tz=Asia%2FQatar&render=1"}
rpm_renderer.1.1huzg0b8pqxn@rpm    | {"level":"error","message":"Browser console error","msg":"Failed to load resource: net::ERR_CONNECTION_RESET","url":"http://grafana:3000/d-solo/PUlb2g27z/healthcheck_dashboard?orgId=1&var-Country=SINGAPOR&var-Customer=SINGTEL&from=1647718128309&to=1647919728309&panelId=4&width=1000&height=500&tz=Asia%2FQatar&render=1"}
rpm_renderer.1.1huzg0b8pqxn@rpm    | {"err":"TimeoutError: Navigation timeout of 60000 ms exceeded\n    at /usr/src/app/node_modules/puppeteer/lib/cjs/puppeteer/common/LifecycleWatcher.js:107:111","level":"error","message":"Error while trying to prepare page for screenshot","url":"http://grafana:3000/d-solo/PUlb2g27z/healthcheck_dashboard?orgId=1&var-Country=SINGAPOR&var-Customer=SINGTEL&from=1647718128309&to=1647919728309&panelId=4&width=1000&height=500&tz=Asia%2FQatar&render=1"}

我环顾四周,发现一个答案说 SQL 查询花费了 60 多秒,但在仪表板内,面板会在几秒钟内加载,并且有关错误请求的日志会立即显示,当我单击渲染图像按钮

您的 Grafana 有:

 - GF_SERVER_PROTOCOL=https

所以我打赌回调 url 需要 https 协议:

 - GF_RENDERING_CALLBACK_URL=https://grafana:3000/

顺便说一句 renderer can have a debug modeLOG_LEVEL=debug