ruby-grafana-reporter 0.3.0 → 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 (86) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +337 -170
  3. data/bin/ruby-grafana-reporter +5 -5
  4. data/lib/VERSION.rb +3 -2
  5. data/lib/grafana/abstract_datasource.rb +149 -0
  6. data/lib/grafana/dashboard.rb +1 -3
  7. data/lib/grafana/errors.rb +20 -5
  8. data/lib/grafana/grafana.rb +52 -57
  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 +37 -0
  12. data/lib/grafana/graphite_datasource.rb +72 -0
  13. data/lib/grafana/image_rendering_datasource.rb +44 -0
  14. data/lib/grafana/influxdb_datasource.rb +70 -0
  15. data/lib/grafana/panel.rb +10 -4
  16. data/lib/grafana/prometheus_datasource.rb +67 -0
  17. data/lib/grafana/sql_datasource.rb +70 -0
  18. data/lib/grafana/unsupported_datasource.rb +7 -0
  19. data/lib/grafana/variable.rb +27 -21
  20. data/lib/grafana/webrequest.rb +71 -0
  21. data/lib/grafana_reporter/abstract_query.rb +478 -0
  22. data/lib/grafana_reporter/abstract_report.rb +152 -18
  23. data/lib/grafana_reporter/abstract_table_format_strategy.rb +34 -0
  24. data/lib/grafana_reporter/alerts_table_query.rb +43 -0
  25. data/lib/grafana_reporter/annotations_table_query.rb +42 -0
  26. data/lib/grafana_reporter/application/application.rb +28 -25
  27. data/lib/grafana_reporter/application/webservice.rb +80 -39
  28. data/lib/grafana_reporter/asciidoctor/adoc_plain_table_format_strategy.rb +25 -0
  29. data/lib/grafana_reporter/asciidoctor/alerts_table_include_processor.rb +92 -0
  30. data/lib/grafana_reporter/asciidoctor/annotations_table_include_processor.rb +91 -0
  31. data/lib/grafana_reporter/asciidoctor/help.rb +336 -313
  32. data/lib/grafana_reporter/asciidoctor/panel_image_block_macro.rb +78 -0
  33. data/lib/grafana_reporter/asciidoctor/panel_image_inline_macro.rb +80 -0
  34. data/lib/grafana_reporter/asciidoctor/panel_property_inline_macro.rb +74 -0
  35. data/lib/grafana_reporter/asciidoctor/panel_query_table_include_processor.rb +99 -0
  36. data/lib/grafana_reporter/asciidoctor/panel_query_value_inline_macro.rb +93 -0
  37. data/lib/grafana_reporter/asciidoctor/processor_mixin.rb +50 -0
  38. data/lib/grafana_reporter/asciidoctor/report.rb +41 -82
  39. data/lib/grafana_reporter/asciidoctor/show_environment_include_processor.rb +46 -0
  40. data/lib/grafana_reporter/asciidoctor/show_help_include_processor.rb +35 -0
  41. data/lib/grafana_reporter/asciidoctor/sql_table_include_processor.rb +94 -0
  42. data/lib/grafana_reporter/asciidoctor/sql_value_inline_macro.rb +90 -0
  43. data/lib/grafana_reporter/asciidoctor/value_as_variable_include_processor.rb +90 -0
  44. data/lib/grafana_reporter/configuration.rb +26 -8
  45. data/lib/grafana_reporter/console_configuration_wizard.rb +109 -67
  46. data/lib/grafana_reporter/csv_table_format_strategy.rb +23 -0
  47. data/lib/grafana_reporter/demo_report_wizard.rb +104 -0
  48. data/lib/grafana_reporter/erb/demo_report_builder.rb +46 -0
  49. data/lib/grafana_reporter/erb/report.rb +36 -0
  50. data/lib/grafana_reporter/erb/report_jail.rb +21 -0
  51. data/lib/grafana_reporter/errors.rb +57 -0
  52. data/lib/grafana_reporter/logger/{two_way_logger.rb → two_way_delegate_logger.rb} +1 -1
  53. data/lib/grafana_reporter/panel_image_query.rb +25 -0
  54. data/lib/grafana_reporter/panel_property_query.rb +22 -0
  55. data/lib/grafana_reporter/query_value_query.rb +61 -0
  56. data/lib/grafana_reporter/report_webhook.rb +39 -0
  57. data/lib/ruby_grafana_extension.rb +8 -0
  58. data/lib/{ruby-grafana-reporter.rb → ruby_grafana_reporter.rb} +1 -3
  59. metadata +49 -38
  60. data/lib/grafana/abstract_panel_query.rb +0 -22
  61. data/lib/grafana/abstract_query.rb +0 -132
  62. data/lib/grafana/abstract_sql_query.rb +0 -51
  63. data/lib/grafana/panel_image_query.rb +0 -52
  64. data/lib/grafana_reporter/asciidoctor/alerts_table_query.rb +0 -101
  65. data/lib/grafana_reporter/asciidoctor/annotations_table_query.rb +0 -96
  66. data/lib/grafana_reporter/asciidoctor/errors.rb +0 -40
  67. data/lib/grafana_reporter/asciidoctor/extensions/alerts_table_include_processor.rb +0 -92
  68. data/lib/grafana_reporter/asciidoctor/extensions/annotations_table_include_processor.rb +0 -91
  69. data/lib/grafana_reporter/asciidoctor/extensions/panel_image_block_macro.rb +0 -69
  70. data/lib/grafana_reporter/asciidoctor/extensions/panel_image_inline_macro.rb +0 -68
  71. data/lib/grafana_reporter/asciidoctor/extensions/panel_property_inline_macro.rb +0 -61
  72. data/lib/grafana_reporter/asciidoctor/extensions/panel_query_table_include_processor.rb +0 -78
  73. data/lib/grafana_reporter/asciidoctor/extensions/panel_query_value_inline_macro.rb +0 -73
  74. data/lib/grafana_reporter/asciidoctor/extensions/processor_mixin.rb +0 -20
  75. data/lib/grafana_reporter/asciidoctor/extensions/show_environment_include_processor.rb +0 -43
  76. data/lib/grafana_reporter/asciidoctor/extensions/show_help_include_processor.rb +0 -30
  77. data/lib/grafana_reporter/asciidoctor/extensions/sql_table_include_processor.rb +0 -70
  78. data/lib/grafana_reporter/asciidoctor/extensions/sql_value_inline_macro.rb +0 -66
  79. data/lib/grafana_reporter/asciidoctor/extensions/value_as_variable_include_processor.rb +0 -88
  80. data/lib/grafana_reporter/asciidoctor/panel_first_value_query.rb +0 -36
  81. data/lib/grafana_reporter/asciidoctor/panel_image_query.rb +0 -28
  82. data/lib/grafana_reporter/asciidoctor/panel_property_query.rb +0 -44
  83. data/lib/grafana_reporter/asciidoctor/panel_table_query.rb +0 -40
  84. data/lib/grafana_reporter/asciidoctor/query_mixin.rb +0 -312
  85. data/lib/grafana_reporter/asciidoctor/sql_first_value_query.rb +0 -42
  86. data/lib/grafana_reporter/asciidoctor/sql_table_query.rb +0 -44
@@ -6,21 +6,48 @@ 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
- def initialize(config)
9
+ # Array of possible webservice running states
10
+ STATUS = %I[stopped running stopping].freeze
11
+
12
+ def initialize
10
13
  @reports = []
14
+ @status = :stopped
15
+ end
16
+
17
+ # Runs the webservice with the given {Configuration} object.
18
+ def run(config)
11
19
  @config = config
12
20
  @logger = config.logger
13
- end
14
21
 
15
- # Runs the webservice with the current set {Configuration} object.
16
- def run
17
22
  # start webserver
18
23
  @server = TCPServer.new(@config.webserver_port)
19
24
  @logger.info("Server listening on port #{@config.webserver_port}...")
20
25
 
21
26
  @progress_reporter = Thread.new {}
22
27
 
28
+ @status = :running
23
29
  accept_requests_loop
30
+ @status = :stopped
31
+ end
32
+
33
+ # @return True, if webservice is stopped, false otherwise
34
+ def stopped?
35
+ @status == :stopped
36
+ end
37
+
38
+ # @return True, if webservice is up and running, false otherwise
39
+ def 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
24
51
  end
25
52
 
26
53
  private
@@ -30,6 +57,14 @@ module GrafanaReporter
30
57
  # step 1) accept incoming connection
31
58
  socket = @server.accept
32
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
+
33
68
  # step 2) print the request headers (separated by a blank line e.g. \r\n)
34
69
  request = ''
35
70
  line = ''
@@ -48,11 +83,8 @@ module GrafanaReporter
48
83
  rescue WebserviceUnknownPathError => e
49
84
  @logger.debug(e.message)
50
85
  socket.write http_response(404, '', e.message)
51
- rescue MissingTemplateError => e
52
- @logger.error(e.message)
53
- socket.write http_response(400, 'Bad Request', e.message)
54
86
  rescue WebserviceGeneralRenderingError => e
55
- @logger.fatal(e.message)
87
+ @logger.error(e.message)
56
88
  socket.write http_response(400, 'Bad Request', e.message)
57
89
  rescue StandardError => e
58
90
  @logger.fatal(e.message)
@@ -164,12 +196,13 @@ module GrafanaReporter
164
196
  return http_response(200, 'OK', content, "Content-Type": 'application/pdf') if content.start_with?('%PDF')
165
197
 
166
198
  http_response(200, 'OK', content, "Content-Type": 'application/octet-stream',
167
- "Content-Disposition": "attachment; filename=report_#{attrs['report_id']}.zip")
199
+ "Content-Disposition": 'attachment; '\
200
+ "filename=report_#{attrs['report_id']}.zip")
168
201
  end
169
202
 
170
203
  def render_report(attrs)
171
204
  # build report
172
- template_file = "#{@config.templates_folder}#{attrs['var-template']}.adoc"
205
+ template_file = "#{@config.templates_folder}#{attrs['var-template']}"
173
206
 
174
207
  file = Tempfile.new('gf_pdf_', @config.reports_folder)
175
208
  begin
@@ -178,9 +211,10 @@ module GrafanaReporter
178
211
  @logger.debug("File permissions could not be set for #{file.path}: #{e.message}")
179
212
  end
180
213
 
181
- report = @config.report_class.new(@config, template_file, file, attrs)
214
+ report = @config.report_class.new(@config)
215
+ Thread.report_on_exception = false
182
216
  Thread.new do
183
- report.create_report
217
+ report.create_report(template_file, file, attrs)
184
218
  end
185
219
  @reports << report
186
220
 
@@ -190,33 +224,40 @@ module GrafanaReporter
190
224
  def get_reports_status_as_html(reports)
191
225
  i = reports.length
192
226
 
193
- content = '<html>'\
194
- '<head></head>'\
195
- '<body>'\
196
- '<table>'\
197
- '<thead>'\
198
- '<th>#</th>'\
199
- '<th>Start Time</th>'\
200
- '<th>End Time</th>'\
201
- '<th>Template</th>'\
202
- '<th>Execution time</th>'\
203
- '<th>Status</th>'\
204
- '<th>Error</th>'\
205
- '<th>Action</th>'\
206
- '</thead>' +
207
- reports.reverse.map do |report|
208
- '<tr>'\
209
- "<td>#{i -= 1}</td>"\
210
- "<td>#{report.start_time}</td>"\
211
- "<td>#{report.end_time}</td>"\
212
- "<td>#{report.template}</td>"\
213
- "<td>#{report.execution_time.to_i} secs</td><td>#{report.status} (#{(report.progress * 100).to_i}%)</td><td>#{report.error.join('<br>')}</td>"\
214
- "<td>#{!report.done && !report.cancel ? "<a href=\"/cancel_report?report_id=#{report.object_id}\">Cancel</a>&nbsp;" : ''}"\
215
- "#{(report.status == 'finished') || (report.status == 'cancelled') ? "<a href=\"/view_report?report_id=#{report.object_id}\">View</a>&nbsp;" : '&nbsp;'}"\
216
- "<a href=\"/view_log?report_id=#{report.object_id}\">Log</a></td>"\
217
- '</tr>'
218
- end.join('') +
219
- '</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)
220
261
 
221
262
  http_response(200, 'OK', content, "Content-Type": 'text/html')
