class LogStash::Outputs::Boundary
This output lets you send annotations to Boundary
based on Logstash events
Note that since Logstash maintains no state these will be one-shot events
By default the start and stop time will be the event timestamp
Public Instance Methods
receive(event)
click to toggle source
# File lib/logstash/outputs/boundary.rb, line 69 def receive(event) boundary_event = Hash.new boundary_keys = ['type', 'subtype', 'creation_time', 'end_time', 'links', 'tags', 'loc'] boundary_event['start_time'] = event.sprintf(@start_time) if @start_time boundary_event['end_time'] = event.sprintf(@end_time) if @end_time boundary_event['type'] = event.sprintf(@btype) if @btype boundary_event['subtype'] = event.sprintf(@bsubtype) if @bsubtype boundary_event['tags'] = @btags.collect { |x| event.sprintf(x) } if @btags if @auto boundary_fields = event.get('@fields').select { |k| boundary_keys.member? k } boundary_event = boundary_fields.merge boundary_event end boundary_event = { 'type' => event.sprintf("%{message}"), 'subtype' => event.sprintf("%{type}"), 'start_time' => event.timestamp.to_i, 'end_time' => event.timestamp.to_i, 'links' => [], 'tags' => event["tags"], }.merge boundary_event request = Net::HTTP::Post.new(@uri.path) request.basic_auth(@api_key, '') @logger.debug("Boundary event", :boundary_event => boundary_event) begin request.body = LogStash::Json.dump(boundary_event) request.add_field("Content-Type", 'application/json') response = @client.request(request) @logger.warn("Boundary convo", :request => request.inspect, :response => response.inspect) raise unless response.code == '201' rescue Exception => e @logger.warn( "Unhandled exception", :request => request.inspect, :response => response.inspect, :exception => e.inspect ) end end
register()
click to toggle source
# File lib/logstash/outputs/boundary.rb, line 57 def register require "net/https" require "uri" @url = "https://api.boundary.com/#{@org_id}/annotations" @uri = URI.parse(@url) @client = Net::HTTP.new(@uri.host, @uri.port) @client.use_ssl = true # Boundary cert doesn't verify @client.verify_mode = OpenSSL::SSL::VERIFY_NONE end