divinity666 / ruby-grafana-reporter

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

From and To cannot take semi-relative time ranges #47

Closed JenSeReal closed 1 month ago

JenSeReal commented 1 month ago

Describe the issue With Grafana you can specify semi-relative time ranges in your visualizations. This can be useful if you want to for example get the data of a business day. If you enter now/d+8h for From and To the time range is from 8:00AM yesterday to 8:00AM today. If these time ranges are used in the dashboard or specified in the template via :from: or :to: the dashboard won't be rendered and the application call will just run forever until you exit with Ctrl+C. When I switch the time range to :from: now-24h and :to: now everything works flawlessly.

Application call

Template file (if applicable)

:grafana_default_dashboard: :grafana_default_from_timezone: Europe/Berlin

:from: now/d+8h :to: now/d+8h

[cols="1,1", frame=none, grid=none] |=== 2+|grafana_panel_image:2[render-height="400", render-width="1200"]

|grafana_panel_image:4[render-height="200"] |grafana_panel_image:5[render-height="200"]

|grafana_panel_image:7[render-height="200"] |grafana_panel_image:6[render-height="200"] |===


**Configuration file**
 - created with configuration wizard version [e.g. 0.3.0 or MANUAL]:
   - created with the wizard version 0.6.6 
 - relevant part of configuration file (remember to X-out personal information as e.g. api_key):

This configuration has been built with the configuration wizard.

grafana: default: host: http://localhost:3000 api_key:

grafana-reporter:

Specifies how often the reporter shall check for newer versions [number of days].

You may set check-for-updates to 0 to disable

check-for-updates: 1 report-class: GrafanaReporter::Asciidoctor::Report templates-folder: ./templates reports-folder: ./reports report-retention: 24 webservice-port: 8815

you may want to configure the following webhook callbacks to get informed on certain events

callbacks:

all:

- <>

- ...

on_before_create:

- <>

- ...

on_after_cancel:

- <>

- ...

on_after_finish:

- <>

- ...

default-document-attributes: imagesdir: ./images

feel free to add here additional asciidoctor document attributes which are applied to all your templates


**Environment (please complete the following information):**
 - OS [e.g. Windows 10]:
   -  MacOS with colima running docker 
 - Grafana version [e.g. 6.3.4]:
  - grafana/grafana-oss:10.3.6
  - grafana-image-renderer:3.10.4
 - Environment [e.g. source, gem, docker or windows-exe]:
  - Grafana and renderer in docker
  - Reporter installed via gem  
 - Ruby Version, if source or gem environment [e.g. 2.3.7]:
   - ruby 3.1.4p223 (2023-03-30 revision 957bb7cb81) [arm64-darwin23]
   - gem 3.5.6
 - Reporter version [e.g. 0.3.0]:
   - 0.6.6 

I, [2024-05-14T15:55:47.566895 #40677] INFO -- : Report started at 2024-05-14 15:55:47 +0200 I, [2024-05-14T15:55:47.566920 #40677] INFO -- : You are running ruby-grafana-reporter version 0.6.6. D, [2024-05-14T15:55:47.789549 #40677] DEBUG -- : Document attributes: {"convert-backend"=>"pdf", "imagesdir"=>"./images", "var-template"=>""} D, [2024-05-14T15:55:47.790306 #40677] DEBUG -- : Template ./templates/.adoc contains 5 calls of grafana reporter functions. D, [2024-05-14T15:55:47.828220 #40677] DEBUG -- : Processing PanelImageInlineMacro (instance: default, dashboard: , panel: 2) D, [2024-05-14T15:55:47.828444 #40677] DEBUG -- : Requesting http://localhost:3000/api/frontend/settings with '' and timeout '60' D, [2024-05-14T15:55:47.839819 #40677] DEBUG -- : Received response # D, [2024-05-14T15:55:47.840261 #40677] DEBUG -- : Requesting http://localhost:3000/api/dashboards/uid/ with '' and timeout '60' D, [2024-05-14T15:55:47.846482 #40677] DEBUG -- : Received response # ^CI, [2024-05-14T16:03:48.625257 #40677] INFO -- : Report creation ended after 481 seconds with status 'finished'

:299:in `initialize': Interrupt from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/ruby-grafana-reporter-0.6.6/lib/grafana_reporter/abstract_query.rb:446:in `new' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/ruby-grafana-reporter-0.6.6/lib/grafana_reporter/abstract_query.rb:446:in `to_time' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/ruby-grafana-reporter-0.6.6/lib/grafana_reporter/abstract_query.rb:446:in `delta_date' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/ruby-grafana-reporter-0.6.6/lib/grafana_reporter/abstract_query.rb:385:in `translate_date' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/ruby-grafana-reporter-0.6.6/lib/grafana_reporter/abstract_query.rb:72:in `execute' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/ruby-grafana-reporter-0.6.6/lib/grafana_reporter/asciidoctor/panel_image_inline_macro.rb:52:in `process' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-2.0.22/lib/asciidoctor/substitutors.rb:333:in `[]' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-2.0.22/lib/asciidoctor/substitutors.rb:333:in `block (2 levels) in sub_macros' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-2.0.22/lib/asciidoctor/substitutors.rb:309:in `gsub' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-2.0.22/lib/asciidoctor/substitutors.rb:309:in `block in sub_macros' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-2.0.22/lib/asciidoctor/substitutors.rb:308:in `each' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-2.0.22/lib/asciidoctor/substitutors.rb:308:in `sub_macros' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-2.0.22/lib/asciidoctor/substitutors.rb:102:in `block in apply_subs' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-2.0.22/lib/asciidoctor/substitutors.rb:91:in `each' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-2.0.22/lib/asciidoctor/substitutors.rb:91:in `apply_subs' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-2.0.22/lib/asciidoctor/table.rb:358:in `text' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-pdf-2.3.15/lib/asciidoctor/pdf/converter.rb:2065:in `block (4 levels) in convert_table' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-pdf-2.3.15/lib/asciidoctor/pdf/converter.rb:2064:in `map' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-pdf-2.3.15/lib/asciidoctor/pdf/converter.rb:2064:in `block (3 levels) in convert_table' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-pdf-2.3.15/lib/asciidoctor/pdf/converter.rb:2063:in `each' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-pdf-2.3.15/lib/asciidoctor/pdf/converter.rb:2063:in `block (2 levels) in convert_table' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-pdf-2.3.15/lib/asciidoctor/pdf/converter.rb:4561:in `block in theme_font' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn/font.rb:60:in `block in font' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn/font.rb:214:in `save_font' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn/font.rb:58:in `font' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-pdf-2.3.15/lib/asciidoctor/pdf/ext/prawn/extensions.rb:329:in `font' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-pdf-2.3.15/lib/asciidoctor/pdf/converter.rb:4559:in `theme_font' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-pdf-2.3.15/lib/asciidoctor/pdf/converter.rb:2041:in `block in convert_table' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-pdf-2.3.15/lib/asciidoctor/pdf/converter.rb:4561:in `block in theme_font' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn/font.rb:60:in `block in font' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn/font.rb:214:in `save_font' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn/font.rb:58:in `font' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-pdf-2.3.15/lib/asciidoctor/pdf/ext/prawn/extensions.rb:329:in `font' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-pdf-2.3.15/lib/asciidoctor/pdf/converter.rb:4559:in `theme_font' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-pdf-2.3.15/lib/asciidoctor/pdf/converter.rb:2033:in `convert_table' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-pdf-2.3.15/lib/asciidoctor/pdf/converter.rb:152:in `convert' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-2.0.22/lib/asciidoctor/abstract_block.rb:76:in `convert' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-2.0.22/lib/asciidoctor/abstract_block.rb:85:in `block in content' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-2.0.22/lib/asciidoctor/abstract_block.rb:85:in `map' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-2.0.22/lib/asciidoctor/abstract_block.rb:85:in `content' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-2.0.22/lib/asciidoctor/document.rb:1012:in `content' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-pdf-2.3.15/lib/asciidoctor/pdf/converter.rb:2406:in `traverse' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-pdf-2.3.15/lib/asciidoctor/pdf/converter.rb:297:in `block in convert_document' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-pdf-2.3.15/lib/asciidoctor/pdf/converter.rb:626:in `indent_section' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-pdf-2.3.15/lib/asciidoctor/pdf/converter.rb:201:in `convert_document' from /Users//pdf-report/.devenv/state/.bundle/ruby/3.1.0/gems/asciidoctor-pdf-2.3.15/lib/asciidoctor/pdf/converter.rb:152:in `convert' from /Userpdf-report/.devenvnt' /Users//devt/.devenv/state/.bms/asciidoctor-pdfctor/pdf/convertert_table' /Users/jpreport/.devenv/sta.0/gems/asciidoctociidoctor/pdf/convnvert' /Users//port/.devenv/state/gems/asciidoctor-tor/abstract_block /Users//dev/hodevenv/state/.bundasciidoctor-2.0.22stract_block.rb:85nt' /Users//devt/.devenv/state/.bms/asciidoctor-2.0/abstract_block.rb//state/.bundle/rubyctor-2.0.22/lib/asblock.rb:85:in `coev//pdf-re.bundle/ruby/3.1.0.0.22/lib/asciidoc2:in `content' /Usd/pdf-report/.deveby/3.1.0/gems/ascilib/asciidoctor/pd:in `traverse' /Usd/pdf-report/.deveby/3.1.0/gems/ascilib/asciidoctor/pdin `block in conve//state/.bundle/rubyctor-pdf-2.3.15/lionverter.rb:626:inUsers//dev/hochvenv/state/.bundleciidoctor-pdf-2.3.pdf/converter.rb:2ment' /Users//dort/.devenv/state/gems/asciidoctor-pdoctor/pdf/convertrt' /Users//devt/.devenv/state/.bms/asciidoctor-2.0/document.rb:956:i/ptate/.bundle/ruby/tor-2.0.22/lib/asc:118:in `convert' land/pdf-report/.d/ruby/3.1.0/gems/aib/asciidoctor/conck in convert_filechland/pdf-report/le/ruby/3.1.0/gems/lib/asciidoctor/cidoctor-pdf-2.3.15/lib/asciidoctor/pdf/converter.rb:20 ```
divinity666 commented 1 month ago

Thanks for your error report. I could reproduce the problem and fixed it.

I will release a new version soon.

divinity666 commented 1 month ago

Issue is solved in 0.7.0. Let me know, if this case can be closed.

JenSeReal commented 1 month ago

Works as expected. Thank you so much for your help and this project 👍