prometheus-api-client 0.0.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 +7 -0
- data/README.md +31 -0
- data/lib/prometheus.rb +5 -0
- data/lib/prometheus/api_client.rb +29 -0
- data/lib/prometheus/api_client/version.rb +7 -0
- metadata +76 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 68b5e8ad6dbe1997d62603c9513afbc071e60866
|
4
|
+
data.tar.gz: a07c99492ae8c8757ea8a9661545c877ba2f625c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 41fa1d531d03bc368bc20827979637d51e8b802aed1d003562eddd8fd1832dda6cba03b92affb6550566b4802eec55eb313b2fa5d17bfc7cec91389d59957166
|
7
|
+
data.tar.gz: b7d3cf27b368f189bbc28136cdf1101fa9965d6916de13b263b8bf207c5783b6430281b6fd6dad53c523493c295441907585f58652758d869bf38e282de916be
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Prometheus Ruby Client
|
2
|
+
|
3
|
+
A Ruby library for reading Prometheus metrics API.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
### Overview
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
require 'prometheus/api_client'
|
11
|
+
|
12
|
+
# returns a default client
|
13
|
+
prometheus = Prometheus::ApiClient.client
|
14
|
+
|
15
|
+
prometheus.get(
|
16
|
+
"query_range",
|
17
|
+
:query => "sum(container_cpu_usage_seconds_total{container_name=\"prometheus-hgv4s\",job=\"kubernetes-nodes\"})",
|
18
|
+
:start => "2015-07-01T20:10:30.781Z",
|
19
|
+
:end => "2015-07-02T20:10:30.781Z",
|
20
|
+
:step => "120s"
|
21
|
+
)
|
22
|
+
```
|
23
|
+
|
24
|
+
## Tests
|
25
|
+
|
26
|
+
Install necessary development gems with `bundle install` and run tests with
|
27
|
+
rspec:
|
28
|
+
|
29
|
+
```bash
|
30
|
+
rake
|
31
|
+
```
|
data/lib/prometheus.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'faraday'
|
4
|
+
|
5
|
+
module Prometheus
|
6
|
+
# Client is a ruby implementation for a Prometheus compatible api_client.
|
7
|
+
module ApiClient
|
8
|
+
# Returns a default client object
|
9
|
+
def self.client(uri, credentials={}, options={})
|
10
|
+
@args = { url: uri.to_s, request: { open_timeout: 2, timeout: 5 } }
|
11
|
+
@args.merge!(prometheus_args(credentials, options))
|
12
|
+
|
13
|
+
Faraday.new(@args)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.prometheus_args(credentials, options)
|
17
|
+
{
|
18
|
+
proxy: options[:http_proxy_uri],
|
19
|
+
headers: { Authorization: 'Bearer ' + credentials[:token].to_s },
|
20
|
+
ssl: if options[:verify_ssl]
|
21
|
+
{
|
22
|
+
verify: options[:verify_ssl] != OpenSSL::SSL::VERIFY_NONE,
|
23
|
+
cert_store: options[:ssl_cert_store],
|
24
|
+
}
|
25
|
+
end,
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: prometheus-api-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yaacov Zamir
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: quantile
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.12.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.12.0
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- kobi.zamir@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- README.md
|
49
|
+
- lib/prometheus.rb
|
50
|
+
- lib/prometheus/api_client.rb
|
51
|
+
- lib/prometheus/api_client/version.rb
|
52
|
+
homepage: https://github.com/yaacov/prometheus_api_client_ruby
|
53
|
+
licenses:
|
54
|
+
- Apache-2.0
|
55
|
+
metadata: {}
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 2.6.11
|
73
|
+
signing_key:
|
74
|
+
specification_version: 4
|
75
|
+
summary: A suite of reading metric valuesthat are exposed through an API interface.
|
76
|
+
test_files: []
|