Initial
This commit is contained in:
24
fluentd/Dockerfile
Normal file
24
fluentd/Dockerfile
Normal file
@@ -0,0 +1,24 @@
|
||||
# image based on fluentd v1.14-1
|
||||
FROM fluentd:v1.14-1
|
||||
# Use root account to use apk
|
||||
USER root
|
||||
# Install the required version of faraday
|
||||
RUN gem uninstall -I faraday
|
||||
RUN gem install faraday -v 2.8.1
|
||||
# Install dependencies and gems
|
||||
RUN apk --no-cache --update add \
|
||||
sudo \
|
||||
build-base \
|
||||
ruby-dev \
|
||||
&& gem uninstall -I elasticsearch \
|
||||
&& gem install elasticsearch -v 7.17.0 \
|
||||
&& gem install fluent-plugin-elasticsearch \
|
||||
&& gem sources --clear-all \
|
||||
&& apk del build-base ruby-dev \
|
||||
&& rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem
|
||||
# Copy fluentd configuration from host image
|
||||
COPY ./conf/fluent.conf /fluentd/etc/
|
||||
# Copy binary start file
|
||||
COPY entrypoint.sh /bin/
|
||||
RUN chmod +x /bin/entrypoint.sh
|
||||
USER fluent
|
||||
28
fluentd/conf/fluent.conf
Normal file
28
fluentd/conf/fluent.conf
Normal file
@@ -0,0 +1,28 @@
|
||||
# bind fluentd on IP 0.0.0.0
|
||||
# port 24224
|
||||
<source>
|
||||
@type forward
|
||||
port 24224
|
||||
bind 0.0.0.0
|
||||
</source>
|
||||
# sendlog to the elasticsearch
|
||||
# the host must match to the elasticsearch
|
||||
# container service
|
||||
<match *.**>
|
||||
@type copy
|
||||
<store>
|
||||
@type elasticsearch
|
||||
host elasticsearch
|
||||
port 9200
|
||||
logstash_format true
|
||||
logstash_prefix fluentd
|
||||
logstash_dateformat %Y%m%d
|
||||
include_tag_key true
|
||||
type_name access_log
|
||||
tag_key @log_name
|
||||
flush_interval 20s
|
||||
</store>
|
||||
<store>
|
||||
@type stdout
|
||||
</store>
|
||||
</match>
|
||||
22
fluentd/entrypoint.sh
Normal file
22
fluentd/entrypoint.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
# Source vars if file exists
|
||||
DEFAULT=/etc/default/fluentd
|
||||
if [ -r $DEFAULT ]; then
|
||||
set -o allexport
|
||||
. $DEFAULT
|
||||
set +o allexport
|
||||
fi
|
||||
# If the user has supplied only arguments, append them to `fluentd` command
|
||||
if [ "${1#-}" != "$1" ]; then
|
||||
set -- fluentd "$@"
|
||||
fi
|
||||
# If the user does not supply a config file or plugins, use the default
|
||||
if [ "$1" = "fluentd" ]; then
|
||||
if ! echo $@ | grep -e ' \-c' -e ' \-\-config' ; then
|
||||
set -- "$@" --config /fluentd/etc/${FLUENTD_CONF}
|
||||
fi
|
||||
if ! echo $@ | grep -e ' \-p' -e ' \-\-plugin' ; then
|
||||
set -- "$@" --plugin /fluentd/plugins
|
||||
fi
|
||||
fi
|
||||
exec "$@"
|
||||
Reference in New Issue
Block a user