Closed EvilLaughInc closed 1 year ago
Thanks for your detailed error report. And there is definitely something wrong in the handling of variables in ERB. Independent of this issue, I am pretty sure, ERB is not what you are searching for:
ERB templates are not a replacement for Asciidoctor, especially not, if you intend to build PDF files. ERBs are mainly helpful, if you intend to create e.g. text file results.
I propose, to leave this one open and I might have a look at it, when I find some time. Maybe you want to discuss your issue with Asciidoctor in an asciidoctor forum or you might want to open up another case here - but keep in mind: I am not an asciidoctor expert.
After having investigated a bit more in detail, it looks as if the issue is not related to variable handling, but rather to query handling of grafana.
Which grafana version are you running in your environment?
Closing because of missing input
I was attempting to convert my reporter to ERB templates to see if I could have more control over image placement since Asciidoc PDF doesnt allow for image float. I switched from Asciidoctor to ERB in the reporter config file. After the change I re-ran the config wizard to generate a new demo report to test with my grafana instance.
Upon testing I am getting a bare metal app response of: INFO -- : Report creation ended after 0 seconds with status 'died'
The webpage lists: GrafanaReporterError: The datasource request to 'unifi' (Grafana::InfluxDbDatasource) returned an invalid value: '{}'
Log file: DEBUG -- : Document attributes: {"grafana_report_timestamp"=>#<Grafana::Variable:0x000000000812f450 @config={}, @raw_value="2022-04-19 14:19:21 -0400", @text="2022-04-19 14:19:21 -0400">}
The reporter had no functional issues when running Asciidoctor, so I know the routing/network config is correct.
I am new to ruby/ERB in general, so if this is an easy fix please feel free to point me to a good resouce and I will keep on trying to get this working.
Application call
Template file (if applicable)
This is a test table for panel <%= panel.id %>:
<%= query.execute %>
grafana: default: host: http://localhost:3000 api_key: redacted
grafana-reporter: check-for-updates: 1 report-class: GrafanaReporter::ERB::Report templates-folder: ./templates reports-folder: ./reports report-retention: 180 webservice-port: 8815
I, [2022-04-19T14:19:21.302018 #14040] INFO -- : Report started at 2022-04-19 14:19:21 -0400 I, [2022-04-19T14:19:21.306733 #14040] INFO -- : You are running ruby-grafana-reporter version 0.5.4. D, [2022-04-19T14:19:21.642348 #14040] DEBUG -- : Document attributes: {"imagesdir"=>"./images", "var-template"=>"demo_report", "var-Controller"=>"https://192.168.X.X", "var-Site"=>"Default (default)", "var-AP"=>"UnPoller AP", "var-Switch"=>"", "var-Wireless"=>"All", "var-Wired"=>"All", "var-Identifier"=>"$tag_name", "var-SSID"=>"UnPoller Test", "var-Subsystem"=>"lan", "var-Devices"=>"All", "var-Port"=>"", "var-Uptime"=>"https://192.168.X.X", "grafana_report_timestamp"=>#<Grafana::Variable:0x000000000812f450 @config={}, @raw_value="2022-04-19 14:19:21 -0400", @text="2022-04-19 14:19:21 -0400">} D, [2022-04-19T14:19:21.647313 #14040] DEBUG -- : Requesting http://localhost:3000/api/frontend/settings with '' and timeout '60' D, [2022-04-19T14:19:21.720961 #14040] DEBUG -- : Received response #
D, [2022-04-19T14:19:21.725060 #14040] DEBUG -- : Requesting http://localhost:3000/api/dashboards/uid/test01 with '' and timeout '60'
D, [2022-04-19T14:19:21.837413 #14040] DEBUG -- : Received response #
D, [2022-04-19T14:19:21.849617 #14040] DEBUG -- : Requesting http://localhost:3000/api/datasources/proxy/2/query?db=unifi&q=SELECT%20max%28%22num_user%22%29%20AS%20%22Users%22%20FROM%20%22subsystems%22%20WHERE%20%28%22site_name%22%20%3D~%20%2F%5EDefault%20%28default%29%24%2F%29%20AND%20time%20%3E%3D%201650219561000ms%20and%20time%20%3C%3D%201650392360000ms%20GROUP%20BY%20time%28172s%29&epoch=ms with '' and timeout '60'
D, [2022-04-19T14:19:21.932275 #14040] DEBUG -- : Received response #
I, [2022-04-19T14:19:21.933221 #14040] INFO -- : Report creation ended after 0 seconds with status 'died'>
0 2022-04-19 14:40:12 -0400 2022-04-19 14:40:13 -0400 ./templates/demo_report.erb 0 secs died (0%) GrafanaReporterError: The datasource request to 'unifi' (Grafana::InfluxDbDatasource) returned an invalid value: '{}' C:/Users/rangetech/AppData/Local/Temp/ocrF3E6.tmp/src/lib/grafana_reporter/abstract_query.rb:95:in
execute' (erb):15:in
bind' C:/Users/RANGET~1/AppData/Local/Temp/ocrF3E6.tmp/lib/ruby/2.7.0/erb.rb:905:ineval' C:/Users/RANGET~1/AppData/Local/Temp/ocrF3E6.tmp/lib/ruby/2.7.0/erb.rb:905:in
result' C:/Users/rangetech/AppData/Local/Temp/ocrF3E6.tmp/src/lib/grafana_reporter/erb/report.rb:17:inbuild' C:/Users/rangetech/AppData/Local/Temp/ocrF3E6.tmp/src/lib/grafana_reporter/abstract_report.rb:148:in
create_report' C:/Users/rangetech/AppData/Local/Temp/ocrF3E6.tmp/src/lib/grafana_reporter/application/webservice.rb:221:in `block in render_report'