Hi, I am using file input plugin. After restarting the telegraf service all files are getting read duplicately.
I found a way using statefile configurations in agent tab.
But telegraf is not writing its state or checkpoint till where it read data from files in statefile.
Am I using the correct configuration, please suggest me solution for this Configuration:
Thanks @Anaisdg for the respons,
Yes I can use the tail plugin but I think tail plugin has one limitation that it does not read the files which creates after telegraf service get up. That is why I am using file input plugin. Is there any solution for tail plugin for this issue ?
Hey @jpowers, My goal is to read the kubernetes pod logs which writes on the directory /var/log/container/* . So if I use file plugin then its not maintaining the state. If I use tail plugin then its not reading the new file after the telegraf service gets up.
If you suggesting to use directory monitor plugin then will this plugin solve the above challenges?
I am still not clear why you are trying to use the state file. Are you constantly reloading telegraf?
So if I use file plugin then its not maintaining the state.
The file plugin reads the entire file at every collection interval. When reading logs this is
probably not what you want. It does not save state.
The tail plugin will effectively tail a file. Reading it from the beginning at first, and then each collection interval will only read new lines. This does save state, when the plugin is shutdown safely. A sudden shutdown will not save state.
The directory monitor plugin will monitor files as they come in, process them, and move on. I don’t believe this plugin monitors state as well.
Each have their own use-cases, even though they are very similar.
Thanks for your response @jpowers ,
For any cases telegraf may be down eg. For OOM killed or suppose need to update any config in the telegraf so need to restart the telegraf instance. I think saving the state is the basic functionality it should provide.
Since tail plugin does not read the new file I can not use it either.
Can I request any way to add the save state functionality in the telegraf file input plugin
A restart would save state as we have time to clean up. An OOM, is not in scope. That would be a sudden shutdown where Telegraf gets killed and is not a scenario we are after supporting.
I have deployed telegraf in kubernetes env as a pod. So when I am deleting the pod/container its not saving its state in the statefile. I have cross checked it manier times. May be telegraf does consider it as a sudden shutdown.
Tail reads new files at each gather interval.
Can you please provide me configurations for gather interval
@jpowers Okay so I can not use file plugin for my case
Sorry for asking the same thing again but just for the confirmation, are you sure that telegraf tail plugin read the new files after it gets up because I have tried tail plugin its not reading the new file.