ruby-grafana-reporter 0.3.0 → 0.4.0

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 (78) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +81 -71
  3. data/bin/ruby-grafana-reporter +5 -5
  4. data/lib/VERSION.rb +3 -2
  5. data/lib/grafana/abstract_datasource.rb +116 -0
  6. data/lib/grafana/dashboard.rb +1 -3
  7. data/lib/grafana/errors.rb +15 -0
  8. data/lib/grafana/grafana.rb +53 -56
  9. data/lib/grafana/grafana_alerts_datasource.rb +57 -0
  10. data/lib/grafana/grafana_annotations_datasource.rb +56 -0
  11. data/lib/grafana/grafana_property_datasource.rb +25 -0
  12. data/lib/grafana/graphite_datasource.rb +44 -0
  13. data/lib/grafana/image_rendering_datasource.rb +44 -0
  14. data/lib/grafana/panel.rb +9 -3
  15. data/lib/grafana/prometheus_datasource.rb +39 -0
  16. data/lib/grafana/sql_datasource.rb +65 -0
  17. data/lib/grafana/variable.rb +1 -0
  18. data/lib/grafana/webrequest.rb +71 -0
  19. data/lib/grafana_reporter/abstract_query.rb +401 -0
  20. data/lib/grafana_reporter/abstract_report.rb +54 -3
  21. data/lib/grafana_reporter/alerts_table_query.rb +44 -0
  22. data/lib/grafana_reporter/annotations_table_query.rb +43 -0
  23. data/lib/grafana_reporter/application/application.rb +12 -8
  24. data/lib/grafana_reporter/application/webservice.rb +18 -6
  25. data/lib/grafana_reporter/asciidoctor/alerts_table_include_processor.rb +90 -0
  26. data/lib/grafana_reporter/asciidoctor/annotations_table_include_processor.rb +89 -0
  27. data/lib/grafana_reporter/asciidoctor/panel_image_block_macro.rb +76 -0
  28. data/lib/grafana_reporter/asciidoctor/panel_image_inline_macro.rb +77 -0
  29. data/lib/grafana_reporter/asciidoctor/panel_property_inline_macro.rb +72 -0
  30. data/lib/grafana_reporter/asciidoctor/panel_query_table_include_processor.rb +98 -0
  31. data/lib/grafana_reporter/asciidoctor/panel_query_value_inline_macro.rb +93 -0
  32. data/lib/grafana_reporter/asciidoctor/processor_mixin.rb +23 -0
  33. data/lib/grafana_reporter/asciidoctor/report.rb +24 -31
  34. data/lib/grafana_reporter/asciidoctor/show_environment_include_processor.rb +46 -0
  35. data/lib/grafana_reporter/asciidoctor/show_help_include_processor.rb +35 -0
  36. data/lib/grafana_reporter/asciidoctor/sql_table_include_processor.rb +92 -0
  37. data/lib/grafana_reporter/asciidoctor/sql_value_inline_macro.rb +88 -0
  38. data/lib/grafana_reporter/asciidoctor/value_as_variable_include_processor.rb +90 -0
  39. data/lib/grafana_reporter/configuration.rb +12 -6
  40. data/lib/grafana_reporter/console_configuration_wizard.rb +115 -65
  41. data/lib/grafana_reporter/demo_report_wizard.rb +87 -0
  42. data/lib/grafana_reporter/errors.rb +33 -0
  43. data/lib/grafana_reporter/help.rb +447 -0
  44. data/lib/grafana_reporter/logger/two_way_logger.rb +1 -1
  45. data/lib/grafana_reporter/panel_image_query.rb +29 -0
  46. data/lib/grafana_reporter/panel_property_query.rb +22 -0
  47. data/lib/grafana_reporter/query_value_query.rb +79 -0
  48. data/lib/grafana_reporter/report_webhook.rb +35 -0
  49. data/lib/{ruby-grafana-reporter.rb → ruby_grafana_reporter.rb} +0 -3
  50. metadata +37 -35
  51. data/lib/grafana/abstract_panel_query.rb +0 -22
  52. data/lib/grafana/abstract_query.rb +0 -132
  53. data/lib/grafana/abstract_sql_query.rb +0 -51
  54. data/lib/grafana/panel_image_query.rb +0 -52
  55. data/lib/grafana_reporter/asciidoctor/alerts_table_query.rb +0 -101
  56. data/lib/grafana_reporter/asciidoctor/annotations_table_query.rb +0 -96
  57. data/lib/grafana_reporter/asciidoctor/errors.rb +0 -40
  58. data/lib/grafana_reporter/asciidoctor/extensions/alerts_table_include_processor.rb +0 -92
  59. data/lib/grafana_reporter/asciidoctor/extensions/annotations_table_include_processor.rb +0 -91
  60. data/lib/grafana_reporter/asciidoctor/extensions/panel_image_block_macro.rb +0 -69
  61. data/lib/grafana_reporter/asciidoctor/extensions/panel_image_inline_macro.rb +0 -68
  62. data/lib/grafana_reporter/asciidoctor/extensions/panel_property_inline_macro.rb +0 -61
  63. data/lib/grafana_reporter/asciidoctor/extensions/panel_query_table_include_processor.rb +0 -78
  64. data/lib/grafana_reporter/asciidoctor/extensions/panel_query_value_inline_macro.rb +0 -73
  65. data/lib/grafana_reporter/asciidoctor/extensions/processor_mixin.rb +0 -20
  66. data/lib/grafana_reporter/asciidoctor/extensions/show_environment_include_processor.rb +0 -43
  67. data/lib/grafana_reporter/asciidoctor/extensions/show_help_include_processor.rb +0 -30
  68. data/lib/grafana_reporter/asciidoctor/extensions/sql_table_include_processor.rb +0 -70
  69. data/lib/grafana_reporter/asciidoctor/extensions/sql_value_inline_macro.rb +0 -66
  70. data/lib/grafana_reporter/asciidoctor/extensions/value_as_variable_include_processor.rb +0 -88
  71. data/lib/grafana_reporter/asciidoctor/help.rb +0 -435
  72. data/lib/grafana_reporter/asciidoctor/panel_first_value_query.rb +0 -36
  73. data/lib/grafana_reporter/asciidoctor/panel_image_query.rb +0 -28
  74. data/lib/grafana_reporter/asciidoctor/panel_property_query.rb +0 -44
  75. data/lib/grafana_reporter/asciidoctor/panel_table_query.rb +0 -40
  76. data/lib/grafana_reporter/asciidoctor/query_mixin.rb +0 -312
  77. data/lib/grafana_reporter/asciidoctor/sql_first_value_query.rb +0 -42
  78. data/lib/grafana_reporter/asciidoctor/sql_table_query.rb +0 -44
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GrafanaReporter
4
+ # This class is used to build a demo report based on a real grafana instance. Therefore
5
+ # it checks available grafana dashboards and panels and returns a final template file as
6
+ # string, which can then be used as a template.
7
+ class DemoReportWizard
8
+ # @param query_classes [Array] class objects, for which a demo report shall be created
9
+ def initialize(query_classes)
10
+ @query_classes = query_classes
11
+ end
12
+
13
+ # Invokes the build process for the given +grafana+ object. Progress is printed to
14
+ # STDOUT.
15
+ # @param grafana [Grafana] grafana instance, for which the demo report shall be built
16
+ # @return [String] demo template as string
17
+ def build(grafana)
18
+ results = {}
19
+
20
+ grafana.dashboard_ids.sample(15).each do |dashboard_id|
21
+ print "Evaluating dashboard '#{dashboard_id}' for building a demo report..."
22
+ dashboard = grafana.dashboard(dashboard_id)
23
+
24
+ results = evaluate_dashboard(dashboard, @query_classes - results.keys).merge(results)
25
+
26
+ puts "done - #{(@query_classes - results.keys).length} examples to go"
27
+ break if (@query_classes - results.keys).empty?
28
+ end
29
+ puts 'Aborting evaluating further dashboards after 15 samples.' if grafana.dashboard_ids.length > 15 and !(@query_classes - results.keys).empty?
30
+ puts "For #{(@query_classes - results.keys).length} reporter functionalities no appropriate examples could be found in the configured grafana instance." unless (@query_classes - results.keys).empty?
31
+
32
+ format_results(default_result(@query_classes - results.keys).merge(results))
33
+ end
34
+
35
+ private
36
+
37
+ def default_result(query_classes)
38
+ results = {}
39
+
40
+ query_classes.each do |query_class|
41
+ results[query_class] = "No example found for #{query_class.name} in the dashboards."
42
+ end
43
+
44
+ results
45
+ end
46
+
47
+ def evaluate_dashboard(dashboard, query_classes)
48
+ results = {}
49
+
50
+ dashboard.panels.shuffle.each do |panel|
51
+ query_classes.each do |query_class|
52
+ unless query_class.public_instance_methods.include?(:build_demo_entry)
53
+ results[query_class] = "Method 'build_demo_entry' not implemented for #{query_class.name}"
54
+ next
55
+ end
56
+
57
+ begin
58
+ result = query_class.new.build_demo_entry(panel)
59
+ results[query_class] = result if result
60
+ rescue StandardError => e
61
+ puts "#{e.message}\n#{e.backtrace.join("\n")}"
62
+ end
63
+ end
64
+ end
65
+
66
+ results
67
+ end
68
+
69
+ # TODO: move this method to Asciidoctor::Report
70
+ def format_results(raw_results)
71
+ results = ['= Demo report',
72
+ "Created by `+ruby-grafana-reporter+` version #{GRAFANA_REPORTER_VERSION.join('.')}",
73
+ '== Examples']
74
+
75
+ raw_results.each do |k, v|
76
+ results += if v =~ /^[A-Z]/
77
+ ["=== #{k.to_s.gsub(/.*::/, '')}", v.to_s]
78
+ else
79
+ ["=== #{k.to_s.gsub(/.*::/, '')}", 'Sample call:', " #{v.gsub(/\n/, "\n ")}",
80
+ 'Result:', v.to_s]
81
+ end
82
+ end
83
+
84
+ results.join("\n\n")
85
+ end
86
+ end
87
+ end
@@ -45,4 +45,37 @@ module GrafanaReporter
45
45
  "but was '#{currently}'.")
