This repository was archived by the owner on Sep 29, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +12
-3
lines changed
lib/prometheus/alert_buffer_client Expand file tree Collapse file tree 4 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,10 @@ alerts = prometheus.get()
3737
3838alerts = prometheus.get(generation_id: '12497ca8-b597-4590-ac5d-d55af7f3d185', from_index: 34)
3939
40+ Alerts will be returned in a Hash with following keys:
41+ * generationID
42+ * messages
43+
4044#### Posting alerts
4145\# post an alert JSON to server
4246
Original file line number Diff line number Diff line change 44prometheus = Prometheus ::AlertBufferClient ::Client . new ( url : 'http://localhost:9099' , path : '/topics/test' )
55
66alerts = prometheus . get ( generation_id : '12497ca8-b597-4590-ac5d-d55af7f3d185' , from_index : 1 )
7- puts alerts
7+
8+ puts "Generation Id: #{ alerts [ 'generationID' ] } "
9+ puts "Alerts: #{ alerts [ 'messages' ] } "
Original file line number Diff line number Diff line change @@ -49,14 +49,17 @@ def initialize(options = {})
4949 # @option options [String] :generation_id Database generation Id.
5050 # @option options [Integer] :from_index Minimal index of alerts to fetch.
5151 #
52+ # @return [Hash] response with keys: generationID, messages
5253 # All alerts will be fetched if options are omitted.
5354 def get ( options = { } )
5455 response = @client . get do |req |
5556 req . params [ 'generationID' ] = options [ :generation_id ]
5657 req . params [ 'fromIndex' ] = options [ :from_index ]
5758 end
5859
59- JSON . parse ( response . body ) [ 'messages' ]
60+ JSON . parse ( response . body )
61+ rescue
62+ raise RequestError , 'Bad response from server'
6063 end
6164
6265 # post alert:
Original file line number Diff line number Diff line change 22
33module Prometheus
44 module AlertBufferClient
5- VERSION = '0.1 .0'
5+ VERSION = '0.2 .0'
66 end
77end
You can’t perform that action at this time.
0 commit comments