prometheus-api-client 0.2.10 → 0.3.1

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: 7248e7525d856f9fbf407b8e15b6f761e84115af
4
- data.tar.gz: a590b35b49f625b63bc572948f2dbd4292b08a8c
3
+ metadata.gz: f98a4aea6667c830dfe09fb682ab1c02e06930a4
4
+ data.tar.gz: 2d36c78279cf1e3db674d9dc3db3a179b0525e39
5
5
  SHA512:
6
- metadata.gz: c7df2b7fd83c373290b1fa2bbe8335dda983f376b4371b90f34d78b12ee68e3c66e81314193ec8e5c93d1ed7da0a8f8072906733d54a42906a501164e222e8ab
7
- data.tar.gz: 8153bee7639544c55f133216e295d10f23ad82fca6045bf0686fd76268bd3cc59cac62e02fe69e580b39daf03f782214dd8ecc39edafe5c107dd71e9096a8032
6
+ metadata.gz: 662fde2340f4e588c5e874d3507958ac51db2975edd97bac9d60243d4fa83d3e82b64c8b3df57eaa72e449404cc525725e58939ac7bf8e406a67faca66004fde
7
+ data.tar.gz: 718bd0e4be1aaa2fc47f285f51f33d3f75b1b76254800438190cfbeaa5ee29a6fa8f54e4a212efa18758ca78997339e065646ebb417217df18af3fb6bdbffdc4
data/README.md CHANGED
@@ -25,7 +25,8 @@ prometheus = Prometheus::ApiClient.client
25
25
 
