kartik468 / grafana-generate-pdf-nodejs

Generate pdf for grafana dashboards using nodejs and puppeteer
18 stars 6 forks source link

script not generate the traffic light plugin #1

Closed kahidna closed 3 years ago

kahidna commented 3 years ago

hi @kartik468
thank you for your script, its an awesome tools. but I found that this script have issue when generate pdf from dashboard which using traffic light plugins. the pdf successfully generated, but its not shown the traffic light. following is the screenshot of the pdf. image

and this is the dashboard

image

I'm not familiar with nodejs, but I figured out that the traffic light is always appear lastly from entire panel on dashboard. I tried to increase delay time at section await page.setDefaultNavigationTimeout(120000); to await page.setDefaultNavigationTimeout(150000); but no luck.

is there code that I can add so the pdf can completely generated?

ps: I use grafana v7.4.3 (010f20c1c8) traffic light v1.4.5

kartik468 commented 3 years ago

@kahidna How long does it take to load these panels? Can u pls try increasing the timeout to like large number lets say 2 to 3mins and see if it is visible in pdf. If it doesn't get displayed after that too then we will have to debug more.

kahidna commented 3 years ago

according to inspect element from firefox browser v86.0.1, using 100Mbps internet connection, it takes 17 seconds, image

I tried to increase await page.setDefaultNavigationTimeout(120000); to await page.setDefaultNavigationTimeout(240000); but the result still same. how can I enable debug mode for your script?

kahidna commented 3 years ago

hi @kartik468 is ther update for this issue?

kartik468 commented 3 years ago

try making headless to false in launch option

kahidna commented 3 years ago

hi @kartik468 sorry for late respond. here is the output when I tried using headless false option

image

the browser open, and as reported before, the traffic light comes last one. but I got some error message. here is the error message.

Error: Protocol error (Page.printToPDF): PrintToPDF is not implemented
    at /home/alfin/work/grafana-generate-pdf-nodejs/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:208:63
    at new Promise (<anonymous>)
    at CDPSession.send (/home/alfin/work/grafana-generate-pdf-nodejs/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:207:16)
    at Page.pdf (/home/alfin/work/grafana-generate-pdf-nodejs/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:1212:43)
    at /home/alfin/work/grafana-generate-pdf-nodejs/grafana_pdf.js:105:16
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

any idea?

kartik468 commented 3 years ago

hi @kahidna i think pdf generation works only when headless is false. i am not really sure why those plugins not displaying.. when i get some time i will check it by creating a dashboard and debug

kartik468 commented 3 years ago

@kahidna did you find the solution for this? i had checked code for the traffic plugin and i found it uses lots of javascript timers/intervals to update the values. i suspect that might be the issue here

kahidna commented 3 years ago

Hi @kartik468 no I haven't found the solution for this issue. As work around I manually do printscreen using printscreen button. Any idea for handle those timer?

I already increase the delay 10 times from your default value but have no luck.

kartik468 commented 3 years ago

@kahidna This is related to the plugin only and it looks like we can't do anything but update the plugin. so closing the issue.