ruby-grafana-reporter 0.9.3 → 0.9.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/lib/VERSION.rb +2 -2
- data/lib/grafana/dashboard.rb +1 -2
- data/lib/grafana/grafana_alerts_datasource.rb +1 -0
- data/lib/grafana/variable.rb +1 -1
- data/lib/grafana_reporter/application/application.rb +1 -0
- data/lib/grafana_reporter/asciidoctor/panel_query_table_include_processor.rb +1 -0
- data/lib/grafana_reporter/asciidoctor/panel_query_value_inline_macro.rb +1 -0
- data/lib/grafana_reporter/asciidoctor/report.rb +9 -16
- data/lib/grafana_reporter/asciidoctor/sql_table_include_processor.rb +2 -0
- data/lib/grafana_reporter/asciidoctor/sql_value_inline_macro.rb +2 -0
- data/lib/grafana_reporter/console_configuration_wizard.rb +3 -1
- data/lib/ruby_grafana_reporter.rb +2 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57a3edcb1aa6c41ed2a26688dc6a8a80fba3b9169aa79ee061eeb2d2c0df1cb9
|
4
|
+
data.tar.gz: 897ae84eb2672b645528e118ff7107e2fab7a4f334f63a4c87bb29a020cf93a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3889cace3794d62bfd50978a24c4eb39cda1148398a4bed8c4354d5c51ad339faa7da7a81b4f001cb29c383ac98334494520a9cbeec2b44019dcafae883bfdb
|
7
|
+
data.tar.gz: 9a7fbf743f0e48e114deaa1d518ba993ea0318229ab391d90481bad43f859b20fca9f8ffaafe6799729a81ace22673d4904797963c776cf9a22c942289f35c23
|
data/lib/VERSION.rb
CHANGED
data/lib/grafana/dashboard.rb
CHANGED
data/lib/grafana/variable.rb
CHANGED
@@ -240,7 +240,7 @@ module Grafana
|
|
240
240
|
if !@config['current'].nil?
|
241
241
|
self.raw_value = @config['current']['value']
|
242
242
|
else
|
243
|
-
raise GrafanaError.new("
|
243
|
+
raise GrafanaError.new("Dashboard variable with type '#{@config['type']}' and name '#{@config['name']}' cannot be handled properly by the reporter in queries. Check your resulting report and raise a ticket on github if you face issues.")
|
244
244
|
end
|
245
245
|
end
|
246
246
|
end
|
@@ -134,6 +134,7 @@ module GrafanaReporter
|
|
134
134
|
begin
|
135
135
|
template_ext = config.report_class.default_template_extension
|
136
136
|
report_ext = config.report_class.default_result_extension
|
137
|
+
report_ext = 'zip' if config.default_document_attributes["convert-backend"] != "pdf" and not config.default_document_attributes["convert-backend"].nil?
|
137
138
|
default_to_file = File.basename(config.template.to_s.gsub(/(?:\.#{template_ext})?$/, ".#{report_ext}"))
|
138
139
|
|
139
140
|
to_file = config.to_file
|
@@ -41,36 +41,29 @@ module GrafanaReporter
|
|
41
41
|
::Asciidoctor.convert_file(@template, extension_registry: registry, backend: attrs['convert-backend'],
|
42
42
|
to_file: path, attributes: attrs, header_footer: true)
|
43
43
|
|
44
|
-
# store report including
|
44
|
+
# store report including all images as ZIP file, if the result is not a PDF
|
45
45
|
if attrs['convert-backend'] != 'pdf'
|
46
46
|
# build zip file
|
47
|
-
zip_file = Tempfile.new('gf_zip')
|
48
47
|
buffer = Zip::OutputStream.write_buffer do |zipfile|
|
49
48
|
# add report file
|
50
|
-
zipfile.put_next_entry("#{path.gsub(@config.reports_folder, '')}.#{attrs['convert-backend']}")
|
51
|
-
zipfile.write File.
|
49
|
+
zipfile.put_next_entry("#{path.gsub(@config.reports_folder, '').gsub(/\.[\w\d]+$/, '')}.#{attrs['convert-backend']}")
|
50
|
+
zipfile.write File.open(path, 'rb') { |f| f.read }
|
52
51
|
|
53
52
|
# add image files
|
54
53
|
@image_files.each do |file|
|
55
54
|
zipfile.put_next_entry(file.path.gsub(@config.images_folder, ''))
|
56
|
-
zipfile.write File.
|
55
|
+
zipfile.write File.open(file.path, 'rb') { |f| f.read }
|
57
56
|
end
|
58
57
|
end
|
59
|
-
File.open(zip_file, 'wb') do |f|
|
60
|
-
f.write buffer.string
|
61
|
-
end
|
62
58
|
|
63
|
-
#
|
64
|
-
zip_file.rewind
|
59
|
+
# write zip file
|
65
60
|
begin
|
66
|
-
File.
|
61
|
+
File.open(path, 'wb') do |f|
|
62
|
+
f.write buffer.string
|
63
|
+
end
|
67
64
|
rescue StandardError => e
|
68
|
-
logger.fatal("Could not overwrite
|
65
|
+
logger.fatal("Could not overwrite file '#{path}' with zipped file. (#{e.message}).")
|
69
66
|
end
|
70
|
-
|
71
|
-
# cleanup temporary zip file
|
72
|
-
zip_file.close
|
73
|
-
zip_file.unlink
|
74
67
|
end
|
75
68
|
|
76
69
|
clean_image_files
|
@@ -84,6 +84,8 @@ module GrafanaReporter
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
return nil unless ref_id
|
87
|
+
# FIXME this filters out e.g. prometheus in demo reports, as the query method returns a Hash instead of a string
|
88
|
+
return nil unless panel.query(ref_id).is_a?(String)
|
87
89
|
|
88
90
|
"|===\ninclude::grafana_sql_table:#{panel.dashboard.grafana.datasource_by_model_entry(panel.model['datasource']).id}"\
|
89
91
|
"[sql=\"#{panel.query(ref_id).gsub(/"/, '\"').gsub("\r\n", ' ').gsub("\n", ' ').gsub(/\\/, '\\\\')}\",filter_columns=\"time\","\
|
@@ -89,6 +89,8 @@ module GrafanaReporter
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
return nil unless ref_id
|
92
|
+
# FIXME this filters out e.g. prometheus in demo reports, as the query method returns a Hash instead of a string
|
93
|
+
return nil unless panel.query(ref_id).is_a?(String)
|
92
94
|
|
93
95
|
"grafana_sql_value:#{panel.dashboard.grafana.datasource_by_model_entry(panel.model['datasource']).id}"\
|
94
96
|
"[sql=\"#{panel.query(ref_id).gsub(/"/, '\"').gsub("\r\n", ' ').gsub("\n", ' ').gsub(/\\/, '\\\\')}\",from=\"now-1h\","\
|
@@ -319,8 +319,10 @@ default-document-attributes:
|
|
319
319
|
end
|
320
320
|
|
321
321
|
def user_input(text, default)
|
322
|
+
$stdout.sync = true
|
322
323
|
print "#{text} [#{default}]: "
|
323
|
-
|
324
|
+
$stdout.sync = false
|
325
|
+
input = gets.gsub(/[\n\r]*$/, '')
|
324
326
|
input = default if input.empty?
|
325
327
|
input
|
326
328
|
end
|
@@ -1,9 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'rubygems'
|
4
|
-
require 'rubygems/name_tuple'
|
5
|
-
require 'rubygems/specification_policy'
|
6
|
-
require 'rubygems/ext'
|
3
|
+
require 'rubygems' # for OCRAN
|
7
4
|
require 'net/http'
|
8
5
|
require 'fileutils'
|
9
6
|
require 'yaml'
|
@@ -17,7 +14,7 @@ require 'date'
|
|
17
14
|
require 'time'
|
18
15
|
require 'logger'
|
19
16
|
require 'asciidoctor'
|
20
|
-
require 'asciidoctor/
|
17
|
+
require 'asciidoctor/converter/html5' # for OCRAN
|
21
18
|
require 'asciidoctor-pdf'
|
22
19
|
require 'zip'
|
23
20
|
require_relative 'VERSION'
|
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.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Kohlmeyer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|