222
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
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'processor_mixin'
4
+
5
+ module GrafanaReporter
6
+ module Asciidoctor
7
+ # Implements the hook
8
+ # include::grafana_alerts[<options>]
9
+ #
10
+ # Returns the results of alerts query as a asciidoctor table.
11
+ #
12
+ # == Used document parameters
13
+ # +grafana_default_instance+ - name of grafana instance, 'default' if not specified
14
+ #
15
+ # +grafana_default_dashboard+ - uid of grafana default dashboard to use
16
+ #
17
+ # +from+ - 'from' time for the sql query
18
+ #
19
+ # +to+ - 'to' time for the sql query
20
+ #
21
+ # == Supported options
22
+ # +columns+ - see {AlertsTableQuery#pre_process} (*mandatory*)
23
+ #
24
+ # +instance+ - name of grafana instance, 'default' if not specified
25
+ #
26
+ # +dashboard+ - uid of grafana dashboard to query for, empty string if no filter is wanted
27
+ #
28
+ # +panel+ - id of the panel to query for
29
+ #
30
+ # +from+ - 'from' time for the sql query
31
+ #
32
+ # +to+ - 'to' time for the sql query
33
+ #
34
+ # +format+ - see {AbstractQuery#format_columns}
35
+ #
36
+ # +replace_values+ - see {AbstractQuery#replace_values}
37
+ #
38
+ # +filter_columns+ - see {AbstractQuery#filter_columns}
39
+ class AlertsTableIncludeProcessor < ::Asciidoctor::Extensions::IncludeProcessor
40
+ include ProcessorMixin
41
+
42
+ # :nodoc:
43
+ def handles?(target)
44
+ target.start_with? 'grafana_alerts'
45
+ end
46
+
47
+ # :nodoc:
48
+ def process(doc, reader, _target, attrs)
49
+ return if @report.cancel
50
+
51
+ @report.next_step
52
+ instance = attrs['instance'] || doc.attr('grafana_default_instance') || 'default'
53
+ dashboard_id = attrs['dashboard'] || doc.attr('grafana_default_dashboard')
54
+ panel_id = attrs['panel']
55
+ @report.logger.debug("Processing AlertsTableIncludeProcessor (instance: #{instance},"\
56
+ " dashboard: #{dashboard_id}, panel: #{panel_id})")
57
+
58
+ grafana_obj = @report.grafana(instance)
59
+ grafana_obj = @report.grafana(instance).dashboard(dashboard_id) if dashboard_id
60
+ grafana_obj = grafana_obj.panel(panel_id) if panel_id
61
+
62
+ vars = { 'table_formatter' => 'adoc_plain' }.merge(build_attribute_hash(doc.attributes, attrs))
63
+ query = AlertsTableQuery.new(grafana_obj, variables: vars)
64
+ defaults = {}
65
+ defaults['dashboardId'] = dashboard_id if dashboard_id
66
+ defaults['panelId'] = panel_id if panel_id
67
+
68
+ selected_attrs = attrs.select do |k, _v|
69
+ k =~ /(?:columns|limit|folderId|dashboardId|panelId|dahboardTag|dashboardQuery|state|query)/x
70
+ end
71
+ query.raw_query = defaults.merge(selected_attrs.each_with_object({}) { |(k, v), h| h[k] = v })
72
+
73
+ begin
74
+ reader.unshift_lines query.execute
75
+ rescue GrafanaReporterError => e
76
+ @report.logger.error(e.message)
77
+ reader.unshift_line "|#{e.message}"
78
+ rescue StandardError => e
79
+ @report.logger.fatal(e.message)
80
+ reader.unshift_line "|#{e.message}"
81
+ end
82
+
83
+ reader
84
+ end
85
+
86
+ # @see ProcessorMixin#build_demo_entry
87
+ def build_demo_entry(_panel)
88
+ "|===\ninclude::grafana_alerts[columns=\"panelId,name,state\"]\n|==="
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'processor_mixin'
4
+
5
+ module GrafanaReporter
6
+ module Asciidoctor
7
+ # Implements the hook
8
+ # include::grafana_annotations[<options>]
9
+ #
10
+ # Returns the results of alerts query as a asciidoctor table.
11
+ #
12
+ # == Used document parameters
13
+ # +grafana_default_instance+ - name of grafana instance, 'default' if not specified
14
+ #
15
+ # +grafana_default_dashboard+ - uid of grafana default dashboard to use
16
+ #
17
+ # +from+ - 'from' time for the sql query
18
+ #
19
+ # +to+ - 'to' time for the sql query
20
+ #
21
+ # == Supported options
22
+ # +columns+ - see {AnnotationsTableQuery#pre_process} (*mandatory*)
23
+ #
24
+ # +instance+ - name of grafana instance, 'default' if not specified
25
+ #
26
+ # +dashboard+ - uid of grafana dashboard to query for, empty string if no filter is wanted
27
+ #
28
+ # +panel+ - id of the panel to query for
29
+ #
30
+ # +from+ - 'from' time for the sql query
31
+ #
32
+ # +to+ - 'to' time for the sql query
33
+ #
34
+ # +format+ - see {AbstractQuery#format_columns}
35
+ #
36
+ # +replace_values+ - see {AbstractQuery#replace_values}
37
+ #
38
+ # +filter_columns+ - see {AbstractQuery#filter_columns}
39
+ class AnnotationsTableIncludeProcessor < ::Asciidoctor::Extensions::IncludeProcessor
40
+ include ProcessorMixin
41
+
42
+ # :nodoc:
43
+ def handles?(target)
44
+ target.start_with? 'grafana_annotations'
45
+ end
46
+
47
+ # :nodoc:
48
+ def process(doc, reader, _target, attrs)
49
+ return if @report.cancel
50
+
51
+ @report.next_step
52
+ instance = attrs['instance'] || doc.attr('grafana_default_instance') || 'default'
53
+ dashboard_id = attrs['dashboard'] || doc.attr('grafana_default_dashboard')
54
+ panel_id = attrs['panel']
55
+ @report.logger.debug("Processing AnnotationsTableIncludeProcessor (instance: #{instance})")
56
+
57
+ grafana_obj = @report.grafana(instance)
58
+ grafana_obj = @report.grafana(instance).dashboard(dashboard_id) if dashboard_id
59
+ grafana_obj = grafana_obj.panel(panel_id) if panel_id
60
+
61
+ vars = { 'table_formatter' => 'adoc_plain' }.merge(build_attribute_hash(doc.attributes, attrs))
62
+ query = AnnotationsTableQuery.new(grafana_obj, variables: vars)
63
+ defaults = {}
64
+ defaults['dashboardId'] = dashboard_id if dashboard_id
65
+ defaults['panelId'] = panel_id if panel_id
66
+
67
+ selected_attrs = attrs.select do |k, _v|
68
+ k =~ /(?:columns|limit|alertId|dashboardId|panelId|userId|type|tags)/
69
+ end
70
+ query.raw_query = defaults.merge(selected_attrs.each_with_object({}) { |(k, v), h| h[k] = v })
71
+
72
+ begin
73
+ reader.unshift_lines query.execute
74
+ rescue GrafanaReporterError => e
75
+ @report.logger.error(e.message)
76
+ reader.unshift_line "|#{e.message}"
77
+ rescue StandardError => e
78
+ @report.logger.fatal(e.message)
79
+ reader.unshift_line "|#{e.message}"
80
+ end
81
+
82
+ reader
83
+ end
84
+
85
+ # @see ProcessorMixin#build_demo_entry
86
+ def build_demo_entry(_panel)
87
+ "|===\ninclude::grafana_annotations[columns=\"time,panelId,newState,prevState,text\"]\n|==="
88
+ end
89
+ end
90
+ end
91
+ end
@@ -4,11 +4,17 @@ require 'yaml'
4
4
 
