prometheus-api-client 0.4.2 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8074c0b0a28baf98df9bd1584a8967da123428be
4
- data.tar.gz: 19f4184ce0b2417ca1d831f63ad57200173b1e41
3
+ metadata.gz: 05ac806cc363c0bd274032ab1a07877f09e774f4
4
+ data.tar.gz: b1612a15ccf17eb234b3abff6e34c7e71217a9ca
5
5
  SHA512:
6
- metadata.gz: 8feafbc014d92d7d3bbea17b276b101742cf0951010cc7b290445951cc85f1eb69d0922b5ed395e540a3de7234b9a51e09f7ab221ca0fbc095c8dbc94193a94c
7
- data.tar.gz: 6aefd696c18b8fd0513095d8c7dec468b122e25cbc30f1a475c2d4c623659b0be8d258283b4b15efc1e484d96b10e29d4d12fa09beb3e27fc0e5d18b7a589dac
6
+ metadata.gz: b83bcd065a1b5d20a06893192ad165443d114bdc1ce373633f0484a7e688c5a7f9073cc65d800318f47d5d96aeb37a4575acc692d70d19c049c8e1200f22abc8
7
+ data.tar.gz: 16ac21572fb55cdf744eb3a7d7c83d90e756eae83bb7c0c5b6677fecc74e5301edc8abac774ce57dafcef7c134fb431b1f5c2a93ee922bd4851c6d3b95186cf6
data/README.md CHANGED
@@ -47,8 +47,8 @@ prometheus = Prometheus::ApiClient.client(url: 'https://example.com:443'
47
47
  ###### query
48
48
 
49
49
  ```ruby
50
- require 'prometheus/api_client'
51
50
 
51
+ # send a low level get request to server
52
52
  prometheus.get(
53
53
  'query_range',
54
54
  query: 'sum(container_cpu_usage_seconds_total' \
@@ -36,8 +36,14 @@ module Prometheus
36
36
  def initialize(options = {})
37
37
  instance = options[:instance]
38
38
 
39
- @labels = "job=\"kubernetes-cadvisor\",instance=\"#{instance}\"," \
40
- 'id="/"'
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
+
41
47
  super(options)
42
48
  end
43
49
  end
@@ -48,8 +54,14 @@ module Prometheus
48
54
  pod_name = options[:pod_name]
49
55
  namespace = options[:namespace] || 'default'
50
56
 
51
- @labels = "job=\"kubernetes-cadvisor\",namespace=\"#{namespace}\"," \
52
- "pod_name=\"#{pod_name}\",container_name=\"POD\""
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
+
53
65
  super(options)
54
66
  end
55
67
  end
@@ -61,8 +73,15 @@ module Prometheus
61
73
  pod_name = options[:pod_name]
62
74
  namespace = options[:namespace] || 'default'
63
75
 
64
- @labels = "job=\"kubernetes-cadvisor\",namespace=\"#{namespace}\"," \
65
- "pod_name=\"#{pod_name}\",container_name=\"#{container_name}\""
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
+
66
85
  super(options)
67
86
  end
68
87
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Prometheus
4
4
  module ApiClient
5
- VERSION = '0.4.2'
5
+ VERSION = '0.5.1'
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.4.2
4
+ version: 0.5.1
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-10 00:00:00.000000000 Z
11
+ date: 2017-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday