embulk-input-prometheus 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/embulk-input-prometheus.gemspec +1 -1
- data/lib/embulk/input/prometheus.rb +17 -3
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c4678abf5e2d81464d84ecd69c9250008289de371552ceb60b77f80a3662464
|
4
|
+
data.tar.gz: 27ac784e4779847d3da7ed459b5a0e3d97dc989d4bbbe681ed2cbf4d76636966
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 653b7b277ae38786e041fc423605f210d9abc1e2e054f199e41d3c36616939e5ad2934bc789d79de942e7c34a0033bdc21116eae6360b3d3eeda745814d4c74a
|
7
|
+
data.tar.gz: '082d0ab71d03d8264588ae98d3389dceecae6e92aed6f760380f25f194fad64bdaebd4c8216d7c090c17580b90e3e843b00199abc8f6144830ed881f07ce7bf5'
|
@@ -2,6 +2,7 @@ require 'prometheus/api_client'
|
|
2
2
|
require 'openssl'
|
3
3
|
require 'json'
|
4
4
|
require 'pp'
|
5
|
+
require 'time'
|
5
6
|
|
6
7
|
module Embulk
|
7
8
|
module Input
|
@@ -12,7 +13,9 @@ module Embulk
|
|
12
13
|
task = {
|
13
14
|
"url" => config.param("url", :string, default: 'http://localhost:9090/api/v1/'),
|
14
15
|
"query" => config.param("query", :string),
|
15
|
-
"since" => config.param("since", :integer),
|
16
|
+
"since" => config.param("since", :integer, default: 0),
|
17
|
+
"start_at" => config.param("start_at", :string, default: nil),
|
18
|
+
"end_at" => config.param("end_at", :string, default: nil),
|
16
19
|
"step" => config.param("step", :integer),
|
17
20
|
"element_key" => config.param("element_key", :string, default: 'instance'),
|
18
21
|
"tls" => config.param("tls", :hash, default: nil),
|
@@ -59,11 +62,22 @@ module Embulk
|
|
59
62
|
params[:options][n.to_sym] = task[n] if task[n]
|
60
63
|
end
|
61
64
|
|
65
|
+
start_at = if task['start_at'] && !task['start_at'].empty?
|
66
|
+
Time.parse(task['start_at'])
|
67
|
+
else
|
68
|
+
Time.now - task['since']
|
69
|
+
end
|
70
|
+
end_at = if task['end_at'] && !task['end_at'].empty?
|
71
|
+
Time.parse(task['end_at'])
|
72
|
+
else
|
73
|
+
Time.now
|
74
|
+
end
|
75
|
+
|
62
76
|
result = JSON.parse(::Prometheus::ApiClient.client(params).get(
|
63
77
|
'query_range',
|
64
78
|
query: task['query'],
|
65
|
-
start:
|
66
|
-
end:
|
79
|
+
start: start_at.strftime("%Y-%m-%dT%H:%M:%S.%LZ"),
|
80
|
+
end: end_at.strftime("%Y-%m-%dT%H:%M:%S.%LZ"),
|
67
81
|
step: "#{task['step']}s",
|
68
82
|
).body)
|
69
83
|
|
metadata
CHANGED
@@ -1,85 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-prometheus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pyama86
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: prometheus-api-client
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
18
|
version: '0'
|
19
|
+
name: prometheus-api-client
|
20
|
+
prerelease: false
|
21
|
+
type: :runtime
|
20
22
|
version_requirements: !ruby/object:Gem::Requirement
|
21
23
|
requirements:
|
22
24
|
- - ">="
|
23
25
|
- !ruby/object:Gem::Version
|
24
26
|
version: '0'
|
25
|
-
prerelease: false
|
26
|
-
type: :runtime
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: faraday
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
30
|
- - "~>"
|
32
31
|
- !ruby/object:Gem::Version
|
33
32
|
version: '0.9'
|
33
|
+
name: faraday
|
34
|
+
prerelease: false
|
35
|
+
type: :runtime
|
34
36
|
version_requirements: !ruby/object:Gem::Requirement
|
35
37
|
requirements:
|
36
38
|
- - "~>"
|
37
39
|
- !ruby/object:Gem::Version
|
38
40
|
version: '0.9'
|
39
|
-
prerelease: false
|
40
|
-
type: :runtime
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: embulk
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
44
43
|
requirements:
|
45
44
|
- - ">="
|
46
45
|
- !ruby/object:Gem::Version
|
47
46
|
version: 0.8.39
|
47
|
+
name: embulk
|
48
|
+
prerelease: false
|
49
|
+
type: :development
|
48
50
|
version_requirements: !ruby/object:Gem::Requirement
|
49
51
|
requirements:
|
50
52
|
- - ">="
|
51
53
|
- !ruby/object:Gem::Version
|
52
54
|
version: 0.8.39
|
53
|
-
prerelease: false
|
54
|
-
type: :development
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name: bundler
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
58
57
|
requirements:
|
59
58
|
- - ">="
|
60
59
|
- !ruby/object:Gem::Version
|
61
60
|
version: 1.10.6
|
61
|
+
name: bundler
|
62
|
+
prerelease: false
|
63
|
+
type: :development
|
62
64
|
version_requirements: !ruby/object:Gem::Requirement
|
63
65
|
requirements:
|
64
66
|
- - ">="
|
65
67
|
- !ruby/object:Gem::Version
|
66
68
|
version: 1.10.6
|
67
|
-
prerelease: false
|
68
|
-
type: :development
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: rake
|
71
70
|
requirement: !ruby/object:Gem::Requirement
|
72
71
|
requirements:
|
73
72
|
- - ">="
|
74
73
|
- !ruby/object:Gem::Version
|
75
74
|
version: '10.0'
|
75
|
+
name: rake
|
76
|
+
prerelease: false
|
77
|
+
type: :development
|
76
78
|
version_requirements: !ruby/object:Gem::Requirement
|
77
79
|
requirements:
|
78
80
|
- - ">="
|
79
81
|
- !ruby/object:Gem::Version
|
80
82
|
version: '10.0'
|
81
|
-
prerelease: false
|
82
|
-
type: :development
|
83
83
|
description: Loads records from Prometheus.
|
84
84
|
email:
|
85
85
|
- pyama@pepabo.com
|