Error using inputs.http plugin

telegraf

#1

Hi I’m trying telegraf 1.6.0-RC4 with the plugin http.plugin with the following configuration

And I’m getting the following error at the logs

2018-04-16T08:25:00Z E! Error in plugin [inputs.http]: [url=http://localhost/metrics]: Post http://localhost/metrics: dial tcp 127.0.0.1:80: getsockopt: connection refused


#2

What is the output of curl -v http://localhost/metrics?


#3

root@0764fe80daab:/# curl -v http://localhost/metrics

  • Trying 127.0.0.1…
  • TCP_NODELAY set
  • connect to 127.0.0.1 port 80 failed: Connection refused
  • Trying ::1…
  • TCP_NODELAY set
  • Immediate connect fail for ::1: Cannot assign requested address
  • Trying ::1…
  • TCP_NODELAY set
  • Immediate connect fail for ::1: Cannot assign requested address
  • Failed to connect to localhost port 80: Connection refused
  • Closing connection 0
    curl: (7) Failed to connect to localhost port 80: Connection refused

I’m using tick sandbox environment using my custom image from 1.6.0-RC4, using curl inside of the telegraf container the others plugins are working properly

thanks in advance
Cayetano


#4

Looks like a networking issue connecting to your service, @katy can you help?


#6

Part of the issue is likely that the container can’t access localhost due to the networking layers. Try replacing localhost with your ip address. It may also depend on where that metrics endpoint lives. What application are you trying to access there? Does it live on your machine?

In the sandbox documentation, we currently have a tutorial for the socket listener, and this http input would be really useful in the same format if you’re interested in contributing.


#7

well, I just come inside of the telegraf container wich seems that it’s loading everything properly as I can see at the logs

telegraf_1 | 2018-04-16T22:16:08Z I! Starting Telegraf v1.6.0~rc4
telegraf_1 | 2018-04-16T22:16:08Z I! Loaded outputs: influxdb
telegraf_1 | 2018-04-16T22:16:08Z I! Loaded inputs: inputs.cloudwatch inputs.cloudwatch inputs.cloudwatch inputs.cloudwatch inputs.cloudwatch inputs.cloudwatch inputs.cloudwatch inputs.cloudwatch inputs.http
telegraf_1 | 2018-04-16T22:16:08Z I! Tags enabled: host=5bb15f8da47e
telegraf_1 | 2018-04-16T22:16:08Z I! Agent Config: Interval:5m0s, Quiet:false, Hostname:“5bb15f8da47e”, Flush Interval:5m0s

inside of the container I just intalled executed netstat and launch -ltpu and seems that the port 80 is not listening

root@5bb15f8da47e:/# netstat -ltpu
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.11:46764 0.0.0.0:* LISTEN -
udp 0 0 127.0.0.11:43101 0.0.0.0:* -

I’m using the example config

thanks in advance
Cayetano


#8

From inside the container, try making a curl request to your /metrics endpoint but replace the localhost (or 127.0.0.1) with your machine’s ip address.


#10

I used this plugin like socket_listener plugin I thought that was the same, thank you