404 Not Found
  • Introduction
  • Monitoring related
    • K8s cluster monitoring
    • Monitor Jenkins with G.A.P on K8s cluster
    • Monitoring tools | projects
      • Grafana
      • AlertManager
      • Prometheus
      • Wavefront
  • Logging related
    • BOSH logs
    • How to gather systemd log
    • K8s cluster logging
    • Logging tools | projects
      • vRealize Log Insight
      • Fluentd
      • syslog vs fluentd
  • Having fun with docker
    • Using docker-compose for redmine
    • Customize Fluentd docker image
  • K8S or Apache Mesos
  • K8S Related
    • Main Architecture
      • Master components
        • API Server
        • etcd
        • Controller Manager
        • Kube Scheduler
      • Worker components
        • kubelet
        • kube-proxy
    • K8S Storage
      • Volume Provisioning
      • Understand CSI
      • How to write CSI
      • VMware CNS
      • K8S storage e2e experiment under VMware vSphere
      • Experiment on Persistent Volume Access Mode
      • Design: Storage in Cluster-API architecture
    • K8S Networking
      • Ingress
      • Endpoints
    • K8S Policies
      • Resource Quotas
    • K8S Management Platform
    • K8S Tests Tool
    • K8S Extension
      • CRDs
        • Custom Resources
        • Custom Controllers
        • How to user code-generator
        • K8S Operators
        • Operators Development Tools
          • Kubebuilder
          • Metacontroller
          • Operator SDK
      • Custom API Server
    • K8S Resource CRUD Workflow
    • K8S Garbage Collection
  • K8S CONTROLLER RELATED
    • IsController: true
    • Controller clients
  • PKS RELATED
    • How to Access VMs and Databases related to PKS
    • PKS Basics
    • BOSH Director
    • Backup and Restore on Ent. PKS with Velero
  • CICD RELATED
    • Configure Jenkins to run on K8S
    • Customize Jenkins JNLP slave image
    • Jenkins global shared libs
  • Google Anthos
    • Google Anthos Day from KubeCon 2019 San Diego
    • Migrate for Anthos
    • Config Connector
  • SYSTEM DESIGN RELATED
    • Design Data Intensive Application - Notes
      • RSM
        • Reliability
        • Scalability
      • Data models and Query Languages
      • Storage and Retrieval
    • How Alibaba Ensure K8S Performance At Large Scale
  • Miscellaneous
    • Knative
    • Serverless
    • Service Mesh
    • gRPC
    • Local persistent volumes
    • ownerReferences in K8S
    • File(NAS) vs Block(SAN) vs Object storage
    • KubeVirt
    • Why K8S HA chooses 3 instead of 5..6..7 as the size of masters?
    • goroutine & go channel
    • How to make docker images smaller
Powered by GitBook
On this page
  • What is Fluentd
  • Get started

Was this helpful?

  1. Having fun with docker

Customize Fluentd docker image

PreviousUsing docker-compose for redmineNextK8S or Apache Mesos

Last updated 6 years ago

Was this helpful?

What is Fluentd

Briefly speaking, Fluentd is an open source data collector, which lets you unify the data collection and consumption for a better use and understanding of data. Click for more details.

You could use Fluentd by either installing the Fluentd agent manually as the daemon process or running a docker image. This article will mainly focus on how to build you own Fluentd docker image which fits your use cases.

Get started

  • Create folder with the following skeleton

#$:~/fluentd-docker$ tree .
.
├── Dockerfile
├── fluent.conf
└── plugins

1 directory, 2 files
  • Edit the Dockerfile

FROM fluent/fluentd:v1.4-debian-onbuild

# Use root account to use apt
USER root

# below RUN includes plugin as examples elasticsearch is not required
# you may customize including plugins as you wish
RUN buildDeps="sudo make gcc g++ libc-dev ruby-dev" \
 && apt-get update \
 && apt-get install -y --no-install-recommends $buildDeps \
 && apt-get install -y libsystemd0 \
 && sudo gem install fluent-plugin-vmware-loginsight \
 && sudo gem install fluent-plugin-systemd -v 1.0.1 \
 && 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

USER fluent
  • apt-get install -y libsystemd0 and sudo gem install fluent-plugin-systemd -v 1.0.1 are specificly for fetching systemd logs

  • fluent.conf is required to build the custom docker image. It could be a default conf file. When you run the docker image the config file could be replaced from the docker run command.

The following fluent.conf is just an example for fetching the systemd log:

<source>
  @type systemd
  tag pks-mgmt-server
  path /var/log/journal
  matches [{ "_SYSTEMD_UNIT": "pks-mgmt-server.service" }]
  read_from_head true
</source>

<source>
  @type systemd
  tag pks-ui-server
  path /var/log/journal
  matches [{ "_SYSTEMD_UNIT": "pks-ui-server.service" }]
  read_from_head true
</source>

<source>
  @type systemd
  tag nginx
  path /var/log/journal
  matches [{ "_SYSTEMD_UNIT": "nginx.service" }]
  read_from_head true
</source>

<filter **>
  @type systemd_entry
  fields_lowercase true
  fields_strip_underscores true
</filter>

<match **>
  @type vmware_loginsight
  host <log-server-ip>
  port 9543
  scheme https
    ssl_verify false
  path api/v1/events/ingest
  agent_id xxxxxx
  http_method post
  serializer json
  rate_limit_msec 0
  raise_on_error false
  flush_mode interval
  flush_interval 20
  include_tag_key true
  tag_key tag
</match>
  • You could leave plugins folder empty in this example

  • Build the new image by using docker build command

Refer to the official for more details

All available fluentd plugins could be found

Refer to the official for running the container with your own configuration files and other additional options.

here
doc
here
doc