Logstash cannot find/connect to InfluxDB

Hey, all. I’m trying to send logstash output to my local InfluxDB. Logstash seems to be unable to find my local InfluxDB. I know this because InfluxDB is not receiving any post or write requests from the logstash file, when I check the logs. I get this error from the logstash logs.

E, [2017-06-22T16:01:00.561000 #10477] ERROR – InfluxDB: Failed to contact host localhost:8086: #<SocketError: initialize: name or service not known> - retrying in 1s.

My logstash configuration file is below. I’ve tried changing the host to “influxdb” or “influx” to no avail.

input {
file {
path => [
"/Users/garrett/Desktop/failures-march-legacy.csv",
"/Users/garrett/Desktop/failures-march-cms.csv",
"/Users/garrett/Desktop/failures-february-legacy.csv",
"/Users/garrett/Desktop/failures-february-cms.csv",
"/Users/garrett/Desktop/failures-january-legacy.csv"
]

   start_position => "beginning"
   type => "changes"
   sincedb_path => "/dev/null"

}
}

filter {
csv {
columns => [
“SR #”,
“Customer”,
“Scheduled Start”
]
}
}

output {
influxdb {
host => "localhost:8086"
db => "mydb"
data_points => {}
use_event_fields_for_data_points => true
}
stdout { codec => rubydebug }
}

Also, I am running this locally, not in any containers or anything.

Is influx bound to localhost, all hosts (e.g. 0.0.0.0), or is an explicit IP like 192.0.2.1?

Binding to a specific IP typically means the service is not available when connecting to localhost. You can do a quick test to confirm whether influx is accessible on localhost, by executing this curl command on the machine where logstash is running:

$ curl -i localhost:8086/ping

Successful output will look something like this:

HTTP/1.1 204 No Content
Content-Type: application/json
Request-Id: 1662924f-5790-11e7-9cac-000000000000
X-Influxdb-Version: 1.3.0rc2-c1.3.0rc2
Date: Thu, 22 Jun 2017 21:16:42 GMT

Failed output can vary but will look something like:

curl: (7) Failed to connect to localhost port 8086: Connection refused

Pinging it was a success.

Garretts-MacBook-Pro:~ garrett$ curl -i localhost:8086/ping
HTTP/1.1 204 No Content
Content-Type: application/json
Request-Id: 35432804-5796-11e7-8001-000000000000
X-Influxdb-Version: v1.2.4
Date: Thu, 22 Jun 2017 22:00:30 GMT

@jackzampolin pointed out in this thread that it should be host => "localhost", not host => "localhost:8086". Does that fix the connection problem?

Yes, thank you! Geez.