ruby-grafana-reporter 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +185 -180
  3. data/lib/VERSION.rb +2 -2
  4. data/lib/grafana/abstract_datasource.rb +32 -12
  5. data/lib/grafana/errors.rb +1 -9
  6. data/lib/grafana/grafana.rb +3 -7
  7. data/lib/grafana/graphite_datasource.rb +6 -0
  8. data/lib/grafana/prometheus_datasource.rb +6 -0
  9. data/lib/grafana/sql_datasource.rb +6 -0
  10. data/lib/grafana/unsupported_datasource.rb +7 -0
  11. data/lib/grafana/webrequest.rb +1 -1
  12. data/lib/grafana_reporter/abstract_query.rb +20 -62
  13. data/lib/grafana_reporter/abstract_report.rb +66 -15
  14. data/lib/grafana_reporter/alerts_table_query.rb +5 -5
  15. data/lib/grafana_reporter/annotations_table_query.rb +4 -4
  16. data/lib/grafana_reporter/application/application.rb +10 -16
  17. data/lib/grafana_reporter/application/webservice.rb +34 -10
  18. data/lib/grafana_reporter/asciidoctor/alerts_table_include_processor.rb +5 -5
  19. data/lib/grafana_reporter/asciidoctor/annotations_table_include_processor.rb +5 -5
  20. data/lib/grafana_reporter/asciidoctor/panel_image_block_macro.rb +2 -1
  21. data/lib/grafana_reporter/asciidoctor/panel_image_inline_macro.rb +7 -5
  22. data/lib/grafana_reporter/asciidoctor/panel_property_inline_macro.rb +2 -1
  23. data/lib/grafana_reporter/asciidoctor/panel_query_table_include_processor.rb +6 -5
  24. data/lib/grafana_reporter/asciidoctor/panel_query_value_inline_macro.rb +5 -5
  25. data/lib/grafana_reporter/asciidoctor/processor_mixin.rb +43 -2
  26. data/lib/grafana_reporter/asciidoctor/report.rb +17 -41
  27. data/lib/grafana_reporter/asciidoctor/sql_table_include_processor.rb +4 -4
  28. data/lib/grafana_reporter/asciidoctor/sql_value_inline_macro.rb +4 -4
  29. data/lib/grafana_reporter/configuration.rb +14 -2
  30. data/lib/grafana_reporter/console_configuration_wizard.rb +2 -10
  31. data/lib/grafana_reporter/demo_report_wizard.rb +16 -2
  32. data/lib/grafana_reporter/erb/report.rb +43 -0
  33. data/lib/grafana_reporter/errors.rb +9 -1
  34. data/lib/grafana_reporter/help.rb +1 -5
  35. data/lib/grafana_reporter/logger/{two_way_logger.rb → two_way_delegate_logger.rb} +0 -0
  36. data/lib/grafana_reporter/panel_image_query.rb +2 -2
  37. data/lib/grafana_reporter/query_value_query.rb +4 -4
  38. data/lib/ruby_grafana_extension.rb +8 -0
  39. data/lib/ruby_grafana_reporter.rb +13 -0
  40. metadata +9 -6
@@ -6,9 +6,12 @@ module GrafanaReporter
6
6
  # make use of `webrick` or similar, so that it can be used without futher dependencies
7
7
  # in conjunction with the standard asciidoctor docker container.
8
8
  class Webservice
9
+ # Array of possible webservice running states
10
+ STATUS = %I[stopped running stopping].freeze
11
+
9
12
  def initialize
10
13
  @reports = []
11
- @running = false
14
+ @status = :stopped
12
15
  end
13
16
 
14
17
  # Runs the webservice with the given {Configuration} object.
@@ -19,17 +22,32 @@ module GrafanaReporter
19
22
  # start webserver
20
23
  @server = TCPServer.new(@config.webserver_port)
21
24
  @logger.info("Server listening on port #{@config.webserver_port}...")
22
- @running = true
23
25
 
24
26
  @progress_reporter = Thread.new {}
25
27
 
28
+ @status = :running
26
29
  accept_requests_loop
27
- @running = false
30
+ @status = :stopped
31
+ end
32
+
33
+ # @return True, if webservice is stopped, false otherwise
34
+ def stopped?
35
+ @status == :stopped
28
36
  end
29
37
 
30
38
  # @return True, if webservice is up and running, false otherwise
31
39
  def running?
