diff --git a/fluentd/fluent-plugin-loki/Dockerfile b/fluentd/fluent-plugin-loki/Dockerfile index c8a16ff241604724ec818a164b39cbae244084aa..5767390161d9b090c576b2d1ccad6b0e06795657 100644 --- a/fluentd/fluent-plugin-loki/Dockerfile +++ b/fluentd/fluent-plugin-loki/Dockerfile @@ -10,26 +10,29 @@ ENV FLUENTD_DISABLE_BUNDLER_INJECTION 1 COPY docker/Gemfile* /fluentd/ RUN buildDeps="sudo make gcc g++ libc-dev ruby-dev" \ - && apt-get update \ - && apt-get install -y --no-install-recommends \ - $buildDeps libsystemd0 net-tools libjemalloc1 \ - && gem install bundler --version 1.16.2 \ - && bundle config silence_root_warning true \ - && bundle install --gemfile=/fluentd/Gemfile --path=/fluentd/vendor/bundle \ - && sudo gem sources --clear-all \ - && SUDO_FORCE_REMOVE=yes \ - apt-get purge -y --auto-remove \ - -o APT::AutoRemove::RecommendsImportant=false \ - $buildDeps \ - && rm -rf /var/lib/apt/lists/* \ - /home/fluent/.gem/ruby/2.3.0/cache/*.gem \ - /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem - -ENV FLUENTD_CONF="/fluentd/etc/fluentd.conf" -ENV FLUENTD_OPT="" + && apt-get update \ + && apt-get install -y --no-install-recommends \ + $buildDeps libsystemd0 net-tools libjemalloc1 \ + && gem install bundler --version 1.16.2 \ + && bundle config silence_root_warning true \ + && bundle install --gemfile=/fluentd/Gemfile --path=/fluentd/vendor/bundle \ + && sudo gem sources --clear-all \ + && SUDO_FORCE_REMOVE=yes \ + apt-get purge -y --auto-remove \ + -o APT::AutoRemove::RecommendsImportant=false \ + $buildDeps \ + && rm -rf /var/lib/apt/lists/* \ + /home/fluent/.gem/ruby/2.3.0/cache/*.gem \ + /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem COPY docker/entrypoint.sh /fluentd/entrypoint.sh COPY lib/fluent/plugin/out_loki.rb /fluentd/plugins/out_loki.rb +COPY docker/conf/ /fluentd/etc/loki/ + +ENV FLUENTD_CONF="/fluentd/etc/loki/fluentd.conf" +ENV FLUENTD_OPT="" + +ENV LOKI_URL "https://logs-us-west1.grafana.net" # See https://packages.debian.org/stretch/amd64/libjemalloc1/filelist ENV LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libjemalloc.so.1" diff --git a/fluentd/fluent-plugin-loki/README.md b/fluentd/fluent-plugin-loki/README.md index 69945010104a5bf3d17c956da5747391dcf2c8e8..de1b318a064078793fe0c17b7f88bd63ae6c6ee5 100644 --- a/fluentd/fluent-plugin-loki/README.md +++ b/fluentd/fluent-plugin-loki/README.md @@ -29,6 +29,44 @@ In your Fluentd configuration, use `@type loki`. Additional configuration is opt </match> ``` +## Docker Image + +There is a Docker image `grafana/fluent-plugin-loki:master` which contains default configuration files to git log information +a host's `/var/log` dir, and from the host's Journald. To use it, you can set the `LOKI_URL`, `LOKI_USERNAME`, and `LOKI_PASSWORD` environment variables (you can leave the USERNAME and PASSWORD blank if they're not used.) + + +A Docker Swarm Compose configuration that will work looks like: + +``` +services: + fluentd: + image: grafana/fluent-plugin-loki:master + command: + - "fluentd" + - "-v" + - "-p" + - "/fluentd/plugins" + environment: + LOKI_URL: http://loki:3100 + LOKI_USERNAME: + LOKI_PASSWORD: + deploy: + mode: global + configs: + - source: loki_config + target: /fluentd/etc/loki/loki.conf + networks: + - loki + volumes: + - host_logs:/var/log + # Needed for journald log ingestion: + - /etc/machine-id:/etc/machine-id + - /dev/log:/dev/log + - /var/run/systemd/journal/:/var/run/systemd/journal/ + logging: + options: + tag: infra.monitoring +``` ## Configuration diff --git a/fluentd/fluent-plugin-loki/docker/conf/loki.conf b/fluentd/fluent-plugin-loki/docker/conf/loki.conf index 3d44782e2a59ba272fd30cefcb166fd466fe17de..11d96f8ba45c7e1a63dbcd1ba94e9b4fc926362e 100644 --- a/fluentd/fluent-plugin-loki/docker/conf/loki.conf +++ b/fluentd/fluent-plugin-loki/docker/conf/loki.conf @@ -1,6 +1,6 @@ <match journald> @type loki - url "https://logs-us-west1.grafana.net" + url "#{ENV['LOKI_URL']}" username "#{ENV['LOKI_USERNAME']}" password "#{ENV['LOKI_PASSWORD']}" extra_labels {"env":"dev"}