prometheus-alert-buffer-client 0.1.0 → 0.2.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dd51f95ffff24af64812c887de0d2b809896b23
|
4
|
+
data.tar.gz: 5bd2ce90b90a5a855d3066e7cc3471dc633a5b72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01d63dd67d9219c9645abbf4810fd27111b60f7cf9a0fb0db853ef467d8b520c25166619e047f31b5eafc66b0aad040404f8cf037f6fe220f91d633c4bae0514
|
7
|
+
data.tar.gz: 217b1b14ec62fe29b40b9241d1cee57ac90799def9bba1d12413aabe4d4cf9a1a3b9a8a09fc420216e8380ad645d7313ef1867a7af18903d3607b6b5b46543bb
|
data/README.md
CHANGED
@@ -36,3 +36,12 @@ alerts = prometheus.get()
|
|
36
36
|
\# get all the alerts with generation_id='12497ca8-b597-4590-ac5d-d55af7f3d185' and index >= 34
|
37
37
|
|
38
38
|
alerts = prometheus.get(generation_id: '12497ca8-b597-4590-ac5d-d55af7f3d185', from_index: 34)
|
39
|
+
|
40
|
+
Alerts will be returned in a Hash with following keys:
|
41
|
+
* generationID
|
42
|
+
* messages
|
43
|
+
|
44
|
+
#### Posting alerts
|
45
|
+
\# post an alert JSON to server
|
46
|
+
|
47
|
+
alerts = prometheus.post('{"alertId":12}')
|
@@ -5,13 +5,10 @@ require 'openssl'
|
|
5
5
|
require 'prometheus/alert_buffer_client/client'
|
6
6
|
|
7
7
|
module Prometheus
|
8
|
-
|
9
8
|
# Alert Client is a ruby implementation for a Prometheus-alert-buffer client.
|
10
9
|
module AlertBufferClient
|
11
|
-
|
12
10
|
def self.client(options = {})
|
13
11
|
Client.new(options)
|
14
12
|
end
|
15
|
-
|
16
13
|
end
|
17
14
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'json'
|
4
4
|
require 'faraday'
|
5
|
+
require 'faraday_middleware'
|
5
6
|
|
6
7
|
module Prometheus
|
7
8
|
# Alert Client is a ruby implementation for a Prometheus-alert-buffer client.
|
@@ -20,7 +21,6 @@ module Prometheus
|
|
20
21
|
},
|
21
22
|
}.freeze
|
22
23
|
|
23
|
-
|
24
24
|
# Create a Prometheus Alert client:
|
25
25
|
#
|
26
26
|
# @param [Hash] options
|
@@ -39,16 +39,19 @@ module Prometheus
|
|
39
39
|
|
40
40
|
@client = Faraday.new(
|
41
41
|
faraday_options(options),
|
42
|
-
)
|
42
|
+
) do |conn|
|
43
|
+
conn.response(:json)
|
44
|
+
conn.adapter(Faraday.default_adapter)
|
45
|
+
end
|
43
46
|
end
|
44
47
|
|
45
|
-
|
46
48
|
# Get alerts:
|
47
49
|
#
|
48
50
|
# @param [Hash] options
|
49
51
|
# @option options [String] :generation_id Database generation Id.
|
50
52
|
# @option options [Integer] :from_index Minimal index of alerts to fetch.
|
51
53
|
#
|
54
|
+
# @return [Hash] response with keys: generationID, messages
|
52
55
|
# All alerts will be fetched if options are omitted.
|
53
56
|
def get(options = {})
|
54
57
|
response = @client.get do |req|
|
@@ -56,7 +59,15 @@ module Prometheus
|
|
56
59
|
req.params['fromIndex'] = options[:from_index]
|
57
60
|
end
|
58
61
|
|
59
|
-
|
62
|
+
response.body
|
63
|
+
end
|
64
|
+
|
65
|
+
# post alert:
|
66
|
+
# @param [String] alert Alert to post
|
67
|
+
def post(alert)
|
68
|
+
@client.post do |req|
|
69
|
+
req.body = alert
|
70
|
+
end
|
60
71
|
end
|
61
72
|
|
62
73
|
# Helper function to evalueate the low level proxy option
|
@@ -88,7 +99,7 @@ module Prometheus
|
|
88
99
|
return unless headers && headers[:token]
|
89
100
|
|
90
101
|
{
|
91
|
-
Authorization: "Bearer #{headers[:token]
|
102
|
+
Authorization: "Bearer #{headers[:token]}",
|
92
103
|
}
|
93
104
|
end
|
94
105
|
|
@@ -115,7 +126,6 @@ module Prometheus
|
|
115
126
|
request: faraday_request(options),
|
116
127
|
}
|
117
128
|
end
|
118
|
-
|
119
129
|
end
|
120
130
|
end
|
121
131
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prometheus-alert-buffer-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zohar Galor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|