Search code examples
fluentd

fluentd - how to source log file name with timestamp


fluentd - how to source log file name with timestamp e.g. Catalina logs are generated with timestamp e.g.

catalina.2018-11-05.log

catalina.2018-12-03.log

catalina.2018-12-10.log

I would like fluentd to access latest log file based on the timestamp in file name. Can you suggest what the source path should look like in td-agent.conf

<source>
  @type tail
  path D:\apache-tomcat-9.0.12\logs\catalina.**[TODAY]**.log
  pos_file C:\opt\td-agent\javalogs.log.pos
  tag javalogs
  <parse>
   @type json
  </parse>
</source>
<match javalogs>
  @type stdout
</match>

Solution

  • Try below path syntax.

    path D:\apache-tomcat-9.0.12\logs\catalina.%Y-%m-%d.log
    

    Note - Make sure your files are created according to same timezone as fluentd agent process so it can properly tail the correctly created files. Also, fluentd process should have correct read permissions on catalina files.