32
- @running
40
+ @status == :running
41
+ end
42
+
43
+ # Forces stopping the webservice.
44
+ def stop!
45
+ @status = :stopping
46
+
47
+ # invoke a new request, so that the webservice stops.
48
+ socket = TCPSocket.new('localhost', @config.webserver_port)
49
+ socket.send '', 0
50
+ socket.close
33
51
  end
34
52
 
35
53
  private
@@ -39,6 +57,14 @@ module GrafanaReporter
39
57
  # step 1) accept incoming connection
40
58
  socket = @server.accept
41
59
 
60
+ # TODO: shutdown properly on SIGINT/SIGHUB
61
+
62
+ # stop webservice properly, if shall be shutdown
63
+ if @status == :stopping
64
+ socket.close
65
+ break
66
+ end
67
+
42
68
  # step 2) print the request headers (separated by a blank line e.g. \r\n)
43
69
  request = ''
44
70
  line = ''
@@ -57,9 +83,6 @@ module GrafanaReporter
57
83
  rescue WebserviceUnknownPathError => e
58
84
  @logger.debug(e.message)
59
85
  socket.write http_response(404, '', e.message)
60
- rescue MissingTemplateError => e
61
- @logger.error(e.message)
62
- socket.write http_response(400, 'Bad Request', e.message)
63
86
  rescue WebserviceGeneralRenderingError => e
64
87
  @logger.fatal(e.message)
65
88
  socket.write http_response(400, 'Bad Request', e.message)
@@ -179,7 +202,7 @@ module GrafanaReporter
179
202
 
180
203
  def render_report(attrs)
181
204
  # build report
182
- template_file = "#{@config.templates_folder}#{attrs['var-template']}.adoc"
205
+ template_file = "#{@config.templates_folder}#{attrs['var-template']}"
183
206
 
184
207
  file = Tempfile.new('gf_pdf_', @config.reports_folder)
185
208
  begin
@@ -188,9 +211,10 @@ module GrafanaReporter
188
211
  @logger.debug("File permissions could not be set for #{file.path}: #{e.message}")
189
212
  end
190
213
 
191
- report = @config.report_class.new(@config, template_file, file, attrs)
214
+ report = @config.report_class.new(@config)
215
+ Thread.report_on_exception = false
192
216
  Thread.new do
193
- report.create_report
217
+ report.create_report(template_file, file, attrs)
194
218
  end
195
219
  @reports << report
196
220
 
@@ -31,11 +31,11 @@ module GrafanaReporter
31
31
  #
32
32
  # +to+ - 'to' time for the sql query
33
33
  #
34
- # +format+ - see {QueryMixin#format_columns}
34
+ # +format+ - see {AbstractQuery#format_columns}
35
35
  #
36
- # +replace_values+ - see {QueryMixin#replace_values}
36
+ # +replace_values+ - see {AbstractQuery#replace_values}
37
37
  #
38
- # +filter_columns+ - see {QueryMixin#filter_columns}
38
+ # +filter_columns+ - see {AbstractQuery#filter_columns}
39
39
  class AlertsTableIncludeProcessor < ::Asciidoctor::Extensions::IncludeProcessor
40
40
  include ProcessorMixin
41
41
 
@@ -56,12 +56,12 @@ module GrafanaReporter
56
56
  " dashboard: #{dashboard_id}, panel: #{panel_id})")
57
57
 
58
58
  query = AlertsTableQuery.new(@report.grafana(instance))
59
- query.set_defaults_from_dashboard(@report.grafana(instance).dashboard(dashboard_id)) if dashboard_id
59
+ assign_dashboard_defaults(query, @report.grafana(instance).dashboard(dashboard_id)) if dashboard_id
60
60
  defaults = {}
61
61
  defaults['dashboardId'] = dashboard_id if dashboard_id
62
62
  defaults['panelId'] = panel_id if panel_id
63
63
 
64
- query.merge_hash_variables(doc.attributes, attrs)
64
+ assign_doc_and_item_variables(query, doc.attributes, attrs)
65
65
  selected_attrs = attrs.select do |k, _v|
66
66
  k =~ /(?:columns|limit|folderId|dashboardId|panelId|dahboardTag|dashboardQuery|state|query)/x
67
67
  end
@@ -31,11 +31,11 @@ module GrafanaReporter
31
31
  #
32
32
  # +to+ - 'to' time for the sql query
33
33
  #
34
- # +format+ - see {QueryMixin#format_columns}
34
+ # +format+ - see {AbstractQuery#format_columns}
35
35
  #
