divinity666 / ruby-grafana-reporter

Reporting Service for Grafana
MIT License
66 stars 5 forks source link

"Repeat for" rows in a dashboard are not working #39

Open ttm92 opened 1 year ago

ttm92 commented 1 year ago

Describe the issue I've been using this plugin for a while and it's really handy. Thank you for the work done. I have a new report that contains sections that repeat according to technology (based on the variable soft_techno which is an array of values). Within each section I have several panels that I want to export as an image. When I have one technology selected is working, but when I have more than one, I have an error :

I have seen that in the logs we can see the request : "http://xxx.xxx.xxx.xxx:3000/render/d-solo/JAUih-d7z?panelId=36&fullscreen=true&theme=light&timeout=60&var-date_selected=2023-02-18&var-soft_techno=%5B%22MariaDB%22%2C+%22MSSQL%22%5D&var-count_soft_techno=2&var-template=Obsolescence.adoc&height=150&width=400&from=1677772968000&to=1677859367000" which is not working In grafana, in order to have the image exported, the request to use is : "http://xxx.xxx.xxx.xxx:3000/render/d-solo/JAUih-d7z?panelId=36&fullscreen=true&theme=light&timeout=60&var-date_selected=2023-02-18&var-soft_techno=MariaDB&var-soft_techno=MSSQL&var-count_soft_techno=2&var-template=Obsolescence.adoc&height=150&width=400&from=1677772968000&to=1677859367000" Hope that can help.

Environment (please complete the following information):