46
46
  end
47
47
  end
48
+
49
+ # Thrown, if the value configuration in {QueryMixin#replace_values} is
50
+ # invalid.
51
+ class MalformedReplaceValuesStatementError < GrafanaReporterError
52
+ def initialize(statement)
53
+ super("The specified replace_values statement '#{statement}' is invalid. Make sure it contains"\
54
+ " exactly one not escaped ':' symbol.")
55
+ end
56
+ end
57
+
58
+ # Thrown, if a configured parameter is malformed.
59
+ class MalformedAttributeContentError < GrafanaReporterError
60
+ def initialize(message, attribute, content)
61
+ super("The content '#{content}' in attribute '#{attribute}' is malformed: #{message}")
62
+ end
63
+ end
64
+
65
+ # Thrown, if a configured time range is not supported by the reporter.
66
+ #
67
+ # If this happens, most likely the reporter has to implement the new
68
+ # time range definition.
69
+ class TimeRangeUnknownError < GrafanaReporterError
70
+ def initialize(time_range)
71
+ super("The specified time range '#{time_range}' is unknown.")
72
+ end
73
+ end
74
+
75
+ # Thrown, if a mandatory attribute is not set.
76
+ class MissingMandatoryAttributeError < GrafanaReporterError
77
+ def initialize(attribute)
78
+ super("Missing mandatory attribute '#{attribute}'.")
79
+ end
80
+ end
48
81
  end
