Error in plugin [inputs.http_response]....getsockopt: connection refused


Ok, maybe I’m confused on how this is supposed to work, but I am trying to check the status of several web sites. The inputs.http_response seems to be what I want, so I added it to my telegraf.conf file like so:

 # HTTP/HTTPS request given an address a method and a timeout
   name_suffix = "_motioneye"
   ## Server address (default http://localhost)
   address = "http://skynet:8765"
   ## Set response_timeout (default 5 seconds)
   response_timeout = "5s"
   ## HTTP Request Method
   method = "GET"
   ## Whether to follow redirects from the server (defaults to false)
   follow_redirects = true

However, when I take the page down (to test the alert), no data is sent to influx and the telegraf service shows this over and over again:

Apr 28 17:21:17 skynet telegraf[15134]: 2019-04-29T00:21:17Z E! Error in plugin [inputs.http_response]: Get http://skynet:8080: dial tcp getsockopt: connection refused

So I’m guessing it “fails” to get a response so it errors out. However, this is exactly the case I want to test for. I found this post from a while back of someone with the same question, but no love there.

Is there a better input plugin for checking the status of a web page, or is there a way I can map this result thingy to some place to make it useful?


InfluxDB map text to value

Hi @xMTinkerer welcome ,

what is your telegraf version ?

I did a little test with your configuration and everything works as expected ,

Connected to http://localhost:8086 version 1.7.4
InfluxDB shell version: 1.7.4 
Enter an InfluxQL query
> select * from http_response_motioneye
name: http_response_motioneye
time                host             method result    result_code result_type server
----                ----             ------ ------    ----------- ----------- ------ 
1556552720000000000 GET    dns_error 5           dns_error   http://skynet:8765
1556552730000000000 GET    dns_error 5           dns_error   http://skynet:8765
1556552740000000000 GET    dns_error 5           dns_error   http://skynet:8765
1556552750000000000 GET    dns_error 5           dns_error   http://skynet:8765
1556552760000000000 GET    dns_error 5           dns_error   http://skynet:8765

telegraf -version
Telegraf 1.10.1 (git: HEAD a6778f46)


Ah, yea, I was on v1.3 :roll_eyes: After upgrading, it doesn’t error, but the status_code is still empty when the page is down. I suppose this actually makes sense because there was no actual response, so there shouldn’t be a response code. The result_type field looks like it has success and anything else should be an error.


1 Like