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.
- checksums.yaml +4 -4
- data/README.md +337 -170
- data/bin/ruby-grafana-reporter +5 -5
- data/lib/VERSION.rb +3 -2
- data/lib/grafana/abstract_datasource.rb +149 -0
- data/lib/grafana/dashboard.rb +1 -3
- data/lib/grafana/errors.rb +20 -5
- data/lib/grafana/grafana.rb +52 -57
- data/lib/grafana/grafana_alerts_datasource.rb +57 -0
- data/lib/grafana/grafana_annotations_datasource.rb +56 -0
- data/lib/grafana/grafana_property_datasource.rb +37 -0
- data/lib/grafana/graphite_datasource.rb +72 -0
- data/lib/grafana/image_rendering_datasource.rb +44 -0
- data/lib/grafana/influxdb_datasource.rb +70 -0
- data/lib/grafana/panel.rb +10 -4
- data/lib/grafana/prometheus_datasource.rb +67 -0
- data/lib/grafana/sql_datasource.rb +70 -0
- data/lib/grafana/unsupported_datasource.rb +7 -0
- data/lib/grafana/variable.rb +27 -21
- data/lib/grafana/webrequest.rb +71 -0
- data/lib/grafana_reporter/abstract_query.rb +478 -0
- data/lib/grafana_reporter/abstract_report.rb +152 -18
- data/lib/grafana_reporter/abstract_table_format_strategy.rb +34 -0
- data/lib/grafana_reporter/alerts_table_query.rb +43 -0
- data/lib/grafana_reporter/annotations_table_query.rb +42 -0
- data/lib/grafana_reporter/application/application.rb +28 -25
- data/lib/grafana_reporter/application/webservice.rb +80 -39
- data/lib/grafana_reporter/asciidoctor/adoc_plain_table_format_strategy.rb +25 -0
- data/lib/grafana_reporter/asciidoctor/alerts_table_include_processor.rb +92 -0
- data/lib/grafana_reporter/asciidoctor/annotations_table_include_processor.rb +91 -0
- data/lib/grafana_reporter/asciidoctor/help.rb +336 -313
- data/lib/grafana_reporter/asciidoctor/panel_image_block_macro.rb +78 -0
- data/lib/grafana_reporter/asciidoctor/panel_image_inline_macro.rb +80 -0
- data/lib/grafana_reporter/asciidoctor/panel_property_inline_macro.rb +74 -0
- data/lib/grafana_reporter/asciidoctor/panel_query_table_include_processor.rb +99 -0
- data/lib/grafana_reporter/asciidoctor/panel_query_value_inline_macro.rb +93 -0
- data/lib/grafana_reporter/asciidoctor/processor_mixin.rb +50 -0
- data/lib/grafana_reporter/asciidoctor/report.rb +41 -82
- data/lib/grafana_reporter/asciidoctor/show_environment_include_processor.rb +46 -0
- data/lib/grafana_reporter/asciidoctor/show_help_include_processor.rb +35 -0
- data/lib/grafana_reporter/asciidoctor/sql_table_include_processor.rb +94 -0
- data/lib/grafana_reporter/asciidoctor/sql_value_inline_macro.rb +90 -0
- data/lib/grafana_reporter/asciidoctor/value_as_variable_include_processor.rb +90 -0
- data/lib/grafana_reporter/configuration.rb +26 -8
- data/lib/grafana_reporter/console_configuration_wizard.rb +109 -67
- data/lib/grafana_reporter/csv_table_format_strategy.rb +23 -0
- data/lib/grafana_reporter/demo_report_wizard.rb +104 -0
- data/lib/grafana_reporter/erb/demo_report_builder.rb +46 -0
- data/lib/grafana_reporter/erb/report.rb +36 -0
- data/lib/grafana_reporter/erb/report_jail.rb +21 -0
- data/lib/grafana_reporter/errors.rb +57 -0
- data/lib/grafana_reporter/logger/{two_way_logger.rb → two_way_delegate_logger.rb} +1 -1
- data/lib/grafana_reporter/panel_image_query.rb +25 -0
- data/lib/grafana_reporter/panel_property_query.rb +22 -0
- data/lib/grafana_reporter/query_value_query.rb +61 -0
- data/lib/grafana_reporter/report_webhook.rb +39 -0
- data/lib/ruby_grafana_extension.rb +8 -0
- data/lib/{ruby-grafana-reporter.rb → ruby_grafana_reporter.rb} +1 -3
- metadata +49 -38
- data/lib/grafana/abstract_panel_query.rb +0 -22
- data/lib/grafana/abstract_query.rb +0 -132
- data/lib/grafana/abstract_sql_query.rb +0 -51
- data/lib/grafana/panel_image_query.rb +0 -52
- data/lib/grafana_reporter/asciidoctor/alerts_table_query.rb +0 -101
- data/lib/grafana_reporter/asciidoctor/annotations_table_query.rb +0 -96
- data/lib/grafana_reporter/asciidoctor/errors.rb +0 -40
- data/lib/grafana_reporter/asciidoctor/extensions/alerts_table_include_processor.rb +0 -92
- data/lib/grafana_reporter/asciidoctor/extensions/annotations_table_include_processor.rb +0 -91
- data/lib/grafana_reporter/asciidoctor/extensions/panel_image_block_macro.rb +0 -69
- data/lib/grafana_reporter/asciidoctor/extensions/panel_image_inline_macro.rb +0 -68
- data/lib/grafana_reporter/asciidoctor/extensions/panel_property_inline_macro.rb +0 -61
- data/lib/grafana_reporter/asciidoctor/extensions/panel_query_table_include_processor.rb +0 -78
- data/lib/grafana_reporter/asciidoctor/extensions/panel_query_value_inline_macro.rb +0 -73
- data/lib/grafana_reporter/asciidoctor/extensions/processor_mixin.rb +0 -20
- data/lib/grafana_reporter/asciidoctor/extensions/show_environment_include_processor.rb +0 -43
- data/lib/grafana_reporter/asciidoctor/extensions/show_help_include_processor.rb +0 -30
- data/lib/grafana_reporter/asciidoctor/extensions/sql_table_include_processor.rb +0 -70
- data/lib/grafana_reporter/asciidoctor/extensions/sql_value_inline_macro.rb +0 -66
- data/lib/grafana_reporter/asciidoctor/extensions/value_as_variable_include_processor.rb +0 -88
- data/lib/grafana_reporter/asciidoctor/panel_first_value_query.rb +0 -36
- data/lib/grafana_reporter/asciidoctor/panel_image_query.rb +0 -28
- data/lib/grafana_reporter/asciidoctor/panel_property_query.rb +0 -44
- data/lib/grafana_reporter/asciidoctor/panel_table_query.rb +0 -40
- data/lib/grafana_reporter/asciidoctor/query_mixin.rb +0 -312
- data/lib/grafana_reporter/asciidoctor/sql_first_value_query.rb +0 -42
- 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
|
-
|
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.
|
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":
|
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']}
|
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
|
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
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
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
|
+
|
247
|
+
<% if (report.status == 'finished') || (report.status == 'cancelled') %>
|
248
|
+
<a href="/view_report?report_id=<%= report.object_id %>">View</a>
|
249
|
+
<% end %>
|
250
|
+
|
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,
|
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 <<
|
37
|
-
result <<
|
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 <<
|
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 : [])
|
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']}
|
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
|
-
|
126
|
-
global_options:
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
standard_options:
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
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
|