@@ -0,0 +1,447 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+
5
+ module GrafanaReporter
6
+ # This class generates the functional help documentation for the reporter.
7
+ # It can create the documentation for github markdown, as well as in asciidoctor.
8
+ class Help
9
+ # @param headline_level [Integer] top level of headline
10
+ # @return [String] asciidoctor compatible documentation
11
+ def asciidoctor(headline_level = 2)
12
+ help_text(asciidoctor_options.merge(level: headline_level))
13
+ end
14
+
15
+ # @param headline_level [Integer] top level of headline
16
+ # @return [String] github markdown compatible documentation
17
+ def github(headline_level = 2)
18
+ "#{toc}\n\n#{help_text(github_options.merge(level: headline_level))}"
19
+ end
20
+
21
+ # @see AbstractQuery#self.build_demo_entry
22
+ def self.build_demo_entry(_panel)
23
+ 'include::grafana_help[]'
24
+ end
25
+
26
+ private
27
+
28
+ def github_options
29
+ { headline_separator: '#', code_begin: '`', code_end: '`', table_begin: "\n", head_postfix_col: '| -- ' }
30
+ end
31
+
32
+ def asciidoctor_options
33
+ { headline_separator: '=', code_begin: '`+', code_end: '+`', table_begin: "\n[%autowidth.stretch, "\
34
+ "options=\"header\"]\n|===\n", table_end: "\n|===" }
35
+ end
36
+
37
+ def help_text(opts)
38
+ %(#{opts[:headline_separator] * opts[:level]} Global options
39
+ #{global_options_as_text(opts.merge(level: opts[:level] + 1))}
40
+ #{opts[:headline_separator] * opts[:level]} Functions
41
+ #{functions_as_text(opts.merge(level: opts[:level] + 1))})
42
+ end
43
+
44
+ def toc
45
+ result = []
46
+
47
+ result << 'Table of contents'
48
+ result << '* [Global options](#global-options)'
49
+ prepared_help[:global_options].sort.map do |k, _v|
50
+ result << " * [#{k}](##{k.downcase})"
51
+ end
52
+
53
+ result << '* [Functions](#functions)'
54
+ prepared_help[:functions].sort.map do |k, _v|
55
+ result << " * [#{k}](##{k.downcase})"
56
+ end
57
+
58
+ result.join("\n")
59
+ end
60
+
61
+ def global_options_as_text(opts = {})
62
+ opts = { level: 3 }.merge(opts)
63
+ result = []
64
+
65
+ prepared_help[:global_options].sort.map do |k, v|
66
+ result << %(
67
+ #{opts[:headline_separator] * opts[:level]} #{opts[:code_begin]}#{k}#{opts[:code_end]}
68
+ Usage: #{opts[:code_begin]}#{v['call']}#{opts[:code_end]}
69
+
70
+ #{v['description']}
71
+ )
72
+ end
73
+
74
+ result.join
75
+ end
76
+
77
+ def functions_as_text(opts = {})
78
+ opts = { level: 3, headline_separator: '=' }.merge(opts)
79
+ result = []
80
+
81
+ prepared_help[:functions].sort.map do |k, v|
82
+ result << %(
83
+ #{opts[:headline_separator] * opts[:level]} #{opts[:code_begin]}#{k}#{opts[:code_end]}
84
+ Usage: #{opts[:code_begin]}#{v[:call]}#{opts[:code_end]}
85
+
86
+ #{v[:description]}#{"\n\nSee also: #{v[:see]}" if v[:see]}#{unless v[:options].empty?
87
+ %(
88
+ #{opts[:table_begin]}| Option | Description#{"\n#{opts[:head_postfix_col] * 2}" if opts[:head_postfix_col]}
89
+ #{v[:options].sort.map { |_opt_k, opt_v| "| #{opts[:code_begin]}#{opt_v[:call]}#{opts[:code_end]} | #{opt_v[:description].gsub('|', '\|')}" }.join("\n") }#{opts[:table_end]})
90
+ end}
91
+ )
92
+ end
93
+
94
+ result.join
95
+ end
96
+
97
+ def prepared_help
98
+ yaml = YAML.safe_load(raw_help_yaml)
99
+
100
+ result = {}
101
+ result[:functions] = {}
102
+ result[:global_options] = yaml['global_options']
103
+
104
+ functions = result[:functions]
105
+ std_opts = yaml['standard_options']
106
+ yaml.reject { |k, _v| k =~ /.*_options$/ }.each_key do |key|
107
+ functions[key] = {}
108
+ res_item = functions[key]
109
+ res_item[:options] = {}
110
+
111
+ item = yaml[key]
112
+ res_item[:call] = item['call']
113
+ res_item[:description] = item['description']
114
+ res_item[:see] = item['see']
115
+
116
+ opts = ((item['options'] ? item['options'].keys : [])
117
+ (item['standard_options'] ? item['standard_options'].keys : [])).sort
118
+ opts.each do |opt_key|
119
+ res_item[:options][opt_key] = {}
120
+
121
+ if item['standard_options'].key?(opt_key)
122
+ res_item[:options][opt_key][:call] = std_opts[opt_key]['call']
123
+ res_item[:options][opt_key][:description] = "#{std_opts[opt_key]['description']} "\
124
+ "#{item['standard_options'][opt_key]}".chop
125
+ res_item[:options][opt_key][:see] = std_opts[opt_key]['see'] if std_opts[opt_key]['see']
126
+ else
127
+ res_item[:options][opt_key][:call] = item['options'][opt_key]['call']
128
+ res_item[:options][opt_key][:description] = item['options'][opt_key]['description']
129
+ res_item[:options][opt_key][:see] = item['options'][opt_key]['see'] if item['options'][opt_key]['see']
130
+ end
131
+ end
132
+ end
133
+
134
+ result
135
+ end
136
+
137
+ def raw_help_yaml
138
+ <<~YAML_HELP
139
+ global_options:
140
+ grafana_default_instance:
141
+ call: ":grafana_default_instance: <instance_name>"
142
+ description: >-
143
+ Specifies which grafana instance shall be used. If not set, the grafana instance names `default`
144
+ will be used.
145
+
146
+ grafana_default_dashboard:
147
+ call: ":grafana_default_dashboard: <dashboard_uid>"
148
+ description: >-
149
+ Specifies to which dashboard the queries shall be targeted by default.
150
+
151
+ grafana_default_from_timezone:
152
+ call: ":grafana_default_from_timezone: <timezone>"
153
+ description: Specifies which timezone shall be used for the `from` time, e.g. `CET` or `CEST`.
154
+
155
+ grafana_default_to_timezone:
156
+ call: ":grafana_default_to_timezone: <timezone>"
157
+ description: Specifies which timezone shall be used for the `to` time, e.g. `CET` or `CEST`.
158
+
159
+ from:
160
+ call: ":from: <from_timestamp>"
161
+ description: >-
162
+ Overrides the time setting from grafana. It may contain dates as `now-1M/M`, which will be translated
163
+ properly to timestamps relative to the called time.
164
+
165
+ to:
166
+ call: ":to: <to_timestamp>"
167
+ description: >-
168
+ Overrides the time setting from grafana. It may contain dates as `now-1M/M`, which will be translated
169
+ properly to timestamps relative to the called time.
170
+
171
+ standard_options:
172
+ instance:
173
+ call: instance="<instance_name>"
174
+ description: >-
175
+ can be used to override global grafana instance, set in the report with `grafana_default_instance`.
176
+ If nothing is set, the configured grafana instance with name `default` will be used.
177
+
178
+ dashboard:
179
+ call: dashboard="<dashboard_uid>"
180
+ description: >-
181
+ Specifies the dashboard to be used. If `grafana_default_dashboard` is specified in the report template,
182
+ this value can be overridden with this option.
183
+
184
+ from:
185
+ call: from="<timestamp>"
186
+ description: can be used to override default `from` time
187
+
188
+ from_timezone:
189
+ call: from_timezone="<timezone>"
190
+ description: can be used to override system timezone for `from` time and will also override `grafana_default_from_timezone` option
191
+
192
+ to_timezone:
193
+ call: to_timezone="<timezone>"
194
+ description: can be used to override system timezone for `to` time and will also override `grafana_default_to_timezone` option
195
+
196
+ to:
197
+ call: to="<timestamp>"
198
+ description: can be used to override default `to` time
199
+
200
+ format:
201
+ call: format="<format_col1>,<format_col2>,..."
202
+ description: >-
203
+ Specify format in which the results shall be returned, e.g. `%.2f` for only two digit decimals of a
204
+ float. Several columns are separated by `,`. Execution is applied in the following order `format`,
205
+ `replace_values`, `filter_columns`, `transpose`.
206
+ see: 'https://ruby-doc.org/core-2.4.0/Kernel.html#method-i-sprintf'
207
+
208
+ replace_values:
209
+ call: replace_values="<replace_1>:<with_1>,<replace_2>:<with_2>,..."
210
+ description: >-
211
+ Specify result values which shall be replaced, e.g. `2:OK` will replace query values `2` with value `OK`.
212
+ Replacing several values is possible by separating by `,`. Matches with regular expressions are also
213
+ supported, but must be full matches, i.e. have to start with `^` and end with `$`, e.g. `^[012]$:OK`.
214
+ Number replacements can also be performed, e.g. `<8.2` or `<>3`. Execution is applied in the following order `format`,
215
+ `replace_values`, `filter_columns`, `transpose`.
216
+ see: https://ruby-doc.org/core-2.7.1/Regexp.html#class-Regexp-label-Character+Classes
217
+
218
+ filter_columns:
219
+ call: filter_columns="<column_name_1>,<column_name_2>,..."
220
+ description: >-
221
+ Removes specified columns from result. Execution is applied in the following order `format`, `replace_values`,
222
+ `filter_columns`, `transpose`.
223
+
224
+ transpose:
225
+ call: transpose="true"
226
+ description: >-
227
+ Transposes the query result, i.e. columns become rows and rows become columnns. Execution is applied in the
228
+ following order `format`, `replace_values`, `filter_columns`, `transpose`.
229
+
230
+ column_divider:
231
+ call: column_divider="<divider>"
232
+ description: >-
233
+ Replace the default column divider with another one. Defaults to ` | ` for being interpreted as a asciidoctor column.
234
+
235
+ row_divider:
236
+ call: row_divider="<divider>"
237
+ description: >-
238
+ Replace the default row divider with another one. Defaults to `| ` for being interpreted as a asciidoctor row.
239
+
240
+ timeout:
241
+ call: timeout="<timeout_in_seconds>"
242
+ description: >-
243
+ Set a timeout for the current query. If not overridden with `grafana-default-timeout` in the report template,
244
+ this defaults to 60 seconds.
245
+
246
+ # ----------------------------------
247
+ # FUNCTION DOCUMENTATION STARTS HERE
248
+ # ----------------------------------
249
+
250
+ grafana_help:
251
+ description: Show all available grafana calls within the asciidoctor templates, including available options.
252
+ call: 'include::grafana_help[]'
253
+
254
+ grafana_environment:
255
+ description: Shows all available variables in the rendering context which can be used in the asciidoctor template.
256
+ call: 'include::grafana_environment[]'
257
+
258
+ grafana_alerts:
259
+ description: >-
260
+ Returns a table of active alert states including the specified columns and the connected information. Supports
261
+ all query parameters from the Grafana Alerting API, such as `query`, `state`, `limit`, `folderId` and others.
262
+ call: 'include::grafana_alerts[columns="<column_name_1>,<column_name_2>,...",options]'
263
+ see: https://grafana.com/docs/grafana/latest/http_api/alerting/#get-alerts
264
+ options:
265
+ columns:
266
+ description: >-
267
+ Specifies columns that shall be returned. Valid columns are `id`, `dashboardId`, `dashboardUId`, `dashboardSlug`,
268
+ `panelId`, `name`, `state`, `newStateDate`, `evalDate`, `evalData` and `executionError`.
269
+ call: columns="<column_name_1>,<columns_name_2>,..."
270
+ panel:
271
+ description: >-
272
+ If specified, the resulting alerts are filtered for this panel. This option will only work, if a `dashboard`
273
+ or `grafana_default_dashboard` is set.
274
+ call: panel="<panel_id>"
275
+ standard_options:
276
+ column_divider:
277
+ dashboard: >-
278
+ If this option, or the global option `grafana_default_dashboard` is set, the resulting alerts will be limited to
279
+ this dashboard. To show all alerts in this case, specify `dashboard=""` as option.
280
+ filter_columns:
281
+ format:
282
+ from:
283
+ instance:
284
+ replace_values:
285
+ row_divider:
286
+ timeout:
287
+ to:
288
+ transpose:
289
+ from_timezone:
290
+ to_timezone:
291
+
292
+ grafana_annotations:
293
+ description: >-
294
+ Returns a table of all annotations, matching the specified filter criteria and the specified columns. Supports all
295
+ query parameters from the Grafana Alerting API, such as `limit`, `alertId`, `panelId` and others.
296
+ call: 'include::grafana_annotations[columns="<column_name_1>,<column_name_2>,...",options]'
297
+ see: https://grafana.com/docs/grafana/latest/http_api/annotations/#find_annotations
298
+ options:
299
+ columns:
300
+ description: >-
301
+ Specified the columns that shall be returned. Valid columns are `id`, `alertId`, `dashboardId`, `panelId`, `userId`,
302
+ `userName`, `newState`, `prevState`, `time`, `timeEnd`, `text`, `metric` and `type`.
303
+ call: columns="<column_name_1>,<columns_name_2>,..."
304
+ panel:
305
+ description: >-
306
+ If specified, the resulting alerts are filtered for this panel. This option will only work, if a `dashboard` or
307
+ `grafana_default_dashboard` is set.
308
+ call: panel="<panel_id>"
309
+ standard_options:
310
+ column_divider:
311
+ dashboard: >-
312
+ If this option, or the global option `grafana_default_dashboard` is set, the resulting alerts will be limited to this
313
+ dashboard. To show all alerts in this case, specify `dashboard=""` as option.
314
+ filter_columns:
315
+ format:
316
+ from:
317
+ instance:
318
+ replace_values:
319
+ row_divider:
320
+ timeout:
321
+ to:
322
+ transpose:
323
+ from_timezone:
324
+ to_timezone:
325
+
326
+ grafana_panel_property:
327
+ description: >-
328
+ Returns a property field for the specified panel. `<type>` can either be `title` or `description`.
329
+ Grafana variables will be replaced in the returned value.
330
+ call: 'grafana_panel_property:<panel_id>["<type>",options]'
331
+ see: https://grafana.com/docs/grafana/latest/variables/templates-and-variables/#variable-syntax
332
+ standard_options:
333
+ dashboard:
334
+ instance:
335
+
336
+ grafana_panel_image:
337
+ description: Includes a panel image as an image in the document. Can be called for inline-images as well as for blocks.
338
+ call: 'grafana_panel_image:<panel_id>[options] or grafana_panel_image::<panel_id>[options]'
339
+ options:
340
+ render-height:
341
+ description: can be used to override default `height` in which the panel shall be rendered
342
+ call: render-height="<height>"
343
+ render-width:
344
+ description: can be used to override default `width` in which the panel shall be rendered
345
+ call: render-width="<width>"
346
+ render-theme:
347
+ description: can be used to override default `theme` in which the panel shall be rendered (light by default)
348
+ call: render-theme="<theme>"
349
+ render-timeout:
350
+ description: can be used to override default `timeout` in which the panel shall be rendered (60 seconds by default)
351
+ call: render-timeout="<timeout>"
352
+ standard_options:
353
+ dashboard:
354
+ from:
355
+ instance:
356
+ timeout:
357
+ to:
358
+ from_timezone:
359
+ to_timezone:
360
+
361
+ grafana_panel_query_table:
362
+ description: >-
363
+ Returns the results of a query, which is configured in a grafana panel, as a table in asciidoctor.
364
+ Grafana variables will be replaced in the panel's SQL statement.
365
+ call: 'include::grafana_panel_query_table:<panel_id>[query="<query_letter>",options]'
366
+ see: https://grafana.com/docs/grafana/latest/variables/templates-and-variables/#variable-syntax
367
+ options:
368
+ query:
369
+ call: query="<query_letter>"
370
+ description: +<query_letter>+ needs to point to the grafana query which shall be evaluated, e.g. +A+ or +B+.
371
+ standard_options:
372
+ column_divider:
373
+ dashboard:
374
+ filter_columns:
375
+ format:
376
+ from:
377
+ instance:
378
+ replace_values:
379
+ row_divider:
380
+ timeout:
381
+ to:
382
+ transpose:
383
+ from_timezone:
384
+ to_timezone:
385
+
386
+ grafana_panel_query_value:
387
+ call: 'grafana_panel_query_value:<panel_id>[query="<query_letter>",options]'
388
+ description: >-
389
+ Returns the value in the first column and the first row of a query, which is configured in a grafana panel.
390
+ Grafana variables will be replaced in the panel's SQL statement.
391
+ see: https://grafana.com/docs/grafana/latest/variables/templates-and-variables/#variable-syntax
392
+ options:
393
+ query:
394
+ call: query="<query_letter>"
395
+ description: +<query_letter>+ needs to point to the grafana query which shall be evaluated, e.g. +A+ or +B+.
396
+ standard_options:
397
+ dashboard:
398
+ filter_columns:
399
+ format:
400
+ from:
401
+ instance:
402
+ replace_values:
403
+ timeout:
404
+ to:
405
+ from_timezone:
406
+ to_timezone:
407
+
408
+ grafana_sql_table:
409
+ call: 'include::grafana_sql_table:<datasource_id>[sql="<sql_query>",options]'
410
+ description: >-
411
+ Returns a table with all results of the given query.
412
+ Grafana variables will be replaced in the SQL statement.
413
+ see: https://grafana.com/docs/grafana/latest/variables/templates-and-variables/#variable-syntax
414
+ standard_options:
415
+ column_divider:
416
+ filter_columns:
417
+ format:
418
+ from:
419
+ instance:
420
+ replace_values:
421
+ row_divider:
422
+ timeout:
423
+ to:
424
+ transpose:
425
+ from_timezone:
426
+ to_timezone:
427
+
428
+ grafana_sql_value:
429
+ call: 'grafana_sql_value:<datasource_id>[sql="<sql_query>",options]'
430
+ description: >-
431
+ Returns the value in the first column and the first row of the given query.
432
+ Grafana variables will be replaced in the SQL statement.
433
+ see: https://grafana.com/docs/grafana/latest/variables/templates-and-variables/#variable-syntax
434
+ standard_options:
435
+ filter_columns:
436
+ format:
437
+ from:
438
+ instance:
439
+ replace_values:
440
+ timeout:
441
+ to:
442
+ from_timezone:
443
+ to_timezone:
444
+ YAML_HELP
445
+ end
446
+ end
447
+ end