ruby-grafana-reporter 0.4.1 → 0.4.2
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 +203 -185
- data/lib/VERSION.rb +2 -2
- data/lib/grafana/abstract_datasource.rb +25 -15
- data/lib/grafana/errors.rb +10 -2
- data/lib/grafana/grafana.rb +2 -0
- data/lib/grafana/grafana_property_datasource.rb +5 -0
- data/lib/grafana/graphite_datasource.rb +27 -5
- data/lib/grafana/influxdb_datasource.rb +70 -0
- data/lib/grafana/prometheus_datasource.rb +27 -5
- data/lib/grafana/sql_datasource.rb +9 -2
- data/lib/grafana/variable.rb +0 -1
- data/lib/grafana_reporter/abstract_query.rb +124 -23
- data/lib/grafana_reporter/abstract_report.rb +21 -2
- data/lib/grafana_reporter/alerts_table_query.rb +1 -6
- data/lib/grafana_reporter/annotations_table_query.rb +1 -6
- data/lib/grafana_reporter/application/webservice.rb +1 -1
- data/lib/grafana_reporter/asciidoctor/alerts_table_include_processor.rb +5 -4
- data/lib/grafana_reporter/asciidoctor/annotations_table_include_processor.rb +5 -4
- data/lib/grafana_reporter/asciidoctor/panel_image_block_macro.rb +1 -4
- data/lib/grafana_reporter/asciidoctor/panel_image_inline_macro.rb +1 -4
- data/lib/grafana_reporter/asciidoctor/panel_property_inline_macro.rb +1 -4
- data/lib/grafana_reporter/asciidoctor/panel_query_table_include_processor.rb +1 -5
- data/lib/grafana_reporter/asciidoctor/panel_query_value_inline_macro.rb +1 -4
- data/lib/grafana_reporter/asciidoctor/processor_mixin.rb +20 -35
- data/lib/grafana_reporter/asciidoctor/report.rb +2 -14
- data/lib/grafana_reporter/asciidoctor/sql_table_include_processor.rb +1 -3
- data/lib/grafana_reporter/asciidoctor/sql_value_inline_macro.rb +1 -3
- data/lib/grafana_reporter/demo_report_wizard.rb +5 -1
- data/lib/grafana_reporter/erb/report.rb +3 -16
- data/lib/grafana_reporter/erb/report_jail.rb +21 -0
- data/lib/grafana_reporter/errors.rb +14 -0
- data/lib/grafana_reporter/help.rb +2 -2
- data/lib/grafana_reporter/panel_image_query.rb +1 -5
- data/lib/grafana_reporter/query_value_query.rb +1 -19
- data/lib/ruby_grafana_reporter.rb +0 -12
- metadata +4 -2
@@ -5,10 +5,6 @@ module GrafanaReporter
|
|
5
5
|
class PanelImageQuery < AbstractQuery
|
6
6
|
# Sets the proper render variables.
|
7
7
|
def pre_process
|
8
|
-
@from = translate_date(@from, @variables['grafana_report_timestamp'], false, @variables['from_timezone'] ||
|
9
|
-
@variables['grafana_default_from_timezone'])
|
10
|
-
@to = translate_date(@to, @variables['grafana_report_timestamp'], true, @variables['to_timezone'] ||
|
11
|
-
@variables['grafana_default_to_timezone'])
|
12
8
|
# TODO: ensure that in case of timezones are specified, that they are also forwarded to the image renderer
|
13
9
|
# rename "render-" variables
|
14
10
|
@variables = @variables.each_with_object({}) { |(k, v), h| h[k.gsub(/^render-/, '')] = v }
|
@@ -18,7 +14,7 @@ module GrafanaReporter
|
|
18
14
|
# Returns the body of the http query, which contains the raw image.
|
19
15
|
def post_process
|
20
16
|
@result = @result[:content].first
|
21
|
-
raise ImageCouldNotBeRenderedError, @panel if @result.include?('<html')
|
17
|
+
raise ::Grafana::ImageCouldNotBeRenderedError, @panel if @result.include?('<html')
|
22
18
|
end
|
23
19
|
|
24
20
|
# @see AbstractQuery#raw_query
|
@@ -3,15 +3,10 @@
|
|
3
3
|
module GrafanaReporter
|
4
4
|
# This class provides a general query implementation for any kind of single value and table queries.
|
5
5
|
class QueryValueQuery < AbstractQuery
|
6
|
-
# Translates the from and to times.
|
7
6
|
# @see Grafana::AbstractQuery#pre_process
|
8
7
|
def pre_process
|
9
8
|
@datasource = @panel.datasource if @panel
|
10
9
|
|
11
|
-
@from = translate_date(@from, @variables['grafana_report_timestamp'], false, @variables['from_timezone'] ||
|
12
|
-
@variables['grafana_default_from_timezone'])
|
13
|
-
@to = translate_date(@to, @variables['grafana_report_timestamp'], true, @variables['to_timezone'] ||
|
14
|
-
@variables['grafana_default_to_timezone'])
|
15
10
|
@variables['result_type'] ||= Variable.new('')
|
16
11
|
end
|
17
12
|
|
@@ -25,7 +20,7 @@ module GrafanaReporter
|
|
25
20
|
|
26
21
|
case @variables['result_type'].raw_value
|
27
22
|
when /(?:panel_table|sql_table)/
|
28
|
-
|
23
|
+
@result = format_table_output(@result, row_divider: @variables['row_divider'], column_divider: @variables['column_divider'])
|
29
24
|
|
30
25
|
when /(?:panel_value|sql_value)/
|
31
26
|
tmp = @result[:content] || []
|
@@ -56,19 +51,6 @@ module GrafanaReporter
|
|
56
51
|
|
57
52
|
private
|
58
53
|
|
59
|
-
def result_to_table
|
60
|
-
row_div = '| '
|
61
|
-
row_div = @variables['row_divider'].raw_value if @variables['row_divider'].is_a?(Grafana::Variable)
|
62
|
-
col_div = ' | '
|
63
|
-
col_div = @variables['column_divider'].raw_value if @variables['column_divider'].is_a?(Grafana::Variable)
|
64
|
-
|
65
|
-
@result = @result[:content].map do |row|
|
66
|
-
row_div + row.map do |item|
|
67
|
-
col_div == ' | ' ? item.to_s.gsub('|', '\\|') : item.to_s
|
68
|
-
end.join(col_div)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
54
|
def modify_results
|
73
55
|
@result = format_columns(@result, @variables['format'])
|
74
56
|
@result = replace_values(@result, @variables.select { |k, _v| k =~ /^replace_values_\d+/ })
|
@@ -18,18 +18,6 @@ require 'asciidoctor-pdf'
|
|
18
18
|
require 'zip'
|
19
19
|
require_relative 'VERSION'
|
20
20
|
|
21
|
-
# TODO: show error in document, if grafana could not be accessed
|
22
|
-
# TODO: show backtrace in extension error rescues
|
23
|
-
# TODO: improve ERB calls
|
24
|
-
# TODO: add test case for proper image generation
|
25
|
-
# TODO: allow to choose report-class during execution, not mandatory by config file
|
26
|
-
# TODO: add docu for ERB reports
|
27
|
-
# TODO: add docu for custom plugins
|
28
|
-
# TODO: add docu for webhook
|
29
|
-
|
30
|
-
# TODO: enable as asciidoctor extension
|
31
|
-
# TODO: build ADOC template as a result with resolved grafana content for further editing
|
32
|
-
|
33
21
|
folders = [
|
34
22
|
%w[grafana],
|
35
23
|
%w[grafana_reporter logger],
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-grafana-reporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Kohlmeyer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -121,6 +121,7 @@ files:
|
|
121
121
|
- "./lib/grafana/grafana_property_datasource.rb"
|
122
122
|
- "./lib/grafana/graphite_datasource.rb"
|
123
123
|
- "./lib/grafana/image_rendering_datasource.rb"
|
124
|
+
- "./lib/grafana/influxdb_datasource.rb"
|
124
125
|
- "./lib/grafana/panel.rb"
|
125
126
|
- "./lib/grafana/prometheus_datasource.rb"
|
126
127
|
- "./lib/grafana/sql_datasource.rb"
|
@@ -152,6 +153,7 @@ files:
|
|
152
153
|
- "./lib/grafana_reporter/console_configuration_wizard.rb"
|
153
154
|
- "./lib/grafana_reporter/demo_report_wizard.rb"
|
154
155
|
- "./lib/grafana_reporter/erb/report.rb"
|
156
|
+
- "./lib/grafana_reporter/erb/report_jail.rb"
|
155
157
|
- "./lib/grafana_reporter/errors.rb"
|
156
158
|
- "./lib/grafana_reporter/help.rb"
|
157
159
|
- "./lib/grafana_reporter/logger/two_way_delegate_logger.rb"
|