grafana-image-renderer icon indicating copy to clipboard operation
grafana-image-renderer copied to clipboard

Full page screenshots not working with height != -1 for version >=3.8.4, "Error while waiting for the panels to loads"

Open zifter opened this issue 1 year ago • 6 comments

What happened: The latest version of grafana-image-renderer failed to render any dashboards in less than 60 seconds. {"level":"debug","message":"Waiting for dashboard/panel to load","timeout":"60s"} {"level":"debug","message":"Browser request","method":"POST","url":"http://grafana:3000/api/frontend-metrics"} {"level":"debug","message":"Browser request finished","method":"POST","url":"http://grafana:3000/api/frontend-metrics"} {"err":"TimeoutError: Waiting failed: 60000ms exceeded\n at Timeout.<anonymous> (/usr/src/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/WaitTask.js:59:37)\n at listOnTimeout (node:internal/timers:569:17)\n at process.processTimers (node:internal/timers:512:7)","level":"error","message":"Error while waiting for the panels to load","url":"http://grafana:3000/d/iUfmr5kMk/prometheus-2-22?orgId=1&width=1024&height=1024&render=1&render=1"} {"level":"debug","message":"Setting zoom level","zoomLevel":1} {"filePath":"/tmp/62cbb3db.png","level":"debug","message":"Taking screenshot"} {"level":"error","message":"Request failed","stack":"Error: Request aborted\n at onaborted (/usr/src/app/node_modules/express/lib/response.js:1052:15)\n at Immediate._onImmediate (/usr/src/app/node_modules/express/lib/response.js:1094:9)\n at process.processImmediate (node:internal/timers:476:21)","url":"/render?deviceScaleFactor=1.000000&domain=grafana&encoding=&height=1024&renderKey=mCgaaFqDE8KBALUazDrwOcTKnB3man0v&timeout=60&timezone=&url=http%3A%2F%2Fgrafana%3A3000%2Fd%2FiUfmr5kMk%2Fprometheus-2-22%3ForgId%3D1%26width%3D1024%26height%3D1024%26render%3D1%26render%3D1&width=1024"} {"err":"TimeoutError: Waiting failed: 60000ms exceeded\n at Timeout.<anonymous> (/usr/src/app/node_modules/puppeteer-core/lib/cjs/puppeteer/common/WaitTask.js:59:37)\n at listOnTimeout (node:internal/timers:569:17)\n at process.processTimers (node:internal/timers:512:7)","level":"error","message":"Error while waiting for the panels to load","url":"http://grafana:3000/d/iUfmr5kMk/prometheus-2-22?orgId=1&width=1024&height=1024&render=1&render=1"} {"level":"debug","message":"Setting zoom level","zoomLevel":1} {"filePath":"/tmp/6ee09d17.png","level":"debug","message":"Taking screenshot"} {"file":"/tmp/6ee09d17.png","level":"debug","message":"Deleting temporary file"} {"level":"debug","message":"::ffff:172.27.0.4 - - [07/Jan/2024:10:02:17 +0000] \"GET /render?deviceScaleFactor=1.000000&domain=grafana&encoding=&height=1024&renderKey=ORjNjvnO5NWOynWvPJsWwod1WiqRmPFn&timeout=60&timezone=&url=http%3A%2F%2Fgrafana%3A3000%2Fd%2FiUfmr5kMk%2Fprometheus-2-22%3ForgId%3D1%26width%3D1024%26height%3D1024%26render%3D1%26render%3D1&width=1024 HTTP/1.1\" 200 157291 \"-\" \"Grafana/10.1.4\"\n"} {"level":"debug","message":"Connection closed","url":"http://grafana:3000/d/iUfmr5kMk/prometheus-2-22?orgId=1&width=1024&height=1024&render=1&render=1"} What you expected to happen: The latest grafana-image-renderer renders any dashboards correctly within a reasonable time range.

How to reproduce it (as minimally and precisely as possible):

  1. Download https://github.com/zifter/unireport/
  2. Enters dev folders (cd dev)
  3. make up
  4. open http://localhost:3000/render/d/iUfmr5kMk/prometheus-2-22?orgId=1&width=1024&height=1024&render=1

Anything else we need to know?: It's working as expected in 3.8.3, but starts failing after 3.8.4 version. I suppose the reason is changes made in https://github.com/grafana/grafana-image-renderer/pull/472/files. panel-container class can't be found, but I see a dynamic style like css-1ijfwvk-panel-container. I suppose it's not working with the latest Grafana setup.

Environment:

  • Grafana Image Renderer version >= 3.8.4:
  • Grafana version - v10.1.4 (a676a96d91):
  • work as remote renderer service:
  • OS Grafana Image Renderer is installed on - the official docker image which is run on Ubuntu:
  • User OS & Browser - Ubuntu 20.04, latest chrome:

zifter avatar Jan 07 '24 10:01 zifter

Hi, @AgnesToulet! Sorry for disturbing you! I suppose you might be familiar with root cause of that issue and might help me :)

zifter avatar Jan 13 '24 17:01 zifter

Hi @zifter, it seems like you are not using the image renderer as it is intended. I followed the steps you wrote to reproduce the issue and it seems like you want to render a screenshot of the full dashboard. If this is indeed the case, you should use height=-1 so use the following URL: http://localhost:3000/render/d/iUfmr5kMk/prometheus-2-22?orgId=1&width=1024&height=-1&render=1

In this case, it shouldn't timeout.

AgnesToulet avatar Jan 18 '24 13:01 AgnesToulet

@AgnesToulet thanks for the replay! Yes, I want to render the whole dashboard, but in my integration test, I specified a fixed height and it worked before 3.8.3, and after 3.8.4 it's working as I described above. It seems like some kind of regression bug for me.

I tested: http://localhost:3000/render/d/iUfmr5kMk/prometheus-2-22?orgId=1&width=1024&height=-1&render=1 - working http://localhost:3000/render/d/iUfmr5kMk/prometheus-2-22?orgId=1&width=1024&height=1024&render=1 - query more than 60 seconds

Maybe there is some wrong waiting condition for the dashboard to finish loading? Because it's ok to render image with specified width and height

zifter avatar Jan 19 '24 15:01 zifter

I'd say, it's more a behavior that was working before but that we never intended to support as you should specify height=-1 to render a full dashboard screenshot.

You're right to say this is related to this change but it fixes the condition that was broken before and didn't wait for anything. The condition to support waiting for the full dashboard to load is written before but it's used only if height=-1.

It could make sense to add a fullPage parameter to both support setting a height and taking a screenshot of the full dashboard. Let me bring this back to the team and if we decide it would be a good addition to the image renderer, contributions to make this happen would be welcomed!

AgnesToulet avatar Jan 22 '24 08:01 AgnesToulet