36
- # +replace_values+ - see {QueryMixin#replace_values}
36
+ # +replace_values+ - see {AbstractQuery#replace_values}
37
37
  #
38
- # +filter_columns+ - see {QueryMixin#filter_columns}
38
+ # +filter_columns+ - see {AbstractQuery#filter_columns}
39
39
  class AnnotationsTableIncludeProcessor < ::Asciidoctor::Extensions::IncludeProcessor
40
40
  include ProcessorMixin
41
41
 
@@ -55,12 +55,12 @@ module GrafanaReporter
55
55
  @report.logger.debug("Processing AnnotationsTableIncludeProcessor (instance: #{instance})")
56
56
 
57
57
  query = AnnotationsTableQuery.new(@report.grafana(instance))
58
- query.set_defaults_from_dashboard(@report.grafana(instance).dashboard(dashboard_id)) if dashboard_id
58
+ assign_dashboard_defaults(query, @report.grafana(instance).dashboard(dashboard_id)) if dashboard_id
59
59
  defaults = {}
60
60
  defaults['dashboardId'] = dashboard_id if dashboard_id
61
61
  defaults['panelId'] = panel_id if panel_id
62
62
 
63
- query.merge_hash_variables(doc.attributes, attrs)
63
+ assign_doc_and_item_variables(query, doc.attributes, attrs)
64
64
  selected_attrs = attrs.select do |k, _v|
65
65
  k =~ /(?:columns|limit|alertId|dashboardId|panelId|userId|type|tags)/
66
66
  end
@@ -47,7 +47,8 @@ module GrafanaReporter
47
47
 
48
48
  begin
49
49
  query = PanelImageQuery.new(@report.grafana(instance).dashboard(dashboard).panel(target))
50
- query.merge_hash_variables(parent.document.attributes, attrs)
50
+ assign_dashboard_defaults(query, @report.grafana(instance).dashboard(dashboard))
51
+ assign_doc_and_item_variables(query, parent.document.attributes, attrs)
51
52
  @report.logger.debug("from: #{query.from}, to: #{query.to}")
52
53
 
53
54
  image = query.execute
@@ -44,13 +44,15 @@ module GrafanaReporter
44
44
  dashboard = attrs['dashboard'] || parent.document.attr('grafana_default_dashboard')
45
45
  @report.logger.debug("Processing PanelImageInlineMacro (instance: #{instance}, dashboard: #{dashboard},"\
46
46
  " panel: #{target})")
47
- query = PanelImageQuery.new(@report.grafana(instance).dashboard(dashboard).panel(target))
48
- # set alt text to a default, because otherwise asciidoctor fails
49
- attrs['alt'] = '' unless attrs['alt']
50
- query.merge_hash_variables(parent.document.attributes, attrs)
51
- @report.logger.debug("from: #{query.from}, to: #{query.to}")
52
47
 
53
48
  begin
49
+ query = PanelImageQuery.new(@report.grafana(instance).dashboard(dashboard).panel(target))
50
+ # set alt text to a default, because otherwise asciidoctor fails
51
+ attrs['alt'] = '' unless attrs['alt']
52
+ assign_dashboard_defaults(query, @report.grafana(instance).dashboard(dashboard))
53
+ assign_doc_and_item_variables(query, parent.document.attributes, attrs)
54
+ @report.logger.debug("from: #{query.from}, to: #{query.to}")
55
+
54
56
  image = query.execute
55
57
  image_path = @report.save_image_file(image)
56
58
  rescue GrafanaReporterError => e
@@ -40,7 +40,8 @@ module GrafanaReporter
40
40
  begin
41
41
  query = PanelPropertyQuery.new(@report.grafana(instance).dashboard(dashboard).panel(target))
42
42
  query.raw_query = { property_name: attrs[:field] }
43
- query.merge_hash_variables(parent.document.attributes, attrs)
43
+ assign_dashboard_defaults(query, @report.grafana(instance).dashboard(dashboard))
44
+ assign_doc_and_item_variables(query, parent.document.attributes, attrs)
44
45
  @report.logger.debug("from: #{query.from}, to: #{query.to}")
45
46
 
46
47
  description = query.execute
@@ -32,11 +32,11 @@ module GrafanaReporter
32
32
  #
33
33
  # +to+ - 'to' time for the sql query
34
34
  #
35
- # +format+ - see {QueryMixin#format_columns}
35
+ # +format+ - see {AbstractQuery#format_columns}
36
36
  #
