arthur-mdn / ExportGrafanaDashboardToPDF

Free PDF Export Tool in Grafana Community version - Using Puppeteer
16 stars 1 forks source link

PDF does not display some views #4

Open U17205367 opened 2 months ago

U17205367 commented 2 months ago

It generates the PDF report but I have 2 visualizations where the query is somewhat heavy, which is why it takes between 15 and 30 seconds to load the information depending on the time range I choose, so in the PDF that part comes out blank. Is there a way I can validate that all the visualizations have actually loaded before generating the PDF?

image

arthur-mdn commented 2 months ago

Hello, As this is an experimental development, I haven't included it on the main branch yet. Waiting to see if it is not causing troubles.

You need to pull the checkForAllQueriesToComplete branch. https://github.com/arthur-mdn/ExportGrafanaDashboardToPDF/tree/checkForAllQueriesToComplete

And add these in your .env :

CHECK_QUERIES_TO_COMPLETE=true
CHECK_QUERIES_TO_COMPLETE_MAX_QUERY_COMPLETION_TIME=30000
CHECK_QUERIES_TO_COMPLETE_QUERIES_COMPLETION_TIMEOUT=60000

Please try and tell me if the issue is solved.

U17205367 commented 2 months ago

Hello, I just tried the modified code and it works but with some modifications.

If I try to generate the PDF with the original code that you have modified, it gives me an error first because it detects 18 queries and in reality there are more because it validates that 19 have been completed

image

Analyzing the code in detail I could see that in the json you enter the array of the panels and only consider those that have the targets attribute, I modified this line so that it counts all of them

const count = json.dashboard.panels.length;

And then I saw that the interval variable is set to 2000ms, that means that if there are no changes in 2 seconds it detects it as a block and ends with an error, so I modified this variable from 2000ms to 20000ms, that is, 20 seconds

const interval = 20000;

After this change, the PDF was generated successfully and the panels that appeared blank now appear as they should be.

image

image

Thank you very much for your time in modifying the code.

nelsontr commented 2 weeks ago

Hi! Just checking in on the progress. What's missing for a master branch merge?