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 +25
-2
lines changed
lib/prometheus/alert_buffer_client Expand file tree Collapse file tree 4 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -36,3 +36,8 @@ alerts = prometheus.get()
3636\# get all the alerts with generation_id='12497ca8-b597-4590-ac5d-d55af7f3d185' and index >= 34
3737
3838alerts = prometheus.get(generation_id: '12497ca8-b597-4590-ac5d-d55af7f3d185', from_index: 34)
39+
40+ #### Posting alerts
41+ \# post an alert JSON to server
42+
43+ alerts = prometheus.post('{"alertId":12}')
Original file line number Diff line number Diff line change 11require 'prometheus/alert_buffer_client'
22
33# returns a client
4- prometheus = Prometheus ::AlertBufferClient ::Client . new ( url : 'http://localhost:9099' , path : '/topics/zgalor ' )
4+ prometheus = Prometheus ::AlertBufferClient ::Client . new ( url : 'http://localhost:9099' , path : '/topics/test ' )
55
6- alerts = prometheus . get ( generation_id : '12497ca8-b597-4590-ac5d-d55af7f3d185' , from_index : 5 )
6+ alerts = prometheus . get ( generation_id : '12497ca8-b597-4590-ac5d-d55af7f3d185' , from_index : 1 )
77puts alerts
Original file line number Diff line number Diff line change 1+ require 'prometheus/alert_buffer_client'
2+
3+ # returns a client
4+ prometheus = Prometheus ::AlertBufferClient ::Client . new ( url : 'http://localhost:9099' , path : '/topics/test' )
5+
6+ prometheus . post '{"posted":"alert"}'
7+ prometheus . post '{"alertId":12}'
8+
Original file line number Diff line number Diff line change @@ -59,6 +59,16 @@ def get(options = {})
5959 JSON . parse ( response . body ) [ 'messages' ]
6060 end
6161
62+ # post alert:
63+ # @param [String] alert Alert to post
64+ def post ( alert )
65+ @client . post do |req |
66+ req . body = alert
67+ end
68+ rescue
69+ raise RequestError , 'Bad response from server'
70+ end
71+
6272 # Helper function to evalueate the low level proxy option
6373 def faraday_proxy ( options )
6474 return options [ :proxy ] if options [ :proxy ]
You can’t perform that action at this time.
0 commit comments