5
5
  module GrafanaReporter
6
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.
7
9
  class Help
10
+ # @param headline_level [Integer] top level of headline
11
+ # @return [String] asciidoctor compatible documentation
8
12
  def asciidoctor(headline_level = 2)
9
13
  help_text(asciidoctor_options.merge(level: headline_level))
10
14
  end
11
15
 
16
+ # @param headline_level [Integer] top level of headline
17
+ # @return [String] github markdown compatible documentation
12
18
  def github(headline_level = 2)
13
19
  "#{toc}\n\n#{help_text(github_options.merge(level: headline_level))}"
14
20
  end
@@ -20,7 +26,8 @@ module GrafanaReporter
20
26
  end
21
27
 
22
28
  def asciidoctor_options
23
- { headline_separator: '=', code_begin: '`+', code_end: '+`', table_begin: "\n[%autowidth.stretch, options=\"header\"]\n|===\n", table_end: "\n|===" }
29
+ { headline_separator: '=', code_begin: '`+', code_end: '+`', table_begin: "\n[%autowidth.stretch, "\
30
+ "options=\"header\"]\n|===\n", table_end: "\n|===" }
24
31
  end
25
32
 
26
33
  def help_text(opts)
@@ -33,13 +40,13 @@ module GrafanaReporter
33
40
  def toc
34
41
  result = []
35
42
 
36
- result << "Table of contents"
37
- result << "* [Global options](#global-options)"
43
+ result << 'Table of contents'
44
+ result << '* [Global options](#global-options)'
38
45
  prepared_help[:global_options].sort.map do |k, _v|
39
46
  result << " * [#{k}](##{k.downcase})"
40
47
  end
41
48
 
42
- result << "* [Functions](#functions)"
49
+ result << '* [Functions](#functions)'
43
50
  prepared_help[:functions].sort.map do |k, _v|
44
51
  result << " * [#{k}](##{k.downcase})"
45
52
  end
@@ -102,13 +109,15 @@ end}
102
109
  res_item[:description] = item['description']
103
110
  res_item[:see] = item['see']
104
111
 
105
- opts = ((item['options'] ? item['options'].keys : []) + (item['standard_options'] ? item['standard_options'].keys : [])).sort
112
+ opts = ((item['options'] ? item['options'].keys : [])
113
+ (item['standard_options'] ? item['standard_options'].keys : [])).sort
106
114
  opts.each do |opt_key|
