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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '00837acead340b75df1bc4dcdf93c05c8014c1317aae288191b592b77a660a7a'
4
- data.tar.gz: 2e072de19e45e7fe5f167f37ec4a88be2a482bf7843df96f059a9489e48760b6
3
+ metadata.gz: e9e3324f4e9d6fa3a47963a73ae4371122f603039284d0b453ac2f62881c5b93
4
+ data.tar.gz: 535a8f6f2763a5689472a423090504bbd5eed6b5610a557c7d9452999694f52c
5
5
  SHA512:
6
- metadata.gz: eec08117ef1a83e7c0a016e80cce31c67fcf552253b63141a440951fa94f1168531b31131ae5cc79e50ac14bf4161a867b717f1c2bfb77ed6d0edac985b7cc38
7
- data.tar.gz: fe05d5a7baeb91411fb5942602cd66a66ae8dfcc65eedb7cf421617ffa6c827f5d2a11306dc33ffae9370033a35c10883c17c11f25d8a431bebaf7ae476af4ef
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://travis-ci.com/divinity666/ruby-grafana-reporter.svg?branch=master)](https://travis-ci.com/github/divinity666/ruby-grafana-reporter?branch=master)
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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Version information
4
- GRAFANA_REPORTER_VERSION = [0, 6, 1].freeze
4
+ GRAFANA_REPORTER_VERSION = [0, 6, 2].freeze
5
5
  # Release date
6
- GRAFANA_REPORTER_RELEASE_DATE = '2022-08-30'
6
+ GRAFANA_REPORTER_RELEASE_DATE = '2022-09-14'
@@ -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
- content = data.first['data']['values'][0].zip(data.first['data']['values'][1])
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
- webrequest.relative_url = '/api/tsdb/query'
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.1
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-08-30 00:00:00.000000000 Z
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.2
209
+ rubygems_version: 3.1.4
210
210
  signing_key:
211
211
  specification_version: 4
212
212
  summary: Reporter Service for Grafana