# Tail docker logs
@type tail
read_from_head true
path /fluentd/containers/*/*-json.log
pos_file /fluentd/log/docker.pos
time_format %Y-%m-%dT%H:%M:%S
tag docker.*
format json
# Add container id
@type record_transformer
container_id ${tag_parts[3]}
# Errors only
@type grep
key log
pattern /\[error\]|\| error \|/i
@type copy
# Write errors to file
@type file
path /fluentd/log/docker-error
# Tag daily errors
@type grepcounter
count_interval 14400 # = 4 hours
input_key log
threshold 1
add_tag_prefix daily_error
# Send daily error mail
#
# @type mail
# host [Host]
# port [Port]
# user [User/Email]
# password [Password]
# from [User/Email]
# to [Recipient]
# subject 'Error alert fluentd'
# message Error occured %s times
# message_out_keys count
#