Simple logstash HTTP poller

Hello,

Can someone give me a simple HTTP poller config to check the 200 response on my URL.
with a filter to check response output.

I tried creating config but its not working .

Thanks in Advance

Please show us what you have so far and what you get when you use that configuration. Add a stdout { codec => rubydebug { metadata => true } } output to get the results.

Hello,

Below is my conf file

    "@host" => "%{http_poller_metadata[name]}"
  }
}

}
}

Classify slow requests

filter {

if [http_poller_metadata][runtime_seconds] and [http_poller_metadata][runtime_seconds] > 0.5 {
mutate {
add_tag => "slow_request"
}
}

}

Classify requests that can't connect or have an unexpected response code

filter {

if [http_request_failure] or
[http_poller_metadata][code] != 200 {
# Tag all these events as being bad
mutate {
add_tag => "bad_request"
}
}

}
output {

elasticsearch {

hosts => "localhost:9200"

index => "http-%{+YYYY.MM.dd}"

#}
#}

stdout { codec => rubydebug { metadata => true } }
62,1 Bot

Your post is incomplete and doesn't include all configuration. You also did no include what you currently get from the stdout output (I suggest you disable the elasticsearch output for now while we debug this).

Hello,

When i execute

sudo /opt/logstash/bin/logstash -f /etc/logstash/conf.d/logstash-http.conf

I get this output on the screen

Error: Expected one of #, if, ", ', } at line 64, column 1 (byte 1430) after output {

elasticsearch {

hosts => "localhost:9200"

index => "http-%{+YYYY.MM.dd}"

#}
#}

stdout { codec => rubydebug { metadata => true } }

{:level=>:error}


The content of logstash-http.conf

input {
http_poller {
urls => {
"localhost" => "http://www.google.com"
}
automatic_retries => 0
# Check the site every 10s
interval => 10
# Wait no longer than 8 seconds 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 that we can throttle it in a filter
tags => website_healthcheck
}
}

filter {

The poller doesn't set an '@host' field because it may or may not have meaning

In this case we can set it to the 'name' of the host which will be 'localhost'

The name is the key used in the poller's 'url' config

if [http_poller_metadata] {
mutate {
add_field => {
"@host" => "%{http_poller_metadata[name]}"
}
}
}
}

Classify slow requests

filter {

if [http_poller_metadata][runtime_seconds] and [http_poller_metadata][runtime_seconds] > 0.5 {
mutate {
add_tag => "slow_request"
}
}

}

Classify requests that can't connect or have an unexpected response code

filter {

if [http_request_failure] or
[http_poller_metadata][code] != 200 {
# Tag all these events as being bad
mutate {
add_tag => "bad_request"
}
}

}
output {

elasticsearch {

hosts => "localhost:9200"

index => "http-%{+YYYY.MM.dd}"

#}
#}

stdout { codec => rubydebug { metadata => true } }

Error: Expected one of #, if, ", ', } at line 64, column 1 (byte 1430) after output {

So... what on line 64 of the configuration file?

If you format your configuration file as code with the </> so that it's readable and won't get munged I can have a look at it myself.