I, [2023-03-03T16:02:48.289154 #7]  INFO -- : Report started at 2023-03-03 16:02:48 +0000
I, [2023-03-03T16:02:48.289833 #7]  INFO -- : You are running ruby-grafana-reporter version 0.6.2.
D, [2023-03-03T16:02:48.289962 #7] DEBUG -- : Document attributes: {"convert-backend"=>"pdf", "imagesdir"=>"./images", "var-template"=>"Obsolescence.adoc", "pdf-theme"=>"Obsolescence", "pdf-themesdir"=>"./templates", "from"=>"now-24h", "to"=>"now", "var-date_selected"=>"2023-02-18", "var-soft_techno"=>["MariaDB", "MSSQL"], "var-count_soft_techno"=>"2"}
D, [2023-03-03T16:02:48.290258 #7] DEBUG -- : Template ./templates/Obsolescence.adoc contains 14 calls of grafana reporter functions.
W, [2023-03-03T16:02:48.302889 #7]  WARN -- : the outline-list theme category is deprecated; use the list category instead
D, [2023-03-03T16:02:48.335251 #7] DEBUG -- : Processing PanelImageInlineMacro (instance: default, dashboard: JAUih-d7z, panel: 35)
D, [2023-03-03T16:02:48.335535 #7] DEBUG -- : Requesting http://xxx.xxx.xxx.xxx:3000/api/frontend/settings with '' and timeout '60'
D, [2023-03-03T16:02:48.371837 #7] DEBUG -- : Received response #<Net::HTTPOK:0x00007fd093e75020>
D, [2023-03-03T16:02:48.377277 #7] DEBUG -- : Requesting http://xxx.xxx.xxx.xxx:3000/api/dashboards/uid/JAUih-d7z with '' and timeout '60'
D, [2023-03-03T16:02:48.410568 #7] DEBUG -- : Received response #<Net::HTTPOK:0x00007fd093e65ee0>
D, [2023-03-03T16:02:48.412435 #7] DEBUG -- : Requesting http://xxx.xxx.xxx.xxx:3000/api/health with '' and timeout '60'
D, [2023-03-03T16:02:48.414903 #7] DEBUG -- : Received response #<Net::HTTPOK:0x00007fd093e44650>
D, [2023-03-03T16:02:48.415328 #7] DEBUG -- : Requesting http://xxx.xxx.xxx.xxx:3000/render/d-solo/JAUih-d7z?panelId=35&fullscreen=true&theme=dark&timeout=60&var-date_selected=2023-02-18&var-soft_techno=%5B%22MariaDB%22%2C+%22MSSQL%22%5D&var-count_soft_techno=2&var-template=Obsolescence.adoc&height=30&from=1677772968000&to=1677859367000 with '' and timeout '60'
D, [2023-03-03T16:02:50.895218 #7] DEBUG -- : Received response #<Net::HTTPOK:0x00007fd093e27370>
D, [2023-03-03T16:02:50.924594 #7] DEBUG -- : Processing PanelImageInlineMacro (instance: default, dashboard: JAUih-d7z, panel: 39)
D, [2023-03-03T16:02:50.925619 #7] DEBUG -- : Requesting http://xxx.xxx.xxx.xxx:3000/render/d-solo/JAUih-d7z?panelId=39&fullscreen=true&theme=light&timeout=60&var-date_selected=2023-02-18&var-soft_techno=%5B%22MariaDB%22%2C+%22MSSQL%22%5D&var-count_soft_techno=2&var-template=Obsolescence.adoc&height=250&width=600&from=1677772968000&to=1677859367000 with '' and timeout '60'
D, [2023-03-03T16:02:53.579837 #7] DEBUG -- : Received response #<Net::HTTPOK:0x00007fd0936ffdb8>
D, [2023-03-03T16:02:53.710042 #7] DEBUG -- : Processing PanelImageInlineMacro (instance: default, dashboard: JAUih-d7z, panel: 36)
D, [2023-03-03T16:02:53.711016 #7] DEBUG -- : Requesting http://xxx.xxx.xxx.xxx:3000/render/d-solo/JAUih-d7z?panelId=36&fullscreen=true&theme=light&timeout=60&var-date_selected=2023-02-18&var-soft_techno=%5B%22MariaDB%22%2C+%22MSSQL%22%5D&var-count_soft_techno=2&var-template=Obsolescence.adoc&height=150&width=400&from=1677772968000&to=1677859367000 with '' and timeout '60'
F, [2023-03-03T16:04:53.773684 #7] FATAL -- : undefined method `[]' for nil:NilClass

      @model['name']
            ^^^^^^^^
D, [2023-03-03T16:04:53.775094 #7] DEBUG -- : Processing PanelImageInlineMacro (instance: default, dashboard: JAUih-d7z, panel: 29)
D, [2023-03-03T16:04:53.776351 #7] DEBUG -- : Requesting http://xxx.xxx.xxx.xxx:3000/render/d-solo/JAUih-d7z?panelId=29&fullscreen=true&theme=light&timeout=60&var-date_selected=2023-02-18&var-soft_techno=%5B%22MariaDB%22%2C+%22MSSQL%22%5D&var-count_soft_techno=2&var-template=Obsolescence.adoc&height=80&width=400&from=1677772968000&to=1677859367000 with '' and timeout '60'
D, [2023-03-03T16:04:56.500178 #7] DEBUG -- : Received response #<Net::HTTPOK:0x00007fd0ba743640>
D, [2023-03-03T16:04:56.539926 #7] DEBUG -- : Processing PanelImageInlineMacro (instance: default, dashboard: JAUih-d7z, panel: 37)
D, [2023-03-03T16:04:56.541399 #7] DEBUG -- : Requesting http://xxx.xxx.xxx.xxx:3000/render/d-solo/JAUih-d7z?panelId=37&fullscreen=true&theme=light&timeout=60&var-date_selected=2023-02-18&var-soft_techno=%5B%22MariaDB%22%2C+%22MSSQL%22%5D&var-count_soft_techno=2&var-template=Obsolescence.adoc&height=250&width=600&from=1677772968000&to=1677859367000 with '' and timeout '60'
D, [2023-03-03T16:05:03.220408 #7] DEBUG -- : Received response #<Net::HTTPOK:0x00007fd0b9c6cb18>
D, [2023-03-03T16:05:03.324973 #7] DEBUG -- : Processing PanelImageInlineMacro (instance: default, dashboard: JAUih-d7z, panel: 32)
D, [2023-03-03T16:05:03.326374 #7] DEBUG -- : Requesting http://xxx.xxx.xxx.xxx:3000/render/d-solo/JAUih-d7z?panelId=32&fullscreen=true&theme=light&timeout=60&var-date_selected=2023-02-18&var-soft_techno=%5B%22MariaDB%22%2C+%22MSSQL%22%5D&var-count_soft_techno=2&var-template=Obsolescence.adoc&height=150&width=400&from=1677772968000&to=1677859367000 with '' and timeout '60'
F, [2023-03-03T16:07:03.396140 #7] FATAL -- : undefined method `[]' for nil:NilClass

      @model['name']
            ^^^^^^^^
D, [2023-03-03T16:07:03.399230 #7] DEBUG -- : Processing PanelImageInlineMacro (instance: default, dashboard: JAUih-d7z, panel: 34)
D, [2023-03-03T16:07:03.402650 #7] DEBUG -- : Requesting http://xxx.xxx.xxx.xxx:3000/render/d-solo/JAUih-d7z?panelId=34&fullscreen=true&theme=light&timeout=60&var-date_selected=2023-02-18&var-soft_techno=%5B%22MariaDB%22%2C+%22MSSQL%22%5D&var-count_soft_techno=2&var-template=Obsolescence.adoc&height=80&width=400&from=1677772968000&to=1677859367000 with '' and timeout '60'
D, [2023-03-03T16:07:06.171308 #7] DEBUG -- : Received response #<Net::HTTPOK:0x00007fd0ae20bb70>
D, [2023-03-03T16:07:06.196420 #7] DEBUG -- : Processing PanelImageInlineMacro (instance: default, dashboard: JAUih-d7z, panel: 41)
E, [2023-03-03T16:07:06.196620 #7] ERROR -- : GrafanaError: The specified panel id '41' does not exist on the dashboard 'JAUih-d7z'. (Grafana::PanelDoesNotExistError)
D, [2023-03-03T16:07:06.213931 #7] DEBUG -- : Processing PanelImageInlineMacro (instance: default, dashboard: JAUih-d7z, panel: 42)
E, [2023-03-03T16:07:06.214041 #7] ERROR -- : GrafanaError: The specified panel id '42' does not exist on the dashboard 'JAUih-d7z'. (Grafana::PanelDoesNotExistError)
D, [2023-03-03T16:07:06.214233 #7] DEBUG -- : Processing PanelImageInlineMacro (instance: default, dashboard: JAUih-d7z, panel: 43)
E, [2023-03-03T16:07:06.214264 #7] ERROR -- : GrafanaError: The specified panel id '43' does not exist on the dashboard 'JAUih-d7z'. (Grafana::PanelDoesNotExistError)
D, [2023-03-03T16:07:06.214374 #7] DEBUG -- : Processing PanelImageInlineMacro (instance: default, dashboard: JAUih-d7z, panel: 44)
E, [2023-03-03T16:07:06.214401 #7] ERROR -- : GrafanaError: The specified panel id '44' does not exist on the dashboard 'JAUih-d7z'. (Grafana::PanelDoesNotExistError)
D, [2023-03-03T16:07:06.214534 #7] DEBUG -- : Processing PanelImageInlineMacro (instance: default, dashboard: JAUih-d7z, panel: 45)
E, [2023-03-03T16:07:06.214564 #7] ERROR -- : GrafanaError: The specified panel id '45' does not exist on the dashboard 'JAUih-d7z'. (Grafana::PanelDoesNotExistError)
D, [2023-03-03T16:07:06.214669 #7] DEBUG -- : Processing PanelImageInlineMacro (instance: default, dashboard: JAUih-d7z, panel: 46)
E, [2023-03-03T16:07:06.214696 #7] ERROR -- : GrafanaError: The specified panel id '46' does not exist on the dashboard 'JAUih-d7z'. (Grafana::PanelDoesNotExistError)
D, [2023-03-03T16:07:06.214802 #7] DEBUG -- : Processing PanelImageInlineMacro (instance: default, dashboard: JAUih-d7z, panel: 47)
E, [2023-03-03T16:07:06.214831 #7] ERROR -- : GrafanaError: The specified panel id '47' does not exist on the dashboard 'JAUih-d7z'. (Grafana::PanelDoesNotExistError)
I, [2023-03-03T16:07:06.304792 #7]  INFO -- : Report creation ended after 258 seconds with status 'finished'
divinity666 commented 1 year ago

Thanks for your feedback and for using the reporter.

It is correct, that "Repeat for" is not properly supported today. Anyway, there is a workaround, that might be ok for you to try out:

grafana_panel_image::36[dashboard="JAUih-d7z",date_selected="2023-02-18",soft_techno="MariaDB",count_soft_techno="2"]

Depending on the variables specified, you can walk through the desired exports in your template. Please try it out and let me know the results.