Class: Semlogr::Sinks::Seq::SeqApi
- Inherits:
-
Object
- Object
- Semlogr::Sinks::Seq::SeqApi
- Defined in:
- lib/semlogr/sinks/seq/seq_api.rb
Instance Method Summary collapse
-
#initialize(server_url, api_key) ⇒ SeqApi
constructor
A new instance of SeqApi.
- #post_events(payload) ⇒ Object
Constructor Details
#initialize(server_url, api_key) ⇒ SeqApi
Returns a new instance of SeqApi.
7 8 9 10 |
# File 'lib/semlogr/sinks/seq/seq_api.rb', line 7 def initialize(server_url, api_key) @server_url = server_url @api_key = api_key end |
Instance Method Details
#post_events(payload) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/semlogr/sinks/seq/seq_api.rb', line 12 def post_events(payload) connection = ::Faraday.new(url: @server_url) do |c| c.request :retry c.response :raise_error c.adapter :net_http end connection.post('/api/events/raw') do |req| req.headers['Content-Type'] = 'application/vnd.serilog.clef' req.headers['X-Api-Key'] = @api_key if @api_key req.body = payload end end |