37
- # +replace_values+ - see {QueryMixin#replace_values}
37
+ # +replace_values+ - see {AbstractQuery#replace_values}
38
38
  #
39
- # +filter_columns+ - see {QueryMixin#filter_columns}
39
+ # +filter_columns+ - see {AbstractQuery#filter_columns}
40
40
  class PanelQueryTableIncludeProcessor < ::Asciidoctor::Extensions::IncludeProcessor
41
41
  include ProcessorMixin
42
42
 
@@ -51,6 +51,7 @@ module GrafanaReporter
51
51
 
52
52
  @report.next_step
53
53
  panel_id = target.split(':')[1]
54
+ # TODO: check if instance and dashboard shouldn't be set in assign_doc_and_item_variables method
54
55
  instance = attrs['instance'] || doc.attr('grafana_default_instance') || 'default'
55
56
  dashboard = attrs['dashboard'] || doc.attr('grafana_default_dashboard')
56
57
  attrs['result_type'] = 'panel_table'
@@ -60,8 +61,8 @@ module GrafanaReporter
60
61
  begin
61
62
  panel = @report.grafana(instance).dashboard(dashboard).panel(panel_id)
62
63
  query = QueryValueQuery.new(panel)
63
- query.set_defaults_from_dashboard(panel.dashboard)
64
- query.merge_hash_variables(doc.attributes, attrs)
64
+ assign_dashboard_defaults(query, panel.dashboard)
65
+ assign_doc_and_item_variables(query, doc.attributes, attrs)
65
66
  @report.logger.debug("from: #{query.from}, to: #{query.to}")
66
67
 
67
68
  reader.unshift_lines query.execute
@@ -32,11 +32,11 @@ module GrafanaReporter
32
32
  #
33
33
  # +to+ - 'to' time for the sql query
34
34
  #
35
- # +format+ - see {QueryMixin#format_columns}
35
+ # +format+ - see {AbstractQuery#format_columns}
36
36
  #
37
- # +replace_values+ - see {QueryMixin#replace_values}
37
+ # +replace_values+ - see {AbstractQuery#replace_values}
38
38
  #
39
- # +filter_columns+ - see {QueryMixin#filter_columns}
39
+ # +filter_columns+ - see {AbstractQuery#filter_columns}
40
40
  class PanelQueryValueInlineMacro < ::Asciidoctor::Extensions::InlineMacroProcessor
41
41
  include ProcessorMixin
42
42
  use_dsl
@@ -57,8 +57,8 @@ module GrafanaReporter
57
57
  begin
58
58
  panel = @report.grafana(instance).dashboard(dashboard).panel(target)
59
59
  query = QueryValueQuery.new(panel)
60
- query.set_defaults_from_dashboard(panel.dashboard)
61
- query.merge_hash_variables(parent.document.attributes, attrs)
60
+ assign_dashboard_defaults(query, panel.dashboard)
61
+ assign_doc_and_item_variables(query, parent.document.attributes, attrs)
62
62
  @report.logger.debug("from: #{query.from}, to: #{query.to}")
63
63
 
64
64
  create_inline(parent, :quoted, query.execute)
@@ -12,12 +12,53 @@ module GrafanaReporter
12
12
  self
13
13
  end
14
14
 
15
- # This method is called if a demo report shall be built for the given {Panel}.
16
- # @param panel [Panel] panel object, for which a demo entry shall be created.
15
+ # This method is called if a demo report shall be built for the given {Grafana::Panel}.
16
+ # @param panel [Grafana::Panel] panel object, for which a demo entry shall be created.
17
17
  # @return [String] String containing the entry, or nil if not possible for given panel
18
18
  def build_demo_entry(panel)
19
19
  raise NotImplementedError
20
20
  end
