Skip to content

Instantly share code, notes, and snippets.

@lcostantini
Created March 17, 2016 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lcostantini/a1379aa6ec7328644d32 to your computer and use it in GitHub Desktop.
Save lcostantini/a1379aa6ec7328644d32 to your computer and use it in GitHub Desktop.
Configuration file for Logstash to run locally.
input {
http_poller {
# Is a hash with a list of URLs.
urls => {
"localhost-health-check" => "http://localhost:9292/health-check"
}
# Default is 1, but I don't want to make any retry.
automatic_retries => 0
# Check the endpoint in URLs every 10s.
interval => 10
# Wait no longer than 8s for the request to complete.
request_timeout => 8
# Store metadata about the request in this field.
metadata_target => http_poller_metadata
# Tag this request so we can use it to filter.
tags => anomaly
# Default is "json", but Cuba doesn't respond with JSON.
codec => "plain"
}
}
filter {
# The poller doesn't set an @status field and I want to use for filter purpose.
# In the http_poller_metadata field you'll see all the request info, included
# the status.
if [http_poller_metadata] {
mutate {
add_field => {
"@status" => "%{http_poller_metadata[code]}"
}
}
}
# Classify slow requests
if [http_poller_metadata][runtime_seconds] and [http_poller_metadata][runtime_seconds] > 0.9 {
mutate {
add_tag => "slow_requests"
}
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment