prometheus-api-client 0.2.10 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +11 -5
- data/lib/prometheus/api_client.rb +1 -1
- data/lib/prometheus/api_client/cadvisor.rb +11 -16
- data/lib/prometheus/api_client/client.rb +2 -2
- data/lib/prometheus/api_client/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f98a4aea6667c830dfe09fb682ab1c02e06930a4
|
4
|
+
data.tar.gz: 2d36c78279cf1e3db674d9dc3db3a179b0525e39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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',
|
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
|
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
|
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 [
|
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 [
|
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(
|
24
|
-
|
25
|
-
zone = options[:zone] || 'default'
|
23
|
+
def initialize(options = {})
|
24
|
+
instance = options[:instance]
|
26
25
|
|
27
|
-
@labels = "job=\"kubernetes-cadvisor\",
|
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(
|
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\",
|
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(
|
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\",
|
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 [
|
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(
|