26
26
  prometheus.get(
27
27
  "query_range",
28
- :query => "sum(container_cpu_usage_seconds_total{container_name=\"prometheus-hgv4s\",job=\"kubernetes-nodes\"})",
28
+ :query => "sum(container_cpu_usage_seconds_total" \
29
+ "{container_name=\"prometheus-hgv4s\",job=\"kubernetes-nodes\"})",
29
30
  :start => "2015-07-01T20:10:30.781Z",
30
31
  :end => "2015-07-02T20:10:30.781Z",
31
32
  :step => "120s"
@@ -41,11 +42,13 @@ prometheus = Prometheus::ApiClient.client(url: 'http://example.com:9090')
41
42
 
42
43
  #### Authentication proxy
43
44
 
44
- If an authentication proxy ( e.g. oauth2 ) is used in a layer above the prometheus REST server, this client can use ssl and authentication headears.
45
+ If an authentication proxy ( e.g. oauth2 ) is used in a layer above the
46
+ prometheus REST server, this client can use ssl and authentication headears.
45
47
 
46
48
  ```ruby
47
49
  # return a client for host https://example.com/api/v1/ using a Bearer token "TopSecret"
48
- prometheus = Prometheus::ApiClient.client(url: 'https://example.com:443', credentials: {token: 'TopSecret'})
50
+ prometheus = Prometheus::ApiClient.client(url: 'https://example.com:443',
51
+ credentials: {token: 'TopSecret'})
49
52
  ```
50
53
 
51
54
  #### High level calls
@@ -54,13 +57,15 @@ prometheus = Prometheus::ApiClient.client(url: 'https://example.com:443', creden
54
57
 
55
58
  # send a query request to server
56
59
  prometheus.query(
57
- :query => "sum(container_cpu_usage_seconds_total{container_name=\"prometheus-hgv4s\",job=\"kubernetes-nodes\"})",
60
+ :query => "sum(container_cpu_usage_seconds_total" \
61
+ "{container_name=\"prometheus-hgv4s\",job=\"kubernetes-nodes\"})",
58
62
  :time => "2015-07-01T20:10:30.781Z",
59
63
  )
60
64
 
61
65
  # send a query_range request to server
62
66
  prometheus.query_range(
63
- :query => "sum(container_cpu_usage_seconds_total{container_name=\"prometheus-hgv4s\",job=\"kubernetes-nodes\"})",
67
+ :query => "sum(container_cpu_usage_seconds_total" \
68
+ "{container_name=\"prometheus-hgv4s\",job=\"kubernetes-nodes\"})",
64
69
  :start => "2015-07-01T20:10:30.781Z",
65
70
  :end => "2015-07-02T20:10:30.781Z",
66
71
  :step => "120s"
@@ -85,6 +90,7 @@ prometheus.query(
85
90
  :query => "sum(container_cpu_usage_seconds_total)",
86
91
  :time => "2015-07-01T20:10:30.781Z",
87
92
  )
93
+ ```
88
94
 
89
95
  ## Tests
90
96
 
@@ -11,7 +11,7 @@ module Prometheus
11
11
  # Create a Prometheus API client:
12
12
  #
13
13
  # @param [Hash] options
14
- # @option options [Hash] :url String base URL.
14
+ # @option options [String] :url Server base URL.
15
15
  # @option options [Hash] :params URI query unencoded key/value pairs.
16
16
  # @option options [Hash] :headers Unencoded HTTP header key/value pairs.
17
17
  # @option options [Hash] :request Request options.
@@ -11,7 +11,7 @@ module Prometheus
11
11
  # Create a Prometheus API client:
12
12
  #
13
13
  # @param [Hash] options
14
- # @option options [Hash] :url String base URL.
14
+ # @option options [String] :url Server base URL.
15
15
  # @option options [Hash] :params URI query unencoded key/value pairs.
16
16
  # @option options [Hash] :headers Unencoded HTTP header key/value pairs.
17
17
  # @option options [Hash] :request Request options.
@@ -20,12 +20,10 @@ module Prometheus
20
20
  #
21
21
  # A default client is created if options is omitted.
22
22
  class Node < Client
23
- def initialize(instance:, **options)
24
- region = options[:region] || 'infra'
25
- zone = options[:zone] || 'default'
23
+ def initialize(options = {})
24
+ instance = options[:instance]
26
25
 
27
- @labels = "job=\"kubernetes-cadvisor\",region=\"#{region}\"," \
28
- "zone=\"#{zone}\",instance=\"#{instance}\""
26
+ @labels = "job=\"kubernetes-cadvisor\",instance=\"#{instance}\""
29
27
  super(options)
30
28
  end
31
29
 
@@ -42,13 +40,11 @@ module Prometheus
42
40
 
43
41
  # A client with special labels for pod cadvisor metrics
44
42
  class Pod < Client
45
- def initialize(pod_name:, **options)
43
+ def initialize(options = {})
44
+ pod_name = options[:pod_name]
46
45
  namespace = options[:namespace] || 'default'
47
- region = options[:region] || 'infra'
48
- zone = options[:zone] || 'default'
49
46
 
50
- @labels = "job=\"kubernetes-cadvisor\",region=\"#{region}\"," \
51
- "zone=\"#{zone}\",namespace=\"#{namespace}\"," \
47
+ @labels = "job=\"kubernetes-cadvisor\",namespace=\"#{namespace}\"," \
52
48
  "pod_name=\"#{pod_name}\",container_name=\"POD\""
53
49
  super(options)
54
50
  end
@@ -66,13 +62,12 @@ module Prometheus
66
62
 
67
63
  # A client with special labels for container cadvisor metrics
68
64
  class Container < Client
69
- def initialize(container_name:, pod_name:, **options)
65
+ def initialize(options = {})
66
+ container_name = args[:container_name]
67
+ pod_name = args[:pod_name]
70
68
  namespace = args[:namespace] || 'default'
71
- region = options[:region] || 'infra'
72
- zone = options[:zone] || 'default'
73
69
 
74
- @labels = "job=\"kubernetes-cadvisor\",region=\"#{region}\"," \
75
- "zone=\"#{zone}\",namespace=\"#{namespace}\"," \
70
+ @labels = "job=\"kubernetes-cadvisor\",namespace=\"#{namespace}\"," \
76
71
  "pod_name=\"#{pod_name}\",container_name=\"#{container_name}\""
77
72
  super(options)
78
73
  end
@@ -24,7 +24,7 @@ module Prometheus
24
24
  # Create a Prometheus API client:
25
25
  #
26
26
  # @param [Hash] options
27
- # @option options [Hash] :url String base URL.
27
+ # @option options [String] :url server base URL.
28
28
  # @option options [Hash] :params URI query unencoded key/value pairs.
29
29
  # @option options [Hash] :headers Unencoded HTTP header key/value pairs.
30
30
  # @option options [Hash] :request Request options.
@@ -32,7 +32,7 @@ module Prometheus
32
32
  # @option options [Hash] :proxy Proxy options.
33
33
  #
34
34
  # A default client is created if options is omitted.
35
- def initialize(options)
35
+ def initialize(options = {})
36
36
  options = DEFAULT_ARGS.merge(options)
37
37
 
38
38
  @client = Faraday.new(
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Prometheus
4
4
  module ApiClient
5
- VERSION = '0.2.10'
5
+ VERSION = '0.3.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prometheus-api-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaacov Zamir