ruby-grafana-reporter 0.4.3 → 0.4.4

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 +337 -203
  3. data/lib/VERSION.rb +2 -2
  4. data/lib/grafana/abstract_datasource.rb +6 -3
  5. data/lib/grafana/errors.rb +2 -2
  6. data/lib/grafana/grafana_property_datasource.rb +8 -1
  7. data/lib/grafana/panel.rb +1 -1
  8. data/lib/grafana/sql_datasource.rb +1 -9
  9. data/lib/grafana/variable.rb +26 -20
  10. data/lib/grafana_reporter/abstract_query.rb +37 -19
  11. data/lib/grafana_reporter/abstract_report.rb +17 -4
  12. data/lib/grafana_reporter/abstract_table_format_strategy.rb +34 -0
  13. data/lib/grafana_reporter/alerts_table_query.rb +5 -1
  14. data/lib/grafana_reporter/annotations_table_query.rb +5 -1
  15. data/lib/grafana_reporter/application/application.rb +7 -2
  16. data/lib/grafana_reporter/application/webservice.rb +34 -29
  17. data/lib/grafana_reporter/asciidoctor/adoc_plain_table_format_strategy.rb +25 -0
  18. data/lib/grafana_reporter/asciidoctor/alerts_table_include_processor.rb +2 -1
  19. data/lib/grafana_reporter/asciidoctor/annotations_table_include_processor.rb +2 -1
  20. data/lib/grafana_reporter/asciidoctor/help.rb +458 -0
  21. data/lib/grafana_reporter/asciidoctor/panel_image_block_macro.rb +5 -1
  22. data/lib/grafana_reporter/asciidoctor/panel_image_inline_macro.rb +5 -1
  23. data/lib/grafana_reporter/asciidoctor/panel_property_inline_macro.rb +5 -1
  24. data/lib/grafana_reporter/asciidoctor/panel_query_table_include_processor.rb +5 -1
  25. data/lib/grafana_reporter/asciidoctor/panel_query_value_inline_macro.rb +3 -0
  26. data/lib/grafana_reporter/asciidoctor/processor_mixin.rb +3 -2
  27. data/lib/grafana_reporter/asciidoctor/report.rb +15 -13
  28. data/lib/grafana_reporter/asciidoctor/show_help_include_processor.rb +1 -1
  29. data/lib/grafana_reporter/asciidoctor/sql_table_include_processor.rb +5 -1
  30. data/lib/grafana_reporter/asciidoctor/sql_value_inline_macro.rb +5 -1
  31. data/lib/grafana_reporter/console_configuration_wizard.rb +2 -2
  32. data/lib/grafana_reporter/csv_table_format_strategy.rb +23 -0
  33. data/lib/grafana_reporter/demo_report_wizard.rb +0 -1
  34. data/lib/grafana_reporter/erb/demo_report_builder.rb +46 -0
  35. data/lib/grafana_reporter/erb/report.rb +13 -7
  36. data/lib/grafana_reporter/errors.rb +9 -7
  37. data/lib/grafana_reporter/query_value_query.rb +1 -1
  38. data/lib/grafana_reporter/report_webhook.rb +12 -8
  39. metadata +7 -3
  40. data/lib/grafana_reporter/help.rb +0 -443
@@ -33,7 +33,11 @@ module GrafanaReporter
33
33
  @result = replace_values(@result, @variables.select { |k, _v| k =~ /^replace_values_\d+/ })
34
34
  @result = filter_columns(@result, @variables['filter_columns'])
35
35
 
36
- @result = format_table_output(@result, row_divider: @variables['row_divider'], column_divider: @variables['column_divider'])
36
+ @result = format_table_output(@result,
37
+ row_divider: @variables['row_divider'],
38
+ column_divider: @variables['column_divider'],
39
+ table_formatter: @variables['table_formatter'],
40
+ include_headline: @variables['include_headline'])
37
41
  end
38
42
  end
39
43
  end