107
115
  res_item[:options][opt_key] = {}
108
116
 
109
117
  if item['standard_options'].key?(opt_key)
110
118
  res_item[:options][opt_key][:call] = std_opts[opt_key]['call']
111
- res_item[:options][opt_key][:description] = "#{std_opts[opt_key]['description']} #{item['standard_options'][opt_key]}".chop
119
+ res_item[:options][opt_key][:description] = "#{std_opts[opt_key]['description']} "\
120
+ "#{item['standard_options'][opt_key]}".chop
112
121
  res_item[:options][opt_key][:see] = std_opts[opt_key]['see'] if std_opts[opt_key]['see']
113
122
  else
114
123
  res_item[:options][opt_key][:call] = item['options'][opt_key]['call']
@@ -122,313 +131,327 @@ end}
122
131
  end
123
132
 
124
133
  def raw_help_yaml
125
- <<YAML_HELP
126
- global_options:
127
- grafana_default_instance:
128
- call: ":grafana_default_instance: <instance_name>"
129
- description: >-
130
- Specifies which grafana instance shall be used. If not set, the grafana instance names `default`
131
- will be used.
132
-
133
- grafana_default_dashboard:
134
- call: ":grafana_default_dashboard: <dashboard_uid>"
135
- description: >-
136
- Specifies to which dashboard the queries shall be targeted by default.
137
-
138
- grafana_default_from_timezone:
139
- call: ":grafana_default_from_timezone: <timezone>"
140
- description: Specifies which timezone shall be used for the `from` time, e.g. `CET` or `CEST`.
141
-
142
- grafana_default_to_timezone:
143
- call: ":grafana_default_to_timezone: <timezone>"
144
- description: Specifies which timezone shall be used for the `to` time, e.g. `CET` or `CEST`.
145
-
146
- from:
147
- call: ":from: <from_timestamp>"
148
- description: >-
149
- Overrides the time setting from grafana. It may contain dates as `now-1M/M`, which will be translated
150
- properly to timestamps relative to the called time.
151
-
152
- to:
153
- call: ":to: <to_timestamp>"
154
- description: >-
155
- Overrides the time setting from grafana. It may contain dates as `now-1M/M`, which will be translated
156
- properly to timestamps relative to the called time.
157
-
158
- standard_options:
159
- instance:
160
- call: instance="<instance_name>"
161
- description: >-
162
- can be used to override global grafana instance, set in the report with `grafana_default_instance`.
163
- If nothing is set, the configured grafana instance with name `default` will be used.
164
-
165
- dashboard:
166
- call: dashboard="<dashboard_uid>"
167
- description: >-
168
- Specifies the dashboard to be used. If `grafana_default_dashboard` is specified in the report template,
169
- this value can be overridden with this option.
170
-
171
- from:
172
- call: from="<timestamp>"
173
- description: can be used to override default `from` time
174
-
175
- from_timezone:
176
- call: from_timezone="<timezone>"
177
- description: can be used to override system timezone for `from` time and will also override `grafana_default_from_timezone` option
178
-
179
- to_timezone:
180
- call: to_timezone="<timezone>"
181
- description: can be used to override system timezone for `to` time and will also override `grafana_default_to_timezone` option
182
-
183
- to:
184
- call: to="<timestamp>"
185
- description: can be used to override default `to` time
186
-
187
- format:
188
- call: format="<format_col1>,<format_col2>,..."
189
- description: >-
190
- Specify format in which the results shall be returned, e.g. `%.2f` for only two digit decimals of a
191
- float. Several columns are separated by `,`. Execution is applied in the following order `format`,
192
- `replace_values`, `filter_columns`, `transpose`.
193
- see: 'https://ruby-doc.org/core-2.4.0/Kernel.html#method-i-sprintf'
194
-
195
- replace_values:
196
- call: replace_values="<replace_1>:<with_1>,<replace_2>:<with_2>,..."
197
- description: >-
198
- Specify result values which shall be replaced, e.g. `2:OK` will replace query values `2` with value `OK`.
199
- Replacing several values is possible by separating by `,`. Matches with regular expressions are also
200
- supported, but must be full matches, i.e. have to start with `^` and end with `$`, e.g. `^[012]$:OK`.
201
- Number replacements can also be performed, e.g. `<8.2` or `<>3`. Execution is applied in the following order `format`,
202
- `replace_values`, `filter_columns`, `transpose`.
203
- see: https://ruby-doc.org/core-2.7.1/Regexp.html#class-Regexp-label-Character+Classes
204
-
205
- filter_columns:
206
- call: filter_columns="<column_name_1>,<column_name_2>,..."
207
- description: >-
208
- Removes specified columns from result. Execution is applied in the following order `format`, `replace_values`,
209
- `filter_columns`, `transpose`.
210
-
211
- transpose:
212
- call: transpose="true"
213
- description: >-
214
- Transposes the query result, i.e. columns become rows and rows become columnns. Execution is applied in the
215
- following order `format`, `replace_values`, `filter_columns`, `transpose`.
216
-
217
- column_divider:
218
- call: column_divider="<divider>"
219
- description: >-
220
- Replace the default column divider with another one. Defaults to ` | ` for being interpreted as a asciidoctor column.
221
-
222
- row_divider:
223
- call: row_divider="<divider>"
224
- description: >-
225
- Replace the default row divider with another one. Defaults to `| ` for being interpreted as a asciidoctor row.
226
-
227
- timeout:
228
- call: timeout="<timeout_in_seconds>"
229
- description: >-
230
- Set a timeout for the current query. If not overridden with `grafana-default-timeout` in the report template,
231
- this defaults to 60 seconds.
232
-
233
- # ----------------------------------
234
- # FUNCTION DOCUMENTATION STARTS HERE
235
- # ----------------------------------
236
-
237
- grafana_help:
238
- description: Show all available grafana calls within the asciidoctor templates, including available options.
239
- call: 'include::grafana_help[]'
240
-
241
- grafana_environment:
242
- description: Shows all available variables in the rendering context which can be used in the asciidoctor template.
243
- call: 'include::grafana_environment[]'
244
-
245
- grafana_alerts:
246
- description: >-
247
- Returns a table of active alert states including the specified columns and the connected information. Supports
248
- all query parameters from the Grafana Alerting API, such as `query`, `state`, `limit`, `folderId` and others.
249
- call: grafana_alerts[columns="<column_name_1>,<column_name_2>,...",options]
250
- see: https://grafana.com/docs/grafana/latest/http_api/alerting/#get-alerts
251
- options:
252
- columns:
253
- description: >-
254
- Specifies columns that shall be returned. Valid columns are `id`, `dashboardId`, `dashboardUId`, `dashboardSlug`,
255
- `panelId`, `name`, `state`, `newStateDate`, `evalDate`, `evalData` and `executionError`.
256
- call: columns="<column_name_1>,<columns_name_2>,..."
257
- panel:
258
- description: >-
259
- If specified, the resulting alerts are filtered for this panel. This option will only work, if a `dashboard`
260
- or `grafana_default_dashboard` is set.
261
- call: panel="<panel_id>"
262
- standard_options:
263
- column_divider:
264
- dashboard: >-
265
- If this option, or the global option `grafana_default_dashboard` is set, the resulting alerts will be limited to
266
- this dashboard. To show all alerts in this case, specify `dashboard=""` as option.
267
- filter_columns:
268
- format:
269
- from:
270
- instance:
271
- replace_values:
272
- row_divider:
273
- timeout:
274
- to:
275
- transpose:
276
- from_timezone:
277
- to_timezone:
278
-
279
- grafana_annotations:
280
- description: >-
281
- Returns a table of all annotations, matching the specified filter criteria and the specified columns. Supports all
282
- query parameters from the Grafana Alerting API, such as `limit`, `alertId`, `panelId` and others.
283
- call: grafana_annotations[columns="<column_name_1>,<column_name_2>,...",options]
284
- see: https://grafana.com/docs/grafana/latest/http_api/annotations/#find_annotations
285
- options:
286
- columns:
287
- description: >-
288
- Specified the columns that shall be returned. Valid columns are `id`, `alertId`, `dashboardId`, `panelId`, `userId`,
289
- `userName`, `newState`, `prevState, `time`, `timeEnd`, `text`, `metric` and `type`.
290
- call: columns="<column_name_1>,<columns_name_2>,..."
291
- panel:
292
- description: >-
293
- If specified, the resulting alerts are filtered for this panel. This option will only work, if a `dashboard` or
294
- `grafana_default_dashboard` is set.
295
- call: panel="<panel_id>"
296
- standard_options:
297
- column_divider:
298
- dashboard: >-
299
- If this option, or the global option `grafana_default_dashboard` is set, the resulting alerts will be limited to this
300
- dashboard. To show all alerts in this case, specify `dashboard=""` as option.
301
- filter_columns:
302
- format:
303
- from:
304
- instance:
305
- replace_values:
306
- row_divider:
307
- timeout:
308
- to:
309
- transpose:
310
- from_timezone:
311
- to_timezone:
312
-
313
- grafana_panel_description:
314
- description: >-
315
- Returns a description field for the specified panel. `<type>` can either be `title` or `description`.
316
- Grafana variables will be replaced in the returned value.
317
- call: 'grafana_panel_description:<panel_id>["<type>",options]'
318
- see: https://grafana.com/docs/grafana/latest/variables/templates-and-variables/#variable-syntax
319
- standard_options:
320
- dashboard:
321
- instance:
322
-
323
- grafana_panel_image:
324
- description: Includes a panel image as an image in the document. Can be called for inline-images as well as for blocks.
325
- call: 'grafana_panel_image:<panel_id>[options] or grafana_panel_image::<panel_id>[options]'
326
- options:
327
- render-height:
328
- description: can be used to override default `height` in which the panel shall be rendered
329
- call: render-height="<height>"
330
- render-width:
331
- description: can be used to override default `width` in which the panel shall be rendered
332
- call: render-width="<width>"
333
- render-theme:
334
- description: can be used to override default `theme` in which the panel shall be rendered (light by default)
335
- call: render-theme="<theme>"
336
- render-timeout:
337
- description: can be used to override default `timeout` in which the panel shall be rendered (60 seconds by default)
338
- call: render-timeout="<timeout>"
339
- standard_options:
340
- dashboard:
341
- from:
342
- instance:
343
- timeout:
344
- to:
345
- from_timezone:
346
- to_timezone:
347
-
348
- grafana_panel_query_table:
349
- description: >-
350
- Returns the results of a query, which is configured in a grafana panel, as a table in asciidoctor.
351
- Grafana variables will be replaced in the panel's SQL statement.
352
- call: 'include::grafana_panel_query_table:<panel_id>[query="<query_letter>",options]'
353
- see: https://grafana.com/docs/grafana/latest/variables/templates-and-variables/#variable-syntax
354
- options:
355
- query:
356
- call: query="<query_letter>"
357
- description: +<query_letter>+ needs to point to the grafana query which shall be evaluated, e.g. +A+ or +B+.
358
- standard_options:
359
- column_divider:
360
- dashboard:
361
- filter_columns:
362
- format:
363
- from:
364
- instance:
365
- replace_values:
366
- row_divider:
367
- timeout:
368
- to:
369
- transpose:
370
- from_timezone:
371
- to_timezone:
372
-
373
- grafana_panel_query_value:
374
- call: 'grafana_panel_query_value:<panel_id>[query="<query_letter>",options]'
375
- description: >-
376
- Returns the value in the first column and the first row of a query, which is configured in a grafana panel.
377
- Grafana variables will be replaced in the panel's SQL statement.
378
- see: https://grafana.com/docs/grafana/latest/variables/templates-and-variables/#variable-syntax
379
- options:
380
- query:
381
- call: query="<query_letter>"
382
- description: +<query_letter>+ needs to point to the grafana query which shall be evaluated, e.g. +A+ or +B+.
383
- standard_options:
384
- dashboard:
385
- filter_columns:
386
- format:
387
- from:
388
- instance:
389
- replace_values:
390
- timeout:
391
- to:
392
- from_timezone:
393
- to_timezone:
394
-
395
- grafana_sql_table:
396
- call: 'include::grafana_sql_table:<datasource_id>[sql="<sql_query>",options]'
397
- description: >-
398
- Returns a table with all results of the given query.
399
- Grafana variables will be replaced in the SQL statement.
400
- see: https://grafana.com/docs/grafana/latest/variables/templates-and-variables/#variable-syntax
401
- standard_options:
402
- column_divider:
403
- filter_columns:
404
- format:
405
- from:
406
- instance:
407
- replace_values:
408
- row_divider:
409
- timeout:
410
- to:
411
- transpose:
412
- from_timezone:
413
- to_timezone:
414
-
415
- grafana_sql_value:
416
- call: 'grafana_sql_value:<datasource_id>[sql="<sql_query>",options]'
417
- description: >-
418
- Returns the value in the first column and the first row of the given query.
419
- Grafana variables will be replaced in the SQL statement.
420
- see: https://grafana.com/docs/grafana/latest/variables/templates-and-variables/#variable-syntax
421
- standard_options:
422
- filter_columns:
423
- format:
424
- from:
425
- instance:
426
- replace_values:
427
- timeout:
428
- to:
429
- from_timezone:
430
- to_timezone:
431
- YAML_HELP
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
432
455
  end
433
456
  end
434
457
  end