ruby-grafana-reporter 0.1.6

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 (45) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +20 -0
  3. data/README.md +248 -0
  4. data/lib/VERSION.rb +3 -0
  5. data/lib/grafana/abstract_panel_query.rb +20 -0
  6. data/lib/grafana/abstract_query.rb +127 -0
  7. data/lib/grafana/abstract_sql_query.rb +42 -0
  8. data/lib/grafana/dashboard.rb +66 -0
  9. data/lib/grafana/errors.rb +61 -0
  10. data/lib/grafana/grafana.rb +131 -0
  11. data/lib/grafana/panel.rb +39 -0
  12. data/lib/grafana/panel_image_query.rb +49 -0
  13. data/lib/grafana/variable.rb +259 -0
  14. data/lib/grafana_reporter/abstract_report.rb +109 -0
  15. data/lib/grafana_reporter/application/application.rb +229 -0
  16. data/lib/grafana_reporter/application/errors.rb +30 -0
  17. data/lib/grafana_reporter/asciidoctor/alerts_table_query.rb +99 -0
  18. data/lib/grafana_reporter/asciidoctor/annotations_table_query.rb +96 -0
  19. data/lib/grafana_reporter/asciidoctor/errors.rb +37 -0
  20. data/lib/grafana_reporter/asciidoctor/extensions/alerts_table_include_processor.rb +86 -0
  21. data/lib/grafana_reporter/asciidoctor/extensions/annotations_table_include_processor.rb +86 -0
  22. data/lib/grafana_reporter/asciidoctor/extensions/panel_image_block_macro.rb +67 -0
  23. data/lib/grafana_reporter/asciidoctor/extensions/panel_image_inline_macro.rb +65 -0
  24. data/lib/grafana_reporter/asciidoctor/extensions/panel_property_inline_macro.rb +58 -0
  25. data/lib/grafana_reporter/asciidoctor/extensions/panel_query_table_include_processor.rb +75 -0
  26. data/lib/grafana_reporter/asciidoctor/extensions/panel_query_value_inline_macro.rb +70 -0
  27. data/lib/grafana_reporter/asciidoctor/extensions/processor_mixin.rb +18 -0
  28. data/lib/grafana_reporter/asciidoctor/extensions/show_environment_include_processor.rb +41 -0
  29. data/lib/grafana_reporter/asciidoctor/extensions/show_help_include_processor.rb +202 -0
  30. data/lib/grafana_reporter/asciidoctor/extensions/sql_table_include_processor.rb +67 -0
  31. data/lib/grafana_reporter/asciidoctor/extensions/sql_value_inline_macro.rb +65 -0
  32. data/lib/grafana_reporter/asciidoctor/extensions/value_as_variable_include_processor.rb +57 -0
  33. data/lib/grafana_reporter/asciidoctor/panel_first_value_query.rb +32 -0
  34. data/lib/grafana_reporter/asciidoctor/panel_image_query.rb +23 -0
  35. data/lib/grafana_reporter/asciidoctor/panel_property_query.rb +43 -0
  36. data/lib/grafana_reporter/asciidoctor/panel_table_query.rb +36 -0
  37. data/lib/grafana_reporter/asciidoctor/query_mixin.rb +309 -0
  38. data/lib/grafana_reporter/asciidoctor/report.rb +159 -0
  39. data/lib/grafana_reporter/asciidoctor/sql_first_value_query.rb +34 -0
  40. data/lib/grafana_reporter/asciidoctor/sql_table_query.rb +32 -0
  41. data/lib/grafana_reporter/configuration.rb +326 -0
  42. data/lib/grafana_reporter/errors.rb +38 -0
  43. data/lib/grafana_reporter/logger/two_way_logger.rb +52 -0
  44. data/lib/ruby-grafana-reporter.rb +27 -0
  45. metadata +88 -0
@@ -0,0 +1,75 @@
1
+ require_relative 'processor_mixin'
2
+
3
+ module GrafanaReporter
4
+ module Asciidoctor
5
+ module Extensions
6
+ # Implements the hook
7
+ # include::grafana_panel_query_table:<panel_id>[<options>]
8
+ #
9
+ # Returns the results of the SQL query as a asciidoctor table.
10
+ #
11
+ # == Used document parameters
12
+ # +grafana_default_instance+ - name of grafana instance, 'default' if not specified
13
+ #
14
+ # +grafana_default_dashboard+ - uid of grafana default dashboard to use
15
+ #
16
+ # +from+ - 'from' time for the sql query
17
+ #
18
+ # +to+ - 'to' time for the sql query
19
+ #
20
+ # All other variables starting with +var-+ will be used to replace grafana templating strings
21
+ # in the given SQL query.
22
+ #
23
+ # == Supported options
24
+ # +query+ - query letter, which shall be used, e.g. +C+ (*mandatory*)
25
+ #
26
+ # +instance+ - name of grafana instance, 'default' if not specified
27
+ #
28
+ # +dashboard+ - uid of grafana dashboard to use
29
+ #
30
+ # +from+ - 'from' time for the sql query
31
+ #
32
+ # +to+ - 'to' time for the sql query
33
+ #
34
+ # +format+ - see {QueryMixin#format_columns}
35
+ #
36
+ # +replace_values+ - see {QueryMixin#replace_values}
37
+ #
38
+ # +filter_columns+ - see {QueryMixin#filter_columns}
39
+ class PanelQueryTableIncludeProcessor < ::Asciidoctor::Extensions::IncludeProcessor
40
+ include ProcessorMixin
41
+
42
+ # :nodoc:
43
+ def handles?(target)
44
+ target.start_with? 'grafana_panel_query_table:'
45
+ end
46
+
47
+ # :nodoc:
48
+ def process(doc, reader, target, attrs)
49
+ return if @report.cancel
50
+
51
+ @report.next_step
52
+ panel_id = target.split(':')[1]
53
+ instance = attrs['instance'] || doc.attr('grafana_default_instance') || 'default'
54
+ dashboard = attrs['dashboard'] || doc.attr('grafana_default_dashboard')
55
+ @report.logger.debug("Processing PanelQueryTableIncludeProcessor (instance: #{instance}, dashboard: #{dashboard}, panel: #{panel_id}, query: #{attrs['query']})")
56
+ query = PanelTableQuery.new(@report.grafana(instance).dashboard(dashboard).panel(panel_id), attrs['query'])
57
+ query.merge_hash_variables(doc.attributes, attrs)
58
+ @report.logger.debug("from: #{query.from}, to: #{query.to}")
59
+
60
+ begin
61
+ reader.unshift_lines query.execute(@report.grafana(instance))
62
+ rescue GrafanaReporterError => e
63
+ @report.logger.error(e.message)
64
+ reader.unshift_line '|' + e.message
65
+ rescue StandardError => e
66
+ @report.logger.fatal(e.message)
67
+ reader.unshift_line '|' + e.message
68
+ end
69
+
70
+ reader
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,70 @@
1
+ require_relative 'processor_mixin'
2
+
3
+ module GrafanaReporter
4
+ module Asciidoctor
5
+ module Extensions
6
+ # Implements the hook
7
+ # grafana_panel_query_value:<panel_id>[<options>]
8
+ #
9
+ # Returns the first value of the resulting SQL query.
10
+ #
11
+ # == Used document parameters
12
+ # +grafana_default_instance+ - name of grafana instance, 'default' if not specified
13
+ #
14
+ # +grafana_default_dashboard+ - uid of grafana default dashboard to use
15
+ #
16
+ # +from+ - 'from' time for the sql query
17
+ #
18
+ # +to+ - 'to' time for the sql query
19
+ #
20
+ # All other variables starting with +var-+ will be used to replace grafana templating strings
21
+ # in the given SQL query.
22
+ #
23
+ # == Supported options
24
+ # +query+ - query letter, which shall be used, e.g. +C+ (*mandatory*)
25
+ #
26
+ # +instance+ - name of grafana instance, 'default' if not specified
27
+ #
28
+ # +dashboard+ - uid of grafana dashboard to use
29
+ #
30
+ # +from+ - 'from' time for the sql query
31
+ #
32
+ # +to+ - 'to' time for the sql query
33
+ #
34
+ # +format+ - see {QueryMixin#format_columns}
35
+ #
36
+ # +replace_values+ - see {QueryMixin#replace_values}
37
+ #
38
+ # +filter_columns+ - see {QueryMixin#filter_columns}
39
+ class PanelQueryValueInlineMacro < ::Asciidoctor::Extensions::InlineMacroProcessor
40
+ include ProcessorMixin
41
+ use_dsl
42
+
43
+ named :grafana_panel_query_value
44
+
45
+ # :nodoc:
46
+ def process(parent, target, attrs)
47
+ return if @report.cancel
48
+
49
+ @report.next_step
50
+ instance = attrs['instance'] || parent.document.attr('grafana_default_instance') || 'default'
51
+ dashboard = attrs['dashboard'] || parent.document.attr('grafana_default_dashboard')
52
+ @report.logger.debug("Processing PanelQueryValueInlineMacro (instance: #{instance}, dashboard: #{dashboard}, panel: #{target}, query: #{attrs['query']})")
53
+ query = PanelFirstValueQuery.new(@report.grafana(instance).dashboard(dashboard).panel(target), attrs['query'])
54
+ query.merge_hash_variables(parent.document.attributes, attrs)
55
+ @report.logger.debug("from: #{query.from}, to: #{query.to}")
56
+
57
+ begin
58
+ create_inline(parent, :quoted, query.execute(@report.grafana(instance)))
59
+ rescue GrafanaReporterError => e
60
+ @report.logger.error(e.message)
61
+ create_inline(parent, :quoted, e.message)
62
+ rescue StandardError => e
63
+ @report.logger.fatal(e.message)
64
+ create_inline(parent, :quoted, e.message)
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,18 @@
1
+ module GrafanaReporter
2
+ module Asciidoctor
3
+ # The classes within this module implement the interface to asciidoctor. Each class implements a specific extension to
4
+ # asciidoctor.
5
+ module Extensions
6
+ # This module contains common methods for all asciidoctor extensions.
7
+ module ProcessorMixin
8
+ # Used when initializing a object instance, to set the report object, which is currently in progress.
9
+ # @param report [GrafanaReporter::Asciidoctor::Report] current report
10
+ # @return [::Asciidoctor::Extensions::Processor] self
11
+ def current_report(report)
12
+ @report = report
13
+ self
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,41 @@
1
+ module GrafanaReporter
2
+ module Asciidoctor
3
+ module Extensions
4
+ # Implements the hook
5
+ # include::grafana_environment[]
6
+ #
7
+ # Shows all available variables, which are accessible during this run of the asciidoctor
8
+ # grafana reporter in a asciidoctor readable form.
9
+ #
10
+ # This processor is very helpful during report template design, to find out the available
11
+ # variables, that can be accessed.
12
+ #
13
+ # == Used document parameters
14
+ # All, to be listed as the available environment.
15
+ class ShowEnvironmentIncludeProcessor < ::Asciidoctor::Extensions::IncludeProcessor
16
+ include ProcessorMixin
17
+
18
+ # :nodoc:
19
+ def handles?(target)
20
+ target.start_with? 'grafana_environment'
21
+ end
22
+
23
+ # :nodoc:
24
+ def process(doc, reader, _target, _attrs)
25
+ # return if @report.cancel
26
+ @report.next_step
27
+ @report.logger.debug('Processing ShowEnvironmentIncludeProcessor')
28
+
29
+ vars = ['== Accessible Variables',
30
+ '|===']
31
+ doc.attributes.sort.each do |k, v|
32
+ vars << '| `+{' + k.to_s + '}+`' + ' | ' + v.to_s
33
+ end
34
+ vars << '|==='
35
+
36
+ reader.unshift_lines vars
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,202 @@
1
+ module GrafanaReporter
2
+ module Asciidoctor
3
+ module Extensions
4
+ # Implements the hook
5
+ # include::grafana_help[]
6
+ #
7
+ # Shows all available options for the asciidoctor grafana reporter in a asciidoctor readable form.
8
+ #
9
+ # == Used document parameters
10
+ # None
11
+ class ShowHelpIncludeProcessor < ::Asciidoctor::Extensions::IncludeProcessor
12
+ include ProcessorMixin
13
+
14
+ # :nodoc:
15
+ def handles?(target)
16
+ target.start_with? 'grafana_help'
17
+ end
18
+
19
+ # :nodoc:
20
+ def replaces_variables(where = nil)
21
+ "https://grafana.com/docs/grafana/latest/variables/templates-and-variables/#variable-syntax[Grafana variables] will be replaced#{' ' + where.to_s if where}."
22
+ end
23
+
24
+ # :nodoc:
25
+ def process(_doc, reader, _target, _attrs)
26
+ # return if @report.cancel
27
+ @report.next_step
28
+ @report.logger.debug('Processing ShowHelpIncludeProcessor')
29
+
30
+ param_instance = '| `instance="<instance_name>"` | can be used to override global grafana instance, set in the report with `grafana_default_instance`. If nothing is set, the configured grafana instance with name `default` will be used.'
31
+ param_dashboard = '| `dashboard="<dashboard_uid>"` | Specifies the dashboard to be used. If `grafana_default_dashboard` is specified in the report template, this value can be overridden with this option.'
32
+ param_from = '| `from="<from_timestamp>"` | can be used to override default `from` time'
33
+ param_to = '| `to="<to_timestamp>"` | can be used to override default `to` time'
34
+ param_format = '| `format="<format_col1>,<format_col2>,..."` | Specify format in which the results shall be returned, e.g. `%.2f` for only two digit decimals of a float. Several columns are separated by `,`. For details see https://ruby-doc.org/core-2.4.0/Kernel.html#method-i-sprintf[Ruby documentation]. This action is always performed *before* `replace_values`and `filter_columns`.'
35
+ param_replace_values = '| `replace_values="<replace_1>:<with_1>,<replace_2>:<with_2>,..."` | Specify result values which shall be replaced, e.g. `2:OK` will replace query values `2` with value `OK`. Replacing several values is possible by separating by `,`. Matches with regular expressions are also supported, but must be full matches, i.e. have to start with `^` and end with `$`, e.g. `^[012]$:OK`. For details see https://ruby-doc.org/core-2.7.1/Regexp.html#class-Regexp-label-Character+Classes[Ruby Regexp class]. Number replacements can also be performed, e.g. `<8.2` or `<>3`. This action if always performed *after* `format`and *before* `filter_columns`.'
36
+ param_filter_columns = '| `filter_columns="<column_name_1>,<column_name_2>,..."` | Removes specified columns from result. This action is always performed *after* `format` and `replace_values`.'
37
+
38
+ help = "
39
+ == Grafana Reporter Functions
40
+ === `grafana_help`
41
+ [cols=\"~,80\"]
42
+ |===
43
+ | Call | `+include::grafana_help[]+`
44
+ | Description | Shows this information.
45
+ |===
46
+
47
+ === `grafana_environment`
48
+ [cols=\"~,80\"]
49
+ |===
50
+ | Call | `+include::grafana_environment[]+`
51
+ | Description | Shows all available variables in the rendering context which can be used in the document.
52
+ |===
53
+
54
+ === `grafana_alerts`
55
+ [cols=\"~,80\"]
56
+ |===
57
+ | Call | `+grafana_alerts[columns=\"<column_name_1>,<column_name_2>,...\",options]+`
58
+ | Description | Returns a table of active alert states with the specified columns. Valid colums are `id`, `dashboardId`, `dashboardUId`, `dashboardSlug`, `panelId`, `name`, `state`, `newStateDate`, `evalDate`, `evalData` and `executionError` (for details see https://grafana.com/docs/grafana/latest/http_api/alerting/#get-alerts[Grafana Alerting API]).
59
+ |===
60
+ [%autowidth.stretch, options=\"header\"]
61
+ |===
62
+ | Option | Description
63
+ #{param_dashboard} If this option, or the global option `grafana_default_dashboard` is set, the resulting alerts will be limited to this dashboard. To show all alerts in this case, specify `dashboard=\"\"` as option.
64
+ #{param_filter_columns}
65
+ #{param_format}
66
+ #{param_from}
67
+ #{param_instance}
68
+ | `panel=\"<panel_id>\"` | If specified, the resulting alerts are filtered for this panel. This option will only work, if a `dashboard` or `grafana_default_dashboard` is set.
69
+ #{param_replace_values}
70
+ #{param_to}
71
+ |===
72
+ Additionally all query parameters from the https://grafana.com/docs/grafana/latest/http_api/alerting/#get-alerts[Grafana Alerting API], such as `query`, `state`, `limit`, `folderId` and others are supported.
73
+
74
+ === `grafana_annotations`
75
+ [cols=\"~,80\"]
76
+ |===
77
+ | Call | `+grafana_annotations[columns=\"<column_name_1>,<column_name_2>,...\",options]+`
78
+ | Description | Returns a table of all annotations, matching the specified filter criteria and the specified columns. Valid colums are `id`, `alertId`, `dashboardId`, `panelId`, `userId`, `userName`, `newState`, `prevState, `time`, `timeEnd`, `text`, `metric` and `type` (for details see https://grafana.com/docs/grafana/latest/http_api/annotations/#find_annotations[Grafana Annotations API]).
79
+ |===
80
+ [%autowidth.stretch, options=\"header\"]
81
+ |===
82
+ | Option | Description
83
+ #{param_dashboard} If this option, or the global option `grafana_default_dashboard` is set, the resulting annotations will be limited to this dashboard. To show all annotations in this case, specify `dashboard=\"\"` as option.
84
+ #{param_filter_columns}
85
+ #{param_format}
86
+ #{param_from}
87
+ #{param_instance}
88
+ | `panel=\"<panel_id>\"` | If specified, the resulting annotations are filtered for this panel. This option will only work, if a `dashboard` or `grafana_default_dashboard` is set.
89
+ #{param_replace_values}
90
+ #{param_to}
91
+ |===
92
+ Additionally all quer parameters from the https://grafana.com/docs/grafana/latest/http_api/annotations/#find_annotations[Grafana Alerting API], such as `limit`, `alertId`, `panelId` and others are supported.
93
+
94
+ === `grafana_panel_description`
95
+ [cols=\"~,80\"]
96
+ |===
97
+ | Call | `+grafana_panel_description:<panel_id>[\"<type>\",options]+`
98
+ | Description | Returns a description field for the specified panel. `+<type>+` can either be `title` or `description`. #{replaces_variables('in the returned value')}
99
+ |===
100
+ [%autowidth.stretch, options=\"header\"]
101
+ |===
102
+ | Option | Description
103
+ #{param_dashboard}
104
+ #{param_instance}
105
+ |===
106
+
107
+ === `grafana_panel_image`
108
+ [cols=\"~,80\"]
109
+ |===
110
+ | Call Inline | `+grafana_panel_image:<panel_id>[options]+`
111
+ | Call Block | `+grafana_panel_image::<panel_id>[options]+`
112
+ | Description | Includes a panel image as an image in the document. Can be calles for inline-images as well as for blocks.
113
+ |===
114
+ [%autowidth.stretch, options=\"header\"]
115
+ |===
116
+ | Option | Description
117
+ #{param_dashboard}
118
+ #{param_from}
119
+ #{param_instance}
120
+ #{param_to}
121
+ | `render-height=\"<height>\"` | can be used to override default `height` in which the panel shall be rendered
122
+ | `render-width=\"<width>\"` | can be used to override default `width` in which the panel shall be rendered
123
+ | `render-theme=\"<theme>\"` | can be used to override default `theme` in which the panel shall be rendered (`light` by default)
124
+ | `render-timeout=\"<timeout>\"` | can be used to override default `timeout` in which the panel shall be rendered (60 seconds by default)
125
+ |===
126
+
127
+ === `grafana_panel_query_table`
128
+ [cols=\"~,80\"]
129
+ |===
130
+ | Call | `+include:grafana_panel_query_table:<panel_id>[query=\"<query_letter>\",options]+`
131
+ | Description | Returns the results of a query, which is configured in a grafana panel, as a table in asciidoc. `+<query_letter>+` needs to point to the grafana query which shall be evaluated, e.g. `A` or `B`. #{replaces_variables("in the panel's SQL statement")}
132
+ |===
133
+ [%autowidth.stretch, options=\"header\"]
134
+ |===
135
+ | Option | Description
136
+ #{param_dashboard}
137
+ #{param_filter_columns}
138
+ #{param_format}
139
+ #{param_from}
140
+ #{param_instance}
141
+ #{param_replace_values}
142
+ #{param_to}
143
+ |===
144
+
145
+ === `grafana_panel_query_value`
146
+ [cols=\"~,80\"]
147
+ |===
148
+ | Call | `+grafana_panel_query_value:<panel_id>[query=\"<query_letter>\",options]+`
149
+ | Description | Returns the first returned value of in the first column of a query, which is configured in a grafana panel. `+<query_letter>+` needs to point to the grafana query which shall be evaluated, e.g. `A` or `B`. #{replaces_variables("in the panel's SQL statement")}
150
+ |===
151
+ [%autowidth.stretch, options=\"header\"]
152
+ |===
153
+ | Option | Description
154
+ #{param_dashboard}
155
+ #{param_filter_columns}
156
+ #{param_format}
157
+ #{param_from}
158
+ #{param_instance}
159
+ #{param_replace_values}
160
+ #{param_to}
161
+ |===
162
+
163
+ === `grafana_sql_table`
164
+ [cols=\"~,80\"]
165
+ |===
166
+ | Call | `+include::grafana_sql_table:<datasource_id>[sql=\"<sql_query>\",options]+`
167
+ | Description | Returns a table with all results of the given query. #{replaces_variables('in the SQL statement')}
168
+ |===
169
+ [%autowidth.stretch, options=\"header\"]
170
+ |===
171
+ | Option | Description
172
+ #{param_filter_columns}
173
+ #{param_format}
174
+ #{param_from}
175
+ #{param_instance}
176
+ #{param_replace_values}
177
+ #{param_to}
178
+ |===
179
+
180
+ === `grafana_sql_value`
181
+ [cols=\"~,80\"]
182
+ |===
183
+ | Call | `+grafana_sql_value:<datasource_id>[sql=\"<sql_query>\",options]+`
184
+ | Description | Returns a table with all results of the given query. #{replaces_variables('in the SQL statement')}
185
+ |===
186
+ [%autowidth.stretch, options=\"header\"]
187
+ |===
188
+ | Option | Description
189
+ #{param_filter_columns}
190
+ #{param_format}
191
+ #{param_from}
192
+ #{param_instance}
193
+ #{param_replace_values}
194
+ #{param_to}
195
+ |==="
196
+
197
+ reader.unshift_lines help.split("\n")
198
+ end
199
+ end
200
+ end
201
+ end
202
+ end
@@ -0,0 +1,67 @@
1
+ module GrafanaReporter
2
+ module Asciidoctor
3
+ module Extensions
4
+ # Implements the hook
5
+ # include::grafana_sql_table:<datasource_id>[<options>]
6
+ #
7
+ # Returns the results of the SQL query as a asciidoctor table.
8
+ #
9
+ # == Used document parameters
10
+ # +grafana_default_instance+ - name of grafana instance, 'default' if not specified
11
+ #
12
+ # +from+ - 'from' time for the sql query
13
+ #
14
+ # +to+ - 'to' time for the sql query
15
+ #
16
+ # All other variables starting with +var-+ will be used to replace grafana templating strings
17
+ # in the given SQL query.
18
+ #
19
+ # == Supported options
20
+ # +sql+ - sql statement (*mandatory*)
21
+ #
22
+ # +instance+ - name of grafana instance, 'default' if not specified
23
+ #
24
+ # +from+ - 'from' time for the sql query
25
+ #
26
+ # +to+ - 'to' time for the sql query
27
+ #
28
+ # +format+ - see {QueryMixin#format_columns}
29
+ #
30
+ # +replace_values+ - see {QueryMixin#replace_values}
31
+ #
32
+ # +filter_columns+ - see {QueryMixin#filter_columns}
33
+ class SqlTableIncludeProcessor < ::Asciidoctor::Extensions::IncludeProcessor
34
+ include ProcessorMixin
35
+
36
+ # :nodoc:
37
+ def handles?(target)
38
+ target.start_with? 'grafana_sql_table:'
39
+ end
40
+
41
+ # :nodoc:
42
+ def process(doc, reader, target, attrs)
43
+ return if @report.cancel
44
+
45
+ @report.next_step
46
+ instance = attrs['instance'] || doc.attr('grafana_default_instance') || 'default'
47
+ @report.logger.debug("Processing SqlTableIncludeProcessor (instance: #{instance}, datasource: #{target.split(':')[1]}, sql: #{attrs['sql']})")
48
+ query = SqlTableQuery.new(attrs['sql'], target.split(':')[1])
49
+ query.merge_hash_variables(doc.attributes, attrs)
50
+ @report.logger.debug("from: #{query.from}, to: #{query.to}")
51
+
52
+ begin
53
+ reader.unshift_lines query.execute(@report.grafana(instance))
54
+ rescue GrafanaReporterError => e
55
+ @report.logger.error(e.message)
56
+ reader.unshift_line '|' + e.message
57
+ rescue StandardError => e
58
+ @report.logger.fatal(e.message)
59
+ reader.unshift_line '|' + e.message
60
+ end
61
+
62
+ reader
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end