# Simple logstash HTTP poller

**URL:** <https://discuss.elastic.co/t/simple-logstash-http-poller/48052>\
**Category:** Logstash\
**Created:** [April 21, 2016, 2:06pm UTC](https://discuss.elastic.co/t/simple-logstash-http-poller/48052 "2016-04-21T14:06:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amit\_Kulkarni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amit_kulkarni/32/9275_2.png) [@Amit\_Kulkarni](https://discuss.elastic.co/u/Amit_Kulkarni)\
**Post date:** [April 21, 2016, 2:06pm UTC](https://discuss.elastic.co/t/simple-logstash-http-poller/48052/1 "2016-04-21T14:06:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [April 21, 2016, 6:11pm UTC](https://discuss.elastic.co/t/simple-logstash-http-poller/48052/2 "2016-04-21T18:11:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Amit\_Kulkarni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amit_kulkarni/32/9275_2.png) [@Amit\_Kulkarni](https://discuss.elastic.co/u/Amit_Kulkarni)\
**Post date:** [April 22, 2016, 4:06am UTC](https://discuss.elastic.co/t/simple-logstash-http-poller/48052/3 "2016-04-22T04:06:06Z")

</div>

> [@magnusbaeck](#):
>
> stdout { codec =\> rubydebug { metadata =\> true } }

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

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [April 22, 2016, 5:51am UTC](https://discuss.elastic.co/t/simple-logstash-http-poller/48052/4 "2016-04-22T05:51:17Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Amit\_Kulkarni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amit_kulkarni/32/9275_2.png) [@Amit\_Kulkarni](https://discuss.elastic.co/u/Amit_Kulkarni)\
**Post date:** [April 22, 2016, 7:01am UTC](https://discuss.elastic.co/t/simple-logstash-http-poller/48052/5 "2016-04-22T07:01:09Z")

</div>

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](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 } }

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [April 23, 2016, 6:41pm UTC](https://discuss.elastic.co/t/simple-logstash-http-poller/48052/6 "2016-04-23T18:41:42Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 5:01am UTC](https://discuss.elastic.co/t/simple-logstash-http-poller/48052/7 "2017-07-06T05:01:03Z")

</div>