@@ -32,7 +32,11 @@ module GrafanaReporter
32
32
  @result = replace_values(@result, @variables.select { |k, _v| k =~ /^replace_values_\d+/ })
33
33
  @result = filter_columns(@result, @variables['filter_columns'])
34
34
 
35
- @result = format_table_output(@result, row_divider: @variables['row_divider'], column_divider: @variables['column_divider'])
35
+ @result = format_table_output(@result,
36
+ row_divider: @variables['row_divider'],
37
+ column_divider: @variables['column_divider'],
38
+ table_formatter: @variables['table_formatter'],
39
+ include_headline: @variables['include_headline'])
36
40
  end
37
41
  end
38
42
  end
@@ -13,7 +13,6 @@ module GrafanaReporter
13
13
  # It can be run to test the grafana connection, render a single template
14
14
  # or run as a service.
15
15
  class Application
16
-
17
16
  # Contains the {Configuration} object of the application.
18
17
  attr_accessor :config
19
18
 
@@ -140,7 +139,13 @@ module GrafanaReporter
140
139
 
141
140
  when Configuration::MODE_SINGLE_RENDER
142
141
  begin
143
- config.report_class.new(config).create_report(config.template, config.to_file)
142
+ template_ext = config.report_class.default_template_extension
143
+ report_ext = config.report_class.default_result_extension
144
+ default_to_file = File.basename(config.template.to_s.gsub(/(?:\.#{template_ext})?$/, ".#{report_ext}"))
145
+
146
+ to_file = config.to_file
147
+ to_file = "#{config.reports_folder}#{default_to_file}" if to_file == true
148
+ config.report_class.new(config).create_report(config.template, to_file)
144
149
  rescue StandardError => e
145
150
  puts "#{e.message}\n#{e.backtrace.join("\n")}"
146
151
  end
@@ -224,35 +224,40 @@ module GrafanaReporter
224
224
  def get_reports_status_as_html(reports)
225
225
  i = reports.length
226
226
 
227
- content = '<html>'\
228
- '<head></head>'\
229
- '<body>'\
230
- '<table>'\
231
- '<thead>'\
232
- '<th>#</th>'\
233
- '<th>Start Time</th>'\
234
- '<th>End Time</th>'\
235
- '<th>Template</th>'\
236
- '<th>Execution time</th>'\
237
- '<th>Status</th>'\
238
- '<th>Error</th>'\
239
- '<th>Action</th>'\
240
- '</thead>' +
241
- reports.reverse.map do |report|
242
- '<tr>'\
243
- "<td>#{i -= 1}</td>"\
244
- "<td>#{report.start_time}</td>"\
245
- "<td>#{report.end_time}</td>"\
246
- "<td>#{report.template}</td>"\
247
- "<td>#{report.execution_time.to_i} secs</td>"\
248
- "<td>#{report.status} (#{(report.progress * 100).to_i}%)</td>"\
249
- "<td>#{report.error.join('<br>')}</td>"\
250
- "<td>#{!report.done && !report.cancel ? "<a href=\"/cancel_report?report_id=#{report.object_id}\">Cancel</a>&nbsp;" : ''}"\
251
- "#{(report.status == 'finished') || (report.status == 'cancelled') ? "<a href=\"/view_report?report_id=#{report.object_id}\">View</a>&nbsp;" : '&nbsp;'}"\
252
- "<a href=\"/view_log?report_id=#{report.object_id}\">Log</a></td>"\
253
- '</tr>'
254
- end.join('') +
255
- '</table></body></html>'
227
+ # TODO: make reporter HTML results customizable
228
+ template = <<~HTML_TEMPLATE
229
+ <html>
230
+ <head></head>
231
+ <body>
232
+ <table>
233
+ <thead>
234
+ <th>#</th><th>Start Time</th><th>End Time</th><th>Template</th><th>Execution time</th>
235
+ <th>Status</th><th>Error</th><th>Action</th>
236
+ </thead>
237
+ <tbody>
238
+ <% reports.reverse.map do |report| %>
239
+ <tr><td><%= i-= 1 %></td><td><%= report.start_time %></td><td><%= report.end_time %></td>
240
+ <td><%= report.template %></td><td><%= report.execution_time.to_i %> secs</td>
241
+ <td><%= report.status %> (<%= (report.progress * 100).to_i %>%)</td>
242
+ <td><%= report.error.join('<br>') %></td>
243
+ <td><% if !report.done && !report.cancel %>
244
+ <a href="/cancel_report?report_id=<%= report.object_id %>">Cancel</a>
245
+ <% end %>
246
+ &nbsp;
247
+ <% if (report.status == 'finished') || (report.status == 'cancelled') %>
248
+ <a href="/view_report?report_id=<%= report.object_id %>">View</a>
249
+ <% end %>
250
+ &nbsp;
251
+ <a href="/view_log?report_id=<%= report.object_id %>">Log</a></td></tr>
252
+ <% end.join('') %>
253
+ <tbody>
254
+ </table>
255
+ <p style="font-size: small; color:grey">You are running ruby-grafana-reporter version <%= GRAFANA_REPORTER_VERSION.join('.') %>.</p>
256
+ </body>
257
+ </html>
258
+ HTML_TEMPLATE
259
+
260
+ content = ::ERB.new(template).result(binding)
256
261
 
257
262
  http_response(200, 'OK', content, "Content-Type": 'text/html')
258
263
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GrafanaReporter
4
+ module Asciidoctor
5
+ # Implements a default table format strategy, which will return tables
6
+ # as asciidoctor formatted table.
7
+ class AdocPlainTableFormatStrategy < AbstractTableFormatStrategy
8
+ # @see AbstractTableFormatStrategy#abbreviation
9
+ def self.abbreviation
10
+ 'adoc_plain'
11
+ end
12
+
13
+ # @see AbstractTableFormatStrategy#format
14
+ def format(result, include_headline)
15
+ headline = '| ' + result[:header].map { |item| item.to_s.gsub(' | ', '\\|') }.join(' | ')
16
+
17
+ content = result[:content].map do |row|
18
+ '| ' + row.map { |item| item.to_s.gsub(' | ', '\\|') }.join(' | ')
19
+ end.join("\n")
20
+
21
+ "#{"#{headline}\n" if include_headline}#{content}"
22
+ end
23
+ end
24
+ end
25
+ end
@@ -59,7 +59,8 @@ module GrafanaReporter
59
59
  grafana_obj = @report.grafana(instance).dashboard(dashboard_id) if dashboard_id
60
60
  grafana_obj = grafana_obj.panel(panel_id) if panel_id
61
61
 
62
- query = AlertsTableQuery.new(grafana_obj, variables: build_attribute_hash(doc.attributes, attrs))
62
+ vars = { 'table_formatter' => 'adoc_plain' }.merge(build_attribute_hash(doc.attributes, attrs))
63
+ query = AlertsTableQuery.new(grafana_obj, variables: vars)
63
64
  defaults = {}
64
65
  defaults['dashboardId'] = dashboard_id if dashboard_id
65
66
  defaults['panelId'] = panel_id if panel_id
@@ -58,7 +58,8 @@ module GrafanaReporter
58
58
  grafana_obj = @report.grafana(instance).dashboard(dashboard_id) if dashboard_id
59
59
  grafana_obj = grafana_obj.panel(panel_id) if panel_id
60
60
 
61
- query = AnnotationsTableQuery.new(grafana_obj, variables: build_attribute_hash(doc.attributes, attrs))
61
+ vars = { 'table_formatter' => 'adoc_plain' }.merge(build_attribute_hash(doc.attributes, attrs))
62
+ query = AnnotationsTableQuery.new(grafana_obj, variables: vars)
62
63
  defaults = {}
63
64
  defaults['dashboardId'] = dashboard_id if dashboard_id
64
65
  defaults['panelId'] = panel_id if panel_id
@@ -0,0 +1,458 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+
5
+ module GrafanaReporter
6
+ module Asciidoctor
7
+ # This class generates the functional help documentation for the asciidoctor report.
8
+ # It can create the documentation for github markdown, as well as in asciidoctor syntax.
9
+ class Help
10
+ # @param headline_level [Integer] top level of headline
11
+ # @return [String] asciidoctor compatible documentation
12
+ def asciidoctor(headline_level = 2)
13
+ help_text(asciidoctor_options.merge(level: headline_level))
14
+ end
15
+
16
+ # @param headline_level [Integer] top level of headline
17
+ # @return [String] github markdown compatible documentation
18
+ def github(headline_level = 2)
19
+ "#{toc}\n\n#{help_text(github_options.merge(level: headline_level))}"
20
+ end
21
+
22
+ private
23
+
24
+ def github_options
25
+ { headline_separator: '#', code_begin: '`', code_end: '`', table_begin: "\n", head_postfix_col: '| -- ' }
26
+ end
27
+
28
+ def asciidoctor_options
29
+ { headline_separator: '=', code_begin: '`+', code_end: '+`', table_begin: "\n[%autowidth.stretch, "\
30
+ "options=\"header\"]\n|===\n", table_end: "\n|===" }
31
+ end
32
+
33
+ def help_text(opts)
34
+ %(#{opts[:headline_separator] * opts[:level]} Global options
35
+ #{global_options_as_text(opts.merge(level: opts[:level] + 1))}
36
+ #{opts[:headline_separator] * opts[:level]} Functions
37
+ #{functions_as_text(opts.merge(level: opts[:level] + 1))})
38
+ end
39
+
40
+ def toc
41
+ result = []
42
+
43
+ result << 'Table of contents'
44
+ result << '* [Global options](#global-options)'
45
+ prepared_help[:global_options].sort.map do |k, _v|
46
+ result << " * [#{k}](##{k.downcase})"
47
+ end
48
+
49
+ result << '* [Functions](#functions)'
50
+ prepared_help[:functions].sort.map do |k, _v|
51
+ result << " * [#{k}](##{k.downcase})"
52
+ end
53
+
54
+ result.join("\n")
55
+ end
56
+
57
+ def global_options_as_text(opts = {})
58
+ opts = { level: 3 }.merge(opts)
59
+ result = []
60
+
61
+ prepared_help[:global_options].sort.map do |k, v|
62
+ result << %(
63
+ #{opts[:headline_separator] * opts[:level]} #{opts[:code_begin]}#{k}#{opts[:code_end]}
64
+ Usage: #{opts[:code_begin]}#{v['call']}#{opts[:code_end]}
65
+
66
+ #{v['description']}
67
+ )
68
+ end
69
+
70
+ result.join
71
+ end
72
+
73
+ def functions_as_text(opts = {})
74
+ opts = { level: 3, headline_separator: '=' }.merge(opts)
75
+ result = []
76
+
77
+ prepared_help[:functions].sort.map do |k, v|
78
+ result << %(
79
+ #{opts[:headline_separator] * opts[:level]} #{opts[:code_begin]}#{k}#{opts[:code_end]}
80
+ Usage: #{opts[:code_begin]}#{v[:call]}#{opts[:code_end]}
81
+
82
+ #{v[:description]}#{"\n\nSee also: #{v[:see]}" if v[:see]}#{unless v[:options].empty?
83
+ %(
84
+ #{opts[:table_begin]}| Option | Description#{"\n#{opts[:head_postfix_col] * 2}" if opts[:head_postfix_col]}
85
+ #{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]})
86
+ end}
87
+ )
88
+ end
89
+
90
+ result.join
91
+ end
92
+
93
+ def prepared_help
94
+ yaml = YAML.safe_load(raw_help_yaml)
95
+
96
+ result = {}
97
+ result[:functions] = {}
98
+ result[:global_options] = yaml['global_options']
99
+
100
+ functions = result[:functions]
101
+ std_opts = yaml['standard_options']
102
+ yaml.reject { |k, _v| k =~ /.*_options$/ }.each_key do |key|
103
+ functions[key] = {}
104
+ res_item = functions[key]
105
+ res_item[:options] = {}
106
+
107
+ item = yaml[key]
108
+ res_item[:call] = item['call']
109
+ res_item[:description] = item['description']
110
+ res_item[:see] = item['see']
111
+
112
+ opts = ((item['options'] ? item['options'].keys : [])
113
+ (item['standard_options'] ? item['standard_options'].keys : [])).sort
114
+ opts.each do |opt_key|
115
+ res_item[:options][opt_key] = {}
116
+
117
+ if item['standard_options'].key?(opt_key)
118
+ res_item[:options][opt_key][:call] = std_opts[opt_key]['call']
119
+ res_item[:options][opt_key][:description] = "#{std_opts[opt_key]['description']} "\
120
+ "#{item['standard_options'][opt_key]}".chop
121
+ res_item[:options][opt_key][:see] = std_opts[opt_key]['see'] if std_opts[opt_key]['see']
122
+ else
123
+ res_item[:options][opt_key][:call] = item['options'][opt_key]['call']
124
+ res_item[:options][opt_key][:description] = item['options'][opt_key]['description']
125
+ res_item[:options][opt_key][:see] = item['options'][opt_key]['see'] if item['options'][opt_key]['see']
126
+ end
127
+ end
128
+ end
129
+
130
+ result
131
+ end
132
+
133
+ def raw_help_yaml
134
+ <<~YAML_HELP
135
+ global_options:
136
+ grafana_default_instance:
137
+ call: ":grafana_default_instance: <instance_name>"
138
+ description: >-
139
+ Specifies which grafana instance shall be used. If not set, the grafana instance names `default`
140
+ will be used.
141
+
142
+ grafana_default_dashboard:
143
+ call: ":grafana_default_dashboard: <dashboard_uid>"
144
+ description: >-
145
+ Specifies to which dashboard the queries shall be targeted by default.
146
+
147
+ grafana_default_from_timezone:
148
+ call: ":grafana_default_from_timezone: <timezone>"
149
+ description: Specifies which timezone shall be used for the `from` time, e.g. `CET` or `CEST`.
150
+
151
+ grafana_default_to_timezone:
152
+ call: ":grafana_default_to_timezone: <timezone>"
153
+ description: Specifies which timezone shall be used for the `to` time, e.g. `CET` or `CEST`.
154
+
155
+ from:
156
+ call: ":from: <from_timestamp>"
157
+ description: >-
158
+ Overrides the time setting from grafana. It may contain dates as `now-1M/M`, which will be translated
159
+ properly to timestamps relative to the called time.
160
+
161
+ to:
162
+ call: ":to: <to_timestamp>"
163
+ description: >-
164
+ Overrides the time setting from grafana. It may contain dates as `now-1M/M`, which will be translated
165
+ properly to timestamps relative to the called time.
166
+
167
+ standard_options:
168
+ instance:
169
+ call: instance="<instance_name>"
170
+ description: >-
171
+ can be used to override global grafana instance, set in the report with `grafana_default_instance`.
172
+ If nothing is set, the configured grafana instance with name `default` will be used.
173
+
174
+ dashboard:
175
+ call: dashboard="<dashboard_uid>"
176
+ description: >-
177
+ Specifies the dashboard to be used. If `grafana_default_dashboard` is specified in the report template,
178
+ this value can be overridden with this option.
179
+
180
+ from:
181
+ call: from="<timestamp>"
182
+ description: can be used to override default `from` time
183
+
184
+ from_timezone:
185
+ call: from_timezone="<timezone>"
186
+ description: can be used to override system timezone for `from` time and will also override `grafana_default_from_timezone` option
187
+
188
+ to_timezone:
189
+ call: to_timezone="<timezone>"
190
+ description: can be used to override system timezone for `to` time and will also override `grafana_default_to_timezone` option
191
+
192
+ to:
193
+ call: to="<timestamp>"
194
+ description: can be used to override default `to` time
195
+
196
+ format:
197
+ call: format="<format_col1>,<format_col2>,..."
198
+ description: >-
199
+ Specify format in which the results shall be returned, e.g. `%.2f` for only two digit decimals of a
200
+ float. Several columns are separated by `,`. Execution is applied in the following order `format`,
201
+ `replace_values`, `filter_columns`, `transpose`.
202
+ see: 'https://ruby-doc.org/core/Kernel.html#method-i-sprintf'
203
+
204
+ replace_values:
205
+ call: replace_values="<replace_1>:<with_1>,<replace_2>:<with_2>,..."
206
+ description: >-
207
+ Specify result values which shall be replaced, e.g. `2:OK` will replace query values `2` with value `OK`.
208
+ Replacing several values is possible by separating by `,`. Matches with regular expressions are also
209
+ supported, but must be full matches, i.e. have to start with `^` and end with `$`, e.g. `^[012]$:OK`.
210
+ Number replacements can also be performed, e.g. `<8.2` or `<>3`. Execution is applied in the following order `format`,
211
+ `replace_values`, `filter_columns`, `transpose`.
212
+ see: https://ruby-doc.org/core/Regexp.html#class-Regexp-label-Character+Classes
213
+
214
+ filter_columns:
215
+ call: filter_columns="<column_name_1>,<column_name_2>,..."
216
+ description: >-
217
+ Removes specified columns from result. Execution is applied in the following order `format`, `replace_values`,
218
+ `filter_columns`, `transpose`.
219
+
220
+ transpose:
221
+ call: transpose="true"
222
+ description: >-
223
+ Transposes the query result, i.e. columns become rows and rows become columnns. Execution is applied in the
224
+ following order `format`, `replace_values`, `filter_columns`, `transpose`.
225
+
226
+ column_divider:
227
+ call: column_divider="<divider>"
228
+ description: >-
229
+ Replace the default column divider with another one, when used in conjunction with `table_formatter` set to
230
+ `adoc_deprecated`. Defaults to ` | ` for being interpreted as a asciidoctor column. DEPRECATED: switch to
231
+ `table_formatter` named `adoc_plain`, or implement a custom table formatter.
232
+
233
+ row_divider:
234
+ call: row_divider="<divider>"
235
+ description: >-
236
+ Replace the default row divider with another one, when used in conjunction with `table_formatter` set to
237
+ `adoc_deprecated`. . Defaults to `| ` for being interpreted as a asciidoctor row. DEPRECATED: switch to
238
+ `table_formatter` named `adoc_plain`, or implement a custom table formatter.
239
+
240
+ table_formatter:
241
+ call: table_formatter="<formatter>"
242
+ description: >-
243
+ Specify a table formatter fitting for your expected target format. It defaults to `adoc_plain` for asciidoctor
244
+ templates and to `csv` for all other templates, e.g. ERB.
245
+
246
+ timeout:
247
+ call: timeout="<timeout_in_seconds>"
248
+ description: >-
249
+ Set a timeout for the current query. If not overridden with `grafana_default_timeout` in the report template,
250
+ this defaults to 60 seconds.
251
+
252
+ # ----------------------------------
253
+ # FUNCTION DOCUMENTATION STARTS HERE
254
+ # ----------------------------------
255
+
256
+ grafana_help:
257
+ description: Show all available grafana calls within the asciidoctor templates, including available options.
258
+ call: 'include::grafana_help[]'
259
+
260
+ grafana_environment:
261
+ description: Shows all available variables in the rendering context which can be used in the asciidoctor template.
262
+ call: 'include::grafana_environment[]'
263
+
264
+ grafana_alerts:
265
+ description: >-
266
+ Returns a table of active alert states including the specified columns and the connected information. Supports
267
+ all query parameters from the Grafana Alerting API, such as `query`, `state`, `limit`, `folderId` and others.
268
+ call: 'include::grafana_alerts[columns="<column_name_1>,<column_name_2>,...",options]'
269
+ see: https://grafana.com/docs/grafana/latest/http_api/alerting/#get-alerts
270
+ options:
271
+ columns:
272
+ description: >-
273
+ Specifies columns that shall be returned. Valid columns are `id`, `dashboardId`, `dashboardUId`, `dashboardSlug`,
274
+ `panelId`, `name`, `state`, `newStateDate`, `evalDate`, `evalData` and `executionError`.
275
+ call: columns="<column_name_1>,<columns_name_2>,..."
276
+ panel:
277
+ description: >-
278
+ If specified, the resulting alerts are filtered for this panel. This option will only work, if a `dashboard`
279
+ or `grafana_default_dashboard` is set.
280
+ call: panel="<panel_id>"
281
+ standard_options:
282
+ column_divider:
283
+ dashboard: >-
284
+ If this option, or the global option `grafana_default_dashboard` is set, the resulting alerts will be limited to
285
+ this dashboard. To show all alerts in this case, specify `dashboard=""` as option.
286
+ filter_columns:
287
+ format:
288
+ from:
289
+ instance:
290
+ replace_values:
291
+ row_divider:
292
+ table_formatter:
293
+ timeout:
294
+ to:
295
+ transpose:
296
+ from_timezone:
297
+ to_timezone:
298
+
299
+ grafana_annotations:
300
+ description: >-
301
+ Returns a table of all annotations, matching the specified filter criteria and the specified columns. Supports all
302
+ query parameters from the Grafana Alerting API, such as `limit`, `alertId`, `panelId` and others.
303
+ call: 'include::grafana_annotations[columns="<column_name_1>,<column_name_2>,...",options]'
304
+ see: https://grafana.com/docs/grafana/latest/http_api/annotations/#find-annotations
305
+ options:
306
+ columns:
307
+ description: >-
308
+ Specified the columns that shall be returned. Valid columns are `id`, `alertId`, `dashboardId`, `panelId`, `userId`,
309
+ `userName`, `newState`, `prevState`, `time`, `timeEnd`, `text`, `metric` and `type`.
310
+ call: columns="<column_name_1>,<columns_name_2>,..."
311
+ panel:
312
+ description: >-
313
+ If specified, the resulting alerts are filtered for this panel. This option will only work, if a `dashboard` or
314
+ `grafana_default_dashboard` is set.
315
+ call: panel="<panel_id>"
316
+ standard_options:
317
+ column_divider:
318
+ dashboard: >-
319
+ If this option, or the global option `grafana_default_dashboard` is set, the resulting alerts will be limited to this
320
+ dashboard. To show all alerts in this case, specify `dashboard=""` as option.
321
+ filter_columns:
322
+ format:
323
+ from:
324
+ instance:
325
+ replace_values:
326
+ row_divider:
327
+ table_formatter:
328
+ timeout:
329
+ to:
330
+ transpose:
331
+ from_timezone:
332
+ to_timezone:
333
+
334
+ grafana_panel_property:
335
+ description: >-
336
+ Returns a property field for the specified panel. `<type>` can either be `title` or `description`.
337
+ Grafana variables will be replaced in the returned value.
338
+ call: 'grafana_panel_property:<panel_id>["<type>",options]'
339
+ see: https://grafana.com/docs/grafana/latest/variables/syntax/
340
+ standard_options:
341
+ dashboard:
342
+ instance:
343
+
344
+ grafana_panel_image:
345
+ description: Includes a panel image as an image in the document. Can be called for inline-images as well as for blocks.
346
+ call: 'grafana_panel_image:<panel_id>[options] or grafana_panel_image::<panel_id>[options]'
347
+ options:
348
+ render-height:
349
+ description: can be used to override default `height` in which the panel shall be rendered
350
+ call: render-height="<height>"
351
+ render-width:
352
+ description: can be used to override default `width` in which the panel shall be rendered
353
+ call: render-width="<width>"
354
+ render-theme:
355
+ description: can be used to override default `theme` in which the panel shall be rendered (light by default)
356
+ call: render-theme="<theme>"
357
+ render-timeout:
358
+ description: can be used to override default `timeout` in which the panel shall be rendered (60 seconds by default)
359
+ call: render-timeout="<timeout>"
360
+ standard_options:
361
+ dashboard:
362
+ from:
363
+ instance:
364
+ timeout:
365
+ to:
366
+ from_timezone:
367
+ to_timezone:
368
+
369
+ grafana_panel_query_table:
370
+ description: >-
371
+ Returns the results of a query, which is configured in a grafana panel, as a table in asciidoctor.
372
+ Grafana variables will be replaced in the panel's SQL statement.
373
+ call: 'include::grafana_panel_query_table:<panel_id>[query="<query_letter>",options]'
374
+ see: https://grafana.com/docs/grafana/latest/variables/syntax/
375
+ options:
376
+ query:
377
+ call: query="<query_letter>"
378
+ description: +<query_letter>+ needs to point to the grafana query which shall be evaluated, e.g. +A+ or +B+.
379
+ standard_options:
380
+ column_divider:
381
+ dashboard:
382
+ filter_columns:
383
+ format:
384
+ from:
385
+ instance:
386
+ replace_values:
387
+ row_divider:
388
+ table_formatter:
389
+ timeout:
390
+ to:
391
+ transpose:
392
+ from_timezone:
393
+ to_timezone:
394
+
395
+ grafana_panel_query_value:
396
+ call: 'grafana_panel_query_value:<panel_id>[query="<query_letter>",options]'
397
+ description: >-
398
+ Returns the value in the first column and the first row of a query, which is configured in a grafana panel.
399
+ Grafana variables will be replaced in the panel's SQL statement.
400
+ see: https://grafana.com/docs/grafana/latest/variables/syntax/
401
+ options:
402
+ query:
403
+ call: query="<query_letter>"
404
+ description: +<query_letter>+ needs to point to the grafana query which shall be evaluated, e.g. +A+ or +B+.
405
+ standard_options:
406
+ dashboard:
407
+ filter_columns:
408
+ format:
409
+ from:
410
+ instance:
411
+ replace_values:
412
+ timeout:
413
+ to:
414
+ from_timezone:
415
+ to_timezone:
416
+
417
+ grafana_sql_table:
418
+ call: 'include::grafana_sql_table:<datasource_id>[sql="<sql_query>",options]'
419
+ description: >-
420
+ Returns a table with all results of the given query.
421
+ Grafana variables will be replaced in the SQL statement.
422
+ see: https://grafana.com/docs/grafana/latest/variables/syntax/
423
+ standard_options:
424
+ column_divider:
425
+ filter_columns:
426
+ format:
427
+ from:
428
+ instance:
429
+ replace_values:
430
+ row_divider:
431
+ table_formatter:
432
+ timeout:
433
+ to:
434
+ transpose:
435
+ from_timezone:
436
+ to_timezone:
437
+
438
+ grafana_sql_value:
439
+ call: 'grafana_sql_value:<datasource_id>[sql="<sql_query>",options]'
440
+ description: >-
441
+ Returns the value in the first column and the first row of the given query.
442
+ Grafana variables will be replaced in the SQL statement.
443
+ see: https://grafana.com/docs/grafana/latest/variables/syntax/
444
+ standard_options:
445
+ filter_columns:
446
+ format:
447
+ from:
448
+ instance:
449
+ replace_values:
450
+ timeout:
451
+ to:
452
+ from_timezone:
453
+ to_timezone:
454
+ YAML_HELP
455
+ end
456
+ end
457
+ end
458
+ end