Q:

How to tail Remote Log File's Using Telegraf

Hi i am new to Telegraf and Influxdb. I know that we can tail (monitor) a local file(on the same machine where Telegraf is installed) using Telegraf and send the output to Influxdb  using [[inputs.tail]] and [[outputs.influxdb]] plugin's of Telegraf.
But I want to tail a log file which is on a different server other than where Telegraf is installed.
One way could be to have Telegraf on the server where the log file is : But I can't have that because that server can't send data to Influxdb . It does not have access to the server where Influxdb is present.
So I have to use intermediate server in order to send data to InfluxDb.
So is there a way to tail the remote file or any other way around.
Any type of suggestion's are welcome.

A:

I looked around and found a solution how we can do it :
Telegraf's inputs.tail plugin have options to tail a pipe which we can use to monitor remote files.
Let's suppose serverA have the log File and serverB is where the Telegraf is running.
So i will write down the step's to monitor a remote file via Telegraf.
1.First create a pipe on serverB. 
 command for creating pipe : mkfifo pipeName

2.Now run a command on serverB which will do ssh to tail the log file on serverA which you want to monitor and send the output to the pipe on serverB.
command is : ssh -q username@serverA tail -f "pathToFile"/out.log > pipeName

3.Now add inputs.tail plugin to telegraf configuration file.
 [[inputs.tail]]
 files = ["pipeName"]
 from_beginning = false
 pipe = true
 data_format = "json"
 name_suffix = "_myMetrics"

these are configurations you can change according to your requirement's.
4.Now run the telegraf and it will start writing the data to the output plugin you specified in your configuration file.
command to run Telegraf : ./usr/bin/telegraf -config demoTelegraf.conf

