lib/logstash/inputs/http_poller.rb in logstash-input-http_poller-1.0.2 vs lib/logstash/inputs/http_poller.rb in logstash-input-http_poller-1.1.0
- old
+ new
@@ -29,11 +29,11 @@
# }
# request_timeout => 60
# interval => 60
# codec => "json"
# # A hash of request metadata info (timing, response headers, etc.) will be sent here
-# metadata_target => "_http_poller_metadata"
+# metadata_target => "http_poller_metadata"
# }
# }
#
# output {
# stdout {
@@ -182,12 +182,12 @@
event.tag("_http_request_failure")
# This is also in the metadata, but we send it anyone because we want this
# persisted by default, whereas metadata isn't. People don't like mysterious errors
- event["_http_request_failure"] = {
- "url" => @urls[name], # We want the exact parameter they passed in
+ event["http_request_failure"] = {
+ "request" => structure_request(request),
"name" => name,
"error" => exception.to_s,
"backtrace" => exception.backtrace,
"runtime_seconds" => execution_time
}
@@ -212,11 +212,11 @@
private
def event_metadata(name, request, response=nil, execution_time=nil)
m = {
"name" => name,
"host" => @host,
- "url" => @urls[name]
+ "request" => structure_request(request),
}
m["runtime_seconds"] = execution_time
if response
@@ -225,7 +225,18 @@
m["response_message"] = response.message
m["times_retried"] = response.times_retried
end
m
+ end
+
+ private
+ # Turn [method, url, spec] requests into a hash for friendlier logging / ES indexing
+ def structure_request(request)
+ method, url, spec = request
+ # Flatten everything into the 'spec' hash, also stringify any keys to normalize
+ Hash[(spec||{}).merge({
+ "method" => method.to_s,
+ "url" => url,
+ }).map {|k,v| [k.to_s,v] }]
end
end