21
+
22
+ # Sets default configurations from the given {Grafana::Dashboard} and store them as settings in the
23
+ # {AbstractQuery}.
24
+ #
25
+ # Following data is extracted:
26
+ # - +from+, by {Grafana::Dashboard#from_time}
27
+ # - +to+, by {Grafana::Dashboard#to_time}
28
+ # - and all variables as {Grafana::Variable}, prefixed with +var-+, as grafana also does it
29
+ # @param query [AbstractQuery] query object, for which the defaults are set
30
+ # @param dashboard [Grafana::Dashboard] dashboard from which the defaults are captured
31
+ # TODO: assign_dashboard_defaults is a common method for all report classes - move it to a public place
32
+ def assign_dashboard_defaults(query, dashboard)
33
+ query.from = dashboard.from_time
34
+ query.to = dashboard.to_time
35
+ dashboard.variables.each { |item| query.assign_variable("var-#{item.name}", item) }
36
+ end
37
+
38
+ # Merges the given hashes to the given query object. It respects the priorities of the hashes and the
39
+ # object and allows only valid variables to be passed.
40
+ # @param query [AbstractQuery] query object, for which the defaults are set
41
+ # @param document_hash [Hash] variables from report template level
42
+ # @param item_hash [Hash] variables from item configuration level, i.e. specific call, which may override document
43
+ # @return [void]
44
+ def assign_doc_and_item_variables(query, document_hash, item_hash)
45
+ sel_doc_items = document_hash.select do |k, _v|
46
+ k =~ /^var-/ || k =~ /grafana_default_(?:from|to)_timezone/
47
+ end
48
+ sel_doc_items.each { |k, v| query.assign_variable(k, ::Grafana::Variable.new(v)) }
49
+ query.assign_variable('grafana_report_timestamp', ::Grafana::Variable.new(document_hash['localdatetime']))
50
+
51
+ sel_items = item_hash.select do |k, _v|
52
+ # TODO: specify accepted options in each class or check if simply all can be allowed with prefix +var-+
53
+ k =~ /^var-/ || k =~ /^render-/ || k =~ /filter_columns|format|replace_values_.*|transpose|column_divider|
54
+ row_divider|from_timezone|to_timezone|result_type|query/x
55
+ end
56
+ sel_items.each { |k, v| query.assign_variable(k, ::Grafana::Variable.new(v)) }
57
+
58
+ query.timeout = item_hash['timeout'] || document_hash['grafana-default-timeout'] || query.timeout
59
+ query.from = item_hash['from'] || document_hash['from'] || query.from
60
+ query.to = item_hash['to'] || document_hash['to'] || query.to
61
+ end
21
62
  end
22
63
  end
23
64
  end
@@ -6,22 +6,18 @@ module GrafanaReporter
6
6
  # Implementation of a specific {AbstractReport}. It is used to
7
7
  # build reports specifically for asciidoctor results.
8
8
  class Report < ::GrafanaReporter::AbstractReport
9
- # (see AbstractReport#initialize)
10
- def initialize(config, template, destination_file_or_path = nil, custom_attributes = {})
9
+ # @see AbstractReport#initialize
10
+ def initialize(config)
11
11
  super
12
- @current_pos = 0
13
12
  @image_files = []
14
- @grafana_instances = {}
15
13
  end
16
14
 
17
- # Starts to create an asciidoctor report. It utilizes all {Extensions} to
18
- # realize the conversion.
15
+ # Starts to create an asciidoctor report. It utilizes all extensions in the {GrafanaReporter::Asciidoctor}
16
+ # namespace to realize the conversion.
19
17
  # @see AbstractReport#create_report
20
- # @return [void]
21
- def create_report
18
+ def create_report(template, destination_file_or_path = nil, custom_attributes = {})
22
19
  super
23
20
  attrs = { 'convert-backend' => 'pdf' }.merge(@config.default_document_attributes.merge(@custom_attributes))
24
- attrs['grafana-report-timestamp'] = @start_time.to_s
25
21
  logger.debug("Document attributes: #{attrs}")
26
22
 
27
23
  initialize_step_counter
@@ -87,37 +83,17 @@ module GrafanaReporter
87
83
  end
88
84
 
89
85
  clean_image_files
86
+ rescue MissingTemplateError => e
87
+ @logger.error(e.message)
88
+ @error = [e.message]
90
89
  done!
90
+ raise e
91
91
  rescue StandardError => e
92
92
  # catch all errors during execution
93
93
  died_with_error(e)
94
94
  raise e
95
- end
96
-
97
- # @see AbstractReport#progress
98
- # @return [Float] number between 0 and 1 reflecting the current progress.
99
- def progress
100
- return 0 if @total_steps.to_i.zero?
101
-
102
- @current_pos.to_f / @total_steps
103
- end
104
-
105
- # @param instance [String] requested grafana instance
106
- # @return [Grafana::Grafana] the requested grafana instance.
107
- def grafana(instance)
108
- unless @grafana_instances[instance]
109
- @grafana_instances[instance] = ::Grafana::Grafana.new(@config.grafana_host(instance),
110
- @config.grafana_api_key(instance),
111
- logger: @logger)
112
- end
113
- @grafana_instances[instance]
114
- end
115
-
116
- # Increments the progress.
117
- # @return [Integer] number of the current progress position.
118
- def next_step
119
- @current_pos += 1
120
- @current_pos
95
+ ensure
96
+ done!
121
97
  end
