ruby-grafana-reporter 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/VERSION.rb +2 -2
- data/lib/grafana/abstract_datasource.rb +4 -1
- data/lib/grafana/sql_datasource.rb +32 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9e3324f4e9d6fa3a47963a73ae4371122f603039284d0b453ac2f62881c5b93
|
4
|
+
data.tar.gz: 535a8f6f2763a5689472a423090504bbd5eed6b5610a557c7d9452999694f52c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e77dd83050e40196334058503c902ac6fc9285bf13a4ac8398ec9ffcf724160b30091ac6994cbff48326b4512499ccc7f0358f291e9af417a3903b8cfb2ac32d
|
7
|
+
data.tar.gz: 2c46bc4ccdd59cd49588e292e1882662b40cde32a50898e14e33eb1f50fffdd5334c86c837bb3e249155002cd80c78af51bfd9897e176654eeece1ebd2d92084
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
[![MIT License](https://img.shields.io/github/license/divinity666/ruby-grafana-reporter.svg?style=flat-square)](https://github.com/divinity666/ruby-grafana-reporter/blob/master/LICENSE)
|
2
|
-
[![Build Status](https://
|
2
|
+
[![Build Status](https://ci.appveyor.com/api/projects/status/5ac434885onmqpm4/branch/master?svg=true)](https://ci.appveyor.com/project/divinity666/ruby-grafana-reporter/branch/master)
|
3
3
|
[![Coverage Status](https://coveralls.io/repos/github/divinity666/ruby-grafana-reporter/badge.svg?branch=master)](https://coveralls.io/github/divinity666/ruby-grafana-reporter?branch=master)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/ruby-grafana-reporter.svg)](https://badge.fury.io/rb/ruby-grafana-reporter)
|
5
5
|
|
data/lib/VERSION.rb
CHANGED
@@ -170,6 +170,7 @@ module Grafana
|
|
170
170
|
# TODO: check how multiple frames have to be handled
|
171
171
|
data = data['frames']
|
172
172
|
headers = []
|
173
|
+
|
173
174
|
data.first['schema']['fields'].each do |headline|
|
174
175
|
use_name_only = true
|
175
176
|
if not headline['config'].nil?
|
@@ -180,7 +181,9 @@ module Grafana
|
|
180
181
|
header = use_name_only ? headline['name'] : headline['config']['displayNameFromDS']
|
181
182
|
headers << header
|
182
183
|
end
|
183
|
-
|
184
|
+
|
185
|
+
# zip all result values together, so that we have one complete table
|
186
|
+
content = data.first['data']['values'][0].zip(*data.first['data']['values'][1..])
|
184
187
|
return { header: headers, content: content }
|
185
188
|
|
186
189
|
rescue
|
@@ -15,17 +15,39 @@ module Grafana
|
|
15
15
|
raise MissingSqlQueryError if query_description[:raw_query].nil?
|
16
16
|
|
17
17
|
sql = replace_variables(query_description[:raw_query], query_description[:variables])
|
18
|
-
request = {
|
19
|
-
body: {
|
20
|
-
from: query_description[:from],
|
21
|
-
to: query_description[:to],
|
22
|
-
queries: [rawSql: sql, datasourceId: id, format: 'table']
|
23
|
-
}.to_json,
|
24
|
-
request: Net::HTTP::Post
|
25
|
-
}
|
26
|
-
|
27
18
|
webrequest = query_description[:prepared_request]
|
28
|
-
|
19
|
+
request = {}
|
20
|
+
|
21
|
+
ver = query_description[:grafana_version].split('.').map{|x| x.to_i}
|
22
|
+
if ver[0] >= 8
|
23
|
+
webrequest.relative_url = '/api/ds/query'
|
24
|
+
request = {
|
25
|
+
body: {
|
26
|
+
from: query_description[:from],
|
27
|
+
to: query_description[:to],
|
28
|
+
queries: [{
|
29
|
+
datasource: { type: type, uid: uid },
|
30
|
+
datasourceId: id,
|
31
|
+
rawSql: sql,
|
32
|
+
format: 'table',
|
33
|
+
# intervalMs: '',
|
34
|
+
# maxDataPoints: 999,
|
35
|
+
refId: 'A'
|
36
|
+
}]
|
37
|
+
}.to_json,
|
38
|
+
request: Net::HTTP::Post
|
39
|
+
}
|
40
|
+
else
|
41
|
+
webrequest.relative_url = '/api/tsdb/query'
|
42
|
+
request = {
|
43
|
+
body: {
|
44
|
+
from: query_description[:from],
|
45
|
+
to: query_description[:to],
|
46
|
+
queries: [rawSql: sql, datasourceId: id, format: 'table']
|
47
|
+
}.to_json,
|
48
|
+
request: Net::HTTP::Post
|
49
|
+
}
|
50
|
+
end
|
29
51
|
webrequest.options.merge!(request)
|
30
52
|
|
31
53
|
result = webrequest.execute(query_description[:timeout])
|
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.6.
|
4
|
+
version: 0.6.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: 2022-
|
11
|
+
date: 2022-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -206,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
206
|
- !ruby/object:Gem::Version
|
207
207
|
version: '0'
|
208
208
|
requirements: []
|
209
|
-
rubygems_version: 3.1.
|
209
|
+
rubygems_version: 3.1.4
|
210
210
|
signing_key:
|
211
211
|
specification_version: 4
|
212
212
|
summary: Reporter Service for Grafana
|