Skip to content

Instantly share code, notes, and snippets.

@kiyoto
Last active August 29, 2015 14:11
Show Gist options
  • Save kiyoto/fa288206c4522dbc9aba to your computer and use it in GitHub Desktop.
Save kiyoto/fa288206c4522dbc9aba to your computer and use it in GitHub Desktop.

With this config, if your hostname is koala and if you have files like

log/t1.log
   /t2.log
   /...

They are sent to

receiver/koala.t1.20141219.log
        /koala.t2.20141219.log
        /...

Right now, the time_format must appear in out_file. If you don't want it in the file name, you can embedded in the path by replacing

path receiver/${tag_parts[1..-2]}.*.log

with

path receiver/*/${tag_parts[1..-2]}.log

in receiver.conf. That would change the file structure to

receiver/20141219/koala.t1.log
        /20141219/koala.t2.log
        /...
<source>
type forward
port 24224
</source>
<match with_hostname.**>
type forest
subtype file
<template>
path receiver/${tag_parts[1..-2]}.*.log
append true
flush_interval 1s
</template>
</match>
<source>
type tail
format none
path log/*.log
read_from_head true
tag no_hostname.*
</source>
<match no_hostname.**>
type record_reformer
tag with_hostname.${hostname}.${tag_suffix[-2]}
</match>
<match with_hostname.**>
type forward
flush_interval 1s
<server>
host localhost
port 24224
</server>
</match>
@kiyoto
Copy link
Author

kiyoto commented Dec 20, 2014

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment