Class: GrafanaReporter::DemoReportWizard
- Inherits:
-
Object
- Object
- GrafanaReporter::DemoReportWizard
- Defined in:
- lib/grafana_reporter/demo_report_wizard.rb
Overview
This class is used to build a demo report based on a real grafana instance. Therefore it checks available grafana dashboards and panels and returns a final template file as string, which can then be used as a template.
Instance Method Summary collapse
-
#build(grafana) ⇒ String
Invokes the build process for the given
grafana
object. -
#initialize(query_classes) ⇒ DemoReportWizard
constructor
A new instance of DemoReportWizard.
Constructor Details
#initialize(query_classes) ⇒ DemoReportWizard
Returns a new instance of DemoReportWizard.
9 10 11 |
# File 'lib/grafana_reporter/demo_report_wizard.rb', line 9 def initialize(query_classes) @query_classes = query_classes end |
Instance Method Details
#build(grafana) ⇒ String
Invokes the build process for the given grafana
object. Progress is printed to STDOUT.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/grafana_reporter/demo_report_wizard.rb', line 17 def build(grafana) results = {} grafana.dashboard_ids.sample(15).each do |dashboard_id| print "Evaluating dashboard '#{dashboard_id}' for building a demo report..." dashboard = grafana.dashboard(dashboard_id) results = evaluate_dashboard(dashboard, @query_classes - results.keys).merge(results) puts "done - #{(@query_classes - results.keys).length} examples to go" break if (@query_classes - results.keys).empty? end if grafana.dashboard_ids.length > 15 && !(@query_classes - results.keys).empty? puts 'Aborting evaluating further dashboards after 15 samples.' end unless (@query_classes - results.keys).empty? puts "For #{(@query_classes - results.keys).length} reporter functionalities no appropriate "\ 'examples could be found in the configured grafana instance.' end format_results(default_result(@query_classes - results.keys).merge(results)) end |