Telegraf can't write to InfluxDB with default install

I’m trying to set up a default install of Telegraf to help monitor the health/performance of my influxdb server. Running the official RHEL rpm from Influx and RHEL7.3.

When I try to start up Telegraf I get:

● telegraf.service - The plugin-driven server agent for reporting metrics into InfluxDB
Loaded: loaded (/usr/lib/systemd/system/telegraf.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2017-05-31 15:55:47 GMT; 41s ago
Docs: GitHub - influxdata/telegraf: The plugin-driven server agent for collecting & reporting metrics.
Main PID: 1295 (telegraf)
CGroup: /system.slice/telegraf.service
└─1295 /usr/bin/telegraf -config /etc/telegraf/telegraf.conf -config-directory /etc/telegraf/telegraf.d

May 31 15:55:47 cfc-000-dev telegraf[1295]: 2017-05-31T15:55:47Z I! Loaded outputs: influxdb
May 31 15:55:47 cfc-000-dev telegraf[1295]: 2017-05-31T15:55:47Z I! Loaded inputs: inputs.processes inputs.swap inputs.system inputs.cpu inputs.disk inputs.diskio inputs.kernel inputs.mem
May 31 15:55:47 cfc-000-dev telegraf[1295]: 2017-05-31T15:55:47Z I! Tags enabled: host=cfc-000-dev
May 31 15:55:47 cfc-000-dev telegraf[1295]: 2017-05-31T15:55:47Z I! Agent Config: Interval:10s, Quiet:false, Hostname:“cfc-000-dev”, Flush Interval:10s
May 31 15:56:00 cfc-000-dev telegraf[1295]: 2017-05-31T15:56:00Z E! InfluxDB Output Error: Post http://localhost:8086/write?consistency=any&db=telegraf: dial tcp 127.0.0.1:8086: getsockopt: connection refused
May 31 15:56:00 cfc-000-dev telegraf[1295]: 2017-05-31T15:56:00Z E! Error writing to output [influxdb]: Could not write to any InfluxDB server in cluster

I also manually created the DB “telegraf” but no luck either.

Is influxdb running on the same machine as the telegraf process? InfluxDB may be configured listen on an explicit IP, not localhost. See this superuser discussion for a related explanation.

yes, influxdb is on the same host. I would like influx to be able to listen to localhost as well as on the IP address of the interface. Will look at your link. Thanks.

@sgreszcz You can always add an entry to your /etc/hosts file to make that happen too…

Does anyone have any concrete examples? I’ve tried this in the config file, but I still can’t get it working on local host:

[admin]

Determines whether the admin service is enabled.

enabled = true

The default bind address used by the admin service.

bind-address = “:8083”

Whether the admin service should use HTTPS.

https-enabled = false

The SSL certificate used when HTTPS is enabled.

https-certificate = “/etc/ssl/influxdb.pem”

[http]

Controls how the HTTP endpoints are configured. These are the primary

mechanism for getting data into and out of InfluxDB.

[http]

Determines whether HTTP endpoint is enabled.

enabled = true

The bind address used by the HTTP service.

bind-address = “:8086”

From a URL it works: http://cfc-000-dev:8086/query?q=SHOW+DATABASES&db=_internal
{“results”:[{“statement_id”:0,“series”:[{“name”:“databases”,“columns”:[“name”],“values”:[[“_internal”],[“collectd”],[“telegraf”]]}]}]}

But telegraf cannot connect to localhost:

May 31 17:10:40 cfc-000-dev telegraf[1887]: 2017-05-31T17:10:40Z E! InfluxDB Output Error: Post http://localhost:8086/write?consistency=any&db=telegraf: dial tcp 127.0.0.1:8086: getsockopt: connection refused
May 31 17:10:40 cfc-000-dev telegraf[1887]: 2017-05-31T17:10:40Z E! Error writing to output [influxdb]: Could not write to any InfluxDB server in cluster

ok, I ended up getting it to work on both the IP address and loopback.

bind-address = “:8086” doesn’t work.

I changed it to:

bind-address = “0.0.0.0:8086”

And now it works for external HTTP requests as well as Telegraf sending to Influx by default.

1 Like

i changed the port to the same port influxdb use.

in the case changed “:8086” to “:8888”
here urls = [“http://127.0.0.1:8888”] # required