122
98
 
123
99
  # Called to save a temporary image file. After the final generation of the
@@ -126,6 +102,7 @@ module GrafanaReporter
126
102
  # @return [String] path to the temporary file.
127
103
  def save_image_file(img_data)
128
104
  file = Tempfile.new(['gf_image_', '.png'], @config.images_folder.to_s)
105
+ file.binmode
129
106
  file.write(img_data)
130
107
  path = file.path.gsub(/#{@config.images_folder}/, '')
131
108
 
@@ -135,12 +112,11 @@ module GrafanaReporter
135
112
  path
136
113
  end
137
114
 
138
- # Called, if the report generation has died with an error.
139
- # @param error [StandardError] occured error
140
- # @return [void]
141
- def died_with_error(error)
142
- @error = [error.message] << [error.backtrace]
143
- done!
115
+ # @see AbstractReport#demo_report_classes
116
+ def self.demo_report_classes
117
+ [AlertsTableIncludeProcessor, AnnotationsTableIncludeProcessor, PanelImageBlockMacro, PanelImageInlineMacro,
118
+ PanelPropertyInlineMacro, PanelQueryTableIncludeProcessor, PanelQueryValueInlineMacro,
119
+ SqlTableIncludeProcessor, SqlValueInlineMacro, ShowHelpIncludeProcessor, ShowEnvironmentIncludeProcessor]
144
120
  end
145
121
 
146
122
  private
@@ -26,11 +26,11 @@ module GrafanaReporter
26
26
  #
27
27
  # +to+ - 'to' time for the sql query
28
28
  #
29
- # +format+ - see {QueryMixin#format_columns}
29
+ # +format+ - see {AbstractQuery#format_columns}
30
30
  #
31
- # +replace_values+ - see {QueryMixin#replace_values}
31
+ # +replace_values+ - see {AbstractQuery#replace_values}
32
32
  #
33
- # +filter_columns+ - see {QueryMixin#filter_columns}
33
+ # +filter_columns+ - see {AbstractQuery#filter_columns}
34
34
  class SqlTableIncludeProcessor < ::Asciidoctor::Extensions::IncludeProcessor
35
35
  include ProcessorMixin
36
36
 
@@ -54,7 +54,7 @@ module GrafanaReporter
54
54
  query = QueryValueQuery.new(@report.grafana(instance))
55
55
  query.datasource = @report.grafana(instance).datasource_by_id(target.split(':')[1].to_i)
56
56
  query.raw_query = attrs['sql']
57
- query.merge_hash_variables(doc.attributes, attrs)
57
+ assign_doc_and_item_variables(query, doc.attributes, attrs)
58
58
  @report.logger.debug("from: #{query.from}, to: #{query.to}")
59
59
 
60
60
  reader.unshift_lines query.execute
@@ -26,11 +26,11 @@ module GrafanaReporter
26
26
  #
27
27
  # +to+ - 'to' time for the sql query
28
28
  #
29
- # +format+ - see {QueryMixin#format_columns}
29
+ # +format+ - see {AbstractQuery#format_columns}
30
30
  #
31
- # +replace_values+ - see {QueryMixin#replace_values}
31
+ # +replace_values+ - see {AbstractQuery#replace_values}
32
32
  #
33
- # +filter_columns+ - see {QueryMixin#filter_columns}
33
+ # +filter_columns+ - see {AbstractQuery#filter_columns}
34
34
  class SqlValueInlineMacro < ::Asciidoctor::Extensions::InlineMacroProcessor
35
35
  include ProcessorMixin
36
36
  use_dsl
@@ -52,7 +52,7 @@ module GrafanaReporter
52
52
  query = QueryValueQuery.new(@report.grafana(instance))
53
53
  query.datasource = @report.grafana(instance).datasource_by_id(target)
54
54
  query.raw_query = attrs['sql']
55
- query.merge_hash_variables(parent.document.attributes, attrs)
55
+ assign_doc_and_item_variables(query, parent.document.attributes, attrs)
56
56
  @report.logger.debug("from: #{query.from}, to: #{query.to}")
57
57
 
58
58
  create_inline(parent, :quoted, query.execute)