Variables and constants in fluentd config

915 views
Skip to first unread message

Marc Ende

unread,
Jun 2, 2016, 3:36:03 AM6/2/16
to Fluentd Google Group
Hi,

is there a way to define constants in fluentd? 

I've got several config files (sources) which loads from unified log-files. But I'd like to store the format in a central place.

<source>
  type tail
  format multiline
  format_firstline /^\d{4}-\d{1,2}-\d{1,2}/
  format1 /^(?<time>\d{4}-\d{1,2}-\d{1,2} \d{1,2}:\d{1,2}:\d{1,2},\d{3}) (?<level>.*) \[(?<thread>.*)\] (?<logger>[^ ]*) (?<message>.*)/
  path /var/log/service-a.log 
  read_from_head true
  tag service.a
  refresh_interval 30
</source>

<source>
  type tail
  format multiline
  format_firstline /^\d{4}-\d{1,2}-\d{1,2}/
  format1 /^(?<time>\d{4}-\d{1,2}-\d{1,2} \d{1,2}:\d{1,2}:\d{1,2},\d{3}) (?<level>.*) \[(?<thread>.*)\] (?<logger>[^ ]*) (?<message>.*)/
  path /var/log/service-b.log 
  read_from_head true
  tag service.b
  refresh_interval 30
</source>
...

Is there any way to achive that?

Or can I define a <source> which reads all the logfiles and depending on the logfile-name it will append the tag correctly?


Thanks
Marc

Mr. Fiber

unread,
Jun 2, 2016, 4:57:06 AM6/2/16
to Fluentd Google Group
Hi,

is there a way to define constants in fluentd? 

Currenlty, there is no defining constant feature but you can use @include instead.
In your case, example configuration is like below:

- fluent.conf

<source>
  @type tail
  path /var/log/sesrvice-b.log
  tag service.b
  @include /path/to/tail_params.conf
</source>

- tail_params.conf

format multiline
format_firstline /^\d{4}-\d{1,2}-\d{1,2}/
format1 /^(?<time>\d{4}-\d{1,2}-\d{1,2} \d{1,2}:\d{1,2}:\d{1,2},\d{3}) (?<level>.*) \[(?<thread>.*)\] (?<logger>[^ ]*) (?<message>.*)/
read_from_head true
refresh_interval 30


Masahiro

--
You received this message because you are subscribed to the Google Groups "Fluentd Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fluentd+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages