prometheus-api-client 0.5.2 → 0.6.0

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
  SHA1:
3
- metadata.gz: a91e48ee3a955d0ae1126935d76701e50d69274f
4
- data.tar.gz: aea2706e58b8b7090042f981573fc85668eba423
3
+ metadata.gz: f9d556204a2bc7ffb30d4a1342ed4db68f0ca91c
4
+ data.tar.gz: 9bd9dcae811c232acd507cc2865e3d005d4d7417
5
5
  SHA512:
6
- metadata.gz: 1e7773540a0a01128436e5468135ce5a5e95966eaf30928124c5973d3c2108186f211122576aa6acaa5a341c7a580bd4d411a7c16da7fdedf7aab1bb510241c0
7
- data.tar.gz: 9a8e24d94bdd662dc6b01d1b39935d30dae2887bc71d0c697d87cfd61b6049562753c7d8854ea95649807ab0fd02870c64354740b6b9de565fbc9c873af6017e
6
+ metadata.gz: 554eece785a3c352385705ebefe7a4b0c83702d482beed3908b1e97f7b588948f71a2e35fcf5c81913c0e1bc1d22b915dc429cd8c200efcd76aea607d7f29d58
7
+ data.tar.gz: 529325a6d350c546274187cca962de4e84f8acf991c4b1f9fcc2ce26695c2550f4d5b2f6a6d516cb8b352593af8eec2ade867bc08766b38ebce01893340c29b2
data/README.md CHANGED
@@ -173,42 +173,6 @@ prometheus.targets()
173
173
 
174
174
  ```
175
175
 
176
- #### cAdvisor specialize client
177
-
178
- A cAdvisor client is a client that add object specific labels to each REST call,
179
- objects available are Node, Pod and Container.
180
-
181
- ###### Node
182
-
183
- Add the instance label, user must declare the instance on client creation.
184
-
185
- ###### Pod
186
-
187
- Add the pod_name label, user must declare the pod_name on client creation.
188
-
189
- ###### Container
190
-
191
- Add the container_name and pod_name labels, user must declare container_name and pod_name on client creation.
192
-
193
- ###### Example
194
-
195
- ```ruby
196
-
197
- # create a client for cAdvisor metrics of a Node instance 'example.com'
198
- # connected to a Prometheus server listening on http://example.com:8080
199
- prometheus = Prometheus::ApiClient::Cadvisor::Node.new(
200
- instance: 'example.com',
201
- url: 'http://example.com:8080',
202
- )
203
-
204
- # send a query request to server
205
- prometheus.query(query: 'sum(container_cpu_usage_seconds_total)')
206
- ```
207
- ```
208
- # response from server:
209
- {"resultType"=>"vector", "result"=>[{"metric"=>{}, "value"=>[1502350741.161, "6606.310387038"]}]}
210
- ```
211
-
212
176
  ## Tests
213
177
 
214
178
  Install necessary development gems with `bundle install` and run tests with
@@ -3,7 +3,6 @@
3
3
  require 'uri'
4
4
  require 'openssl'
5
5
  require 'prometheus/api_client/client'
6
- require 'prometheus/api_client/cadvisor'
7
6
 
8
7
  module Prometheus
9
8
  # Api Client is a ruby implementation for a Prometheus compatible api_client.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Prometheus
4
4
  module ApiClient
5
- VERSION = '0.5.2'
5
+ VERSION = '0.6.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prometheus-api-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaacov Zamir
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-21 00:00:00.000000000 Z
11
+ date: 2017-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -34,7 +34,6 @@ files:
34
34
  - README.md
35
35
  - lib/prometheus.rb
36
36
  - lib/prometheus/api_client.rb
37
- - lib/prometheus/api_client/cadvisor.rb
38
37
  - lib/prometheus/api_client/client.rb
39
38
  - lib/prometheus/api_client/version.rb
40
39
  homepage: https://github.com/yaacov/prometheus_api_client_ruby
@@ -1,90 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require 'prometheus/api_client/client'
4
-
5
- module Prometheus
6
- # Client is a ruby implementation for a Prometheus compatible api_client.
7
- module ApiClient
8
- # Client contains the implementation for a Prometheus compatible api_client,
9
- # With special labels for the cadvisor job.
10
- module Cadvisor
11
- # A client with special labels for cadvisor metrics
12
- class CadvisorClient < Client
13
- # Add labels to simple query variables.
14
- #
15
- # Example:
16
- # "cpu_usage" => "cpu_usage{labels...}"
17
- # "sum(cpu_usage)" => "sum(cpu_usage{labels...})"
18
- # "rate(cpu_usage[5m])" => "rate(cpu_usage{labels...}[5m])"
19
- #
20
- # Note:
21
- # Not supporting more complex queries.
22
- def update_query(query, labels)
23
- query.sub(/(?<r>\[.+\])?(?<f>[)])?$/, "{#{labels}}\\k<r>\\k<f>")
24
- end
25
-
26
- # Issues a get request to the low level client.
27
- # Update the query options to use specific labels
28
- def get(command, options)
29
- options[:query] = update_query(options[:query], @labels)
30
- @client.get(command, options)
31
- end
32
- end
33
-
34
- # A client with special labels for node cadvisor metrics
35
- class Node < CadvisorClient
36
- def initialize(options = {})
37
- instance = options[:instance]
38
-
39
- # if no instance is given, assume we want data on all nodes
40
- @labels = if instance
41
- 'job="kubernetes-cadvisor",id="/",' \
42
- "instance=\"#{instance}\""
43
- else
44
- 'job="kubernetes-cadvisor",id="/"'
45
- end
46
-
47
- super(options)
48
- end
49
- end
50
-
51
- # A client with special labels for pod cadvisor metrics
52
- class Pod < CadvisorClient
53
- def initialize(options = {})
54
- pod_name = options[:pod_name]
55
- namespace = options[:namespace] || 'default'
56
-
57
- # if no pod_name is given, assume we want data on all pods
58
- @labels = if pod_name
59
- 'job="kubernetes-cadvisor",container_name="POD",' \
60
- "pod_name=\"#{pod_name}\",namespace=\"#{namespace}\""
61
- else
62
- 'job="kubernetes-cadvisor",container_name="POD"'
63
- end
64
-
65
- super(options)
66
- end
67
- end
68
-
69
- # A client with special labels for container cadvisor metrics
70
- class Container < CadvisorClient
71
- def initialize(options = {})
72
- container_name = options[:container_name]
73
- pod_name = options[:pod_name]
74
- namespace = options[:namespace] || 'default'
75
-
76
- # if no container_name is given, assume we want data on all containers
77
- @labels = if container_name
78
- 'job="kubernetes-cadvisor",' \
79
- "namespace=\"#{namespace}\",pod_name=\"#{pod_name}\"," \
80
- "container_name=\"#{container_name}\""
81
- else
82
- 'job="kubernetes-cadvisor",container_name!="POD"'
83
- end
84
-
85
- super(options)
86
- end
87
- end
88
- end
89
- end
90
- end