27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/logstash/outputs/elasticapm.rb', line 27
def receive(event)
begin
json = event.to_json
= {}
['Content-Type'] = 'application/x-protobuf'
['Authorization'] = "ApiKey #{@api_key}"
results = JsonPath.new(@base64_encoded_proto_field).on(json)
results.each do |item|
requestBody = Base64.decode64(item)
response = RestClient.post(@uri, requestBody, )
unless response.code == 200
puts "Elastic APM request failure: error code: #{response.code}, data=>#{event}"
@logger.error("Elastic APM request failure: error code: #{response.code}, data=>#{event}")
end
end
rescue Exception => ex
puts "Exception occurred in posting to Elastic APM Server: '#{ex}', data=>#{event}"
@logger.error("Exception occurred in posting to Elastic APM Server: '#{ex}', data=>#{event}")
end
end
|