I’ve got a Windows application that’s managing a local instance of Telegraf. i.e. when the application starts, it starts up Telegraf as a child process, configured with a StatsD input and Influx output. I would like to disable a part of the application if and when Telegraf loses connectivity to Influx. What would be a recommended approach? Should I just look past it and periodically attempt a direct connection to Influx and check the result, or is there some signal/output from Telegraf that can be checked for signs of failure?
The InfluxDB output plugin will throw an error if it can’t connect to InfluxDB; this will be written to stdout or to a logfile if you have one set in your configuration.
For example, this is the error I see on my Windows VM when I stop InfluxDB:
2018-04-07T19:00:51Z E! InfluxDB Output Error: Post http://127.0.0.1:8086/write?db=telegraf: dial tcp 127.0.0.1:8086: connectex: No connection could be made because the target machine actively refused it. 2018-04-07T19:00:51Z E! Error writing to output [influxdb]: Could not write to any InfluxDB server in cluster
There won’t be any indication when the connection has been restored, however, since that won’t result in an error, so it might make more sense to attempt a direct connection to Influx and check the result.
Thanks, for the advice. I’ll check directly, then.