From 469a1c6d8723006dec65974c450270f3c02face8 Mon Sep 17 00:00:00 2001 From: Kris Lamoureux Date: Wed, 19 Feb 2020 12:26:34 -0500 Subject: [PATCH] Fix logging to file and importing into Graylog --- fluentd/Dockerfile | 1 + fluentd/fluent.conf | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/fluentd/Dockerfile b/fluentd/Dockerfile index 545af56..2f1e645 100644 --- a/fluentd/Dockerfile +++ b/fluentd/Dockerfile @@ -3,6 +3,7 @@ USER root RUN apt-get update \ && apt-get -y install --no-install-recommends wget \ && rm -rf /var/lib/apt/lists/* +RUN gem install fluent-plugin-rewrite-tag-filter RUN gem install gelf RUN cd /fluentd/plugins \ && wget -q https://raw.githubusercontent.com/emsearcy/fluent-plugin-gelf/master/lib/fluent/plugin/out_gelf.rb diff --git a/fluentd/fluent.conf b/fluentd/fluent.conf index 14832d9..5c6a474 100644 --- a/fluentd/fluent.conf +++ b/fluentd/fluent.conf @@ -20,13 +20,25 @@ - @type file - path /var/log/hostlogs/containers/${tag} - append true - - timekey 5s - flush_mode immediate - + @type copy + + @type file + path /var/log/hostlogs/containers/${tag} + pos_file /var/log/hostlogs/httpd/access_log.pos + append true + + timekey 5s + flush_mode immediate + + + + @type rewrite_tag_filter + + key container_name + pattern /(.+)/ + tag ${tag}.$1 + +