5
5
[ ![ Build Status] [ 3 ]] ( https://codeclimate.com/github/yaacov/prometheus_api_client_ruby )
6
6
[ ![ Coverage Status] [ 4 ]] ( https://coveralls.io/github/yaacov/prometheus_api_client_ruby?branch=master )
7
7
8
- A Ruby library for reading Prometheus metrics API .
8
+ A Ruby library for reading metrics stored on a Prometheus server .
9
9
10
10
## Install
11
11
@@ -61,7 +61,9 @@ prometheus.query(
61
61
" {container_name=\" prometheus-hgv4s\" ,job=\" kubernetes-nodes\" })" ,
62
62
:time => " 2015-07-01T20:10:30.781Z" ,
63
63
)
64
+ ```
64
65
66
+ ``` ruby
65
67
# send a query_range request to server
66
68
prometheus.query_range(
67
69
:query => " sum(container_cpu_usage_seconds_total" \
@@ -70,11 +72,56 @@ prometheus.query_range(
70
72
:end => " 2015-07-02T20:10:30.781Z" ,
71
73
:step => " 120s"
72
74
)
75
+ ```
73
76
77
+ Example of response to metrics request:
78
+ ```
79
+ {"resultType"=>"matrix",
80
+ "result"=>
81
+ [{"metric"=>
82
+ {"__name__"=>"container_cpu_usage_seconds_total",
83
+ "beta_kubernetes_io_arch"=>"amd64",
84
+ "beta_kubernetes_io_os"=>"linux",
85
+ "cpu"=>"cpu00",
86
+ "id"=>"/",
87
+ "instance"=>"example.com",
88
+ "job"=>"kubernetes-cadvisor",
89
+ "kubernetes_io_hostname"=>"example.com",
90
+ "region"=>"infra",
91
+ "zone"=>"default"},
92
+ "values"=>[[1502086230.781, "51264.830099022"],
93
+ [1502086470.781, "51277.367732154"]]},
94
+ {"metric"=>
95
+ {"__name__"=>"container_cpu_usage_seconds_total",
96
+ "beta_kubernetes_io_arch"=>"amd64",
97
+ "beta_kubernetes_io_os"=>"linux",
98
+ "cpu"=>"cpu01",
99
+ "id"=>"/",
100
+ "instance"=>"example.com",
101
+ "job"=>"kubernetes-cadvisor",
102
+ "kubernetes_io_hostname"=>"example.com",
103
+ "region"=>"infra",
104
+ "zone"=>"default"},
105
+ "values"=>[[1502086230.781, "53879.644934689"],
106
+ [1502086470.781, "53892.665282065"]]}]}
107
+ ```
108
+
109
+ ``` ruby
74
110
# send a label request to server
75
111
prometheus.label(' __name__' )
76
112
```
77
113
114
+ Example of response to a label request:
115
+ ```
116
+ ["kubernetes-apiservers", "kubernetes-cadvisor", "kubernetes-nodes",
117
+ "kubernetes-service-endpoints"]
118
+ ```
119
+
120
+ ``` ruby
121
+ # send a targets request to server
122
+ prometheus.targets()
123
+ ```
124
+
78
125
#### cAdvisor specialize client
79
126
80
127
``` ruby
0 commit comments