2014-10-13 18:06:01 +00:00
# This configuration file for Fluentd / td-agent is used
2015-05-21 19:04:01 +00:00
# to watch changes to Docker log files. The kubelet creates symlinks that
# capture the pod name, namespace, container name & Docker container ID
# to the docker logs for pods in the /var/log/containers directory on the host.
# If running this fluentd configuration in a Docker container, the /var/log
# directory should be mounted in the container.
#
# These logs are then submitted to Elasticsearch which assumes the
# installation of the fluent-plugin-elasticsearch & the
# fluent-plugin-kubernetes_metadata_filter plugins.
# See https://github.com/uken/fluent-plugin-elasticsearch &
# https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter for
# more information about the plugins.
# Maintainer: Jimmi Dyson <jimmidyson@gmail.com>
2014-10-13 18:06:01 +00:00
#
2015-04-30 18:13:54 +00:00
# Example
# =======
2014-10-13 18:06:01 +00:00
# A line in the Docker log file might like like this JSON:
#
# {"log":"2014/09/25 21:15:03 Got request with path wombat\n",
# "stream":"stderr",
# "time":"2014-09-25T21:15:03.499185026Z"}
#
# The time_format specification below makes sure we properly
# parse the time format produced by Docker. This will be
# submitted to Elasticsearch and should appear like:
2015-06-25 04:55:40 +00:00
# $ curl 'http://elasticsearch-logging:9200/_search?pretty'
2014-10-13 18:06:01 +00:00
# ...
# {
# "_index" : "logstash-2014.09.25",
# "_type" : "fluentd",
# "_id" : "VBrbor2QTuGpsQyTCdfzqA",
# "_score" : 1.0,
# "_source":{"log":"2014/09/25 22:45:50 Got request with path wombat\n",
# "stream":"stderr","tag":"docker.container.all",
# "@timestamp":"2014-09-25T22:45:50+00:00"}
# },
# ...
2015-04-30 18:13:54 +00:00
#
2015-05-21 19:04:01 +00:00
# The Kubernetes fluentd plugin is used to write the Kubernetes metadata to the log
# record & add labels to the log record if properly configured. This enables users
# to filter & search logs on any metadata.
# For example a Docker container's logs might be in the directory:
#
2015-04-30 18:13:54 +00:00
# /var/lib/docker/containers/997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b
2015-05-21 19:04:01 +00:00
#
2015-04-30 18:13:54 +00:00
# and in the file:
2015-05-21 19:04:01 +00:00
#
2015-04-30 18:13:54 +00:00
# 997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b-json.log
2015-05-21 19:04:01 +00:00
#
2015-04-30 18:13:54 +00:00
# where 997599971ee6... is the Docker ID of the running container.
# The Kubernetes kubelet makes a symbolic link to this file on the host machine
# in the /var/log/containers directory which includes the pod name and the Kubernetes
# container name:
2015-05-21 19:04:01 +00:00
#
# synthetic-logger-0.25lps-pod_default_synth-lgr-997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b.log
# ->
2015-04-30 18:13:54 +00:00
# /var/lib/docker/containers/997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b/997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b-json.log
2015-05-21 19:04:01 +00:00
#
# The /var/log directory on the host is mapped to the /var/log directory in the container
2015-04-30 18:13:54 +00:00
# running this instance of Fluentd and we end up collecting the file:
2015-05-21 19:04:01 +00:00
#
# /var/log/containers/synthetic-logger-0.25lps-pod_default_synth-lgr-997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b.log
#
2015-04-30 18:13:54 +00:00
# This results in the tag:
2015-05-21 19:04:01 +00:00
#
# var.log.containers.synthetic-logger-0.25lps-pod_default_synth-lgr-997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b.log
#
# The Kubernetes fluentd plugin is used to extract the namespace, pod name & container name
# which are added to the log message as a kubernetes field object & the Docker container ID
# is also added under the docker field object.
# The final tag is:
#
# kubernetes.var.log.containers.synthetic-logger-0.25lps-pod_default_synth-lgr-997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b.log
#
# And the final log record look like:
#
# {
# "log":"2014/09/25 21:15:03 Got request with path wombat\n",
# "stream":"stderr",
# "time":"2014-09-25T21:15:03.499185026Z",
# "kubernetes": {
# "namespace": "default",
# "pod_name": "synthetic-logger-0.25lps-pod",
# "container_name": "synth-lgr"
# },
# "docker": {
# "container_id": "997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b"
# }
# }
#
2015-04-30 18:13:54 +00:00
# This makes it easier for users to search for logs by pod name or by
# the name of the Kubernetes container regardless of how many times the
# Kubernetes pod has been restarted (resulting in a several Docker container IDs).
2015-05-21 19:04:01 +00:00
#
2015-04-30 18:13:54 +00:00
# TODO: Propagate the labels associated with a container along with its logs
# so users can query logs using labels as well as or instead of the pod name
2015-05-21 19:04:01 +00:00
# and container name. This is simply done via configuration of the Kubernetes
# fluentd plugin but requires secrets to be enabled in the fluent pod. This is a
# problem yet to be solved as secrets are not usable in static pods which the fluentd
# pod must be until a per-node controller is available in Kubernetes.
2014-10-13 18:06:01 +00:00
2016-01-26 23:59:27 +00:00
# Do not directly collect fluentd's own logs to avoid infinite loops.
<match fluent.**>
type null
</match>
2016-02-18 19:07:27 +00:00
# Example:
# {"log":"[info:2016-02-16T16:04:05.930-08:00] Some log text here\n","stream":"stdout","time":"2016-02-17T00:04:05.931087621Z"}
2014-10-13 18:06:01 +00:00
<source>
type tail
2015-05-21 19:04:01 +00:00
path /var/log/containers/*.log
pos_file /var/log/es-containers.log.pos
2016-02-18 19:07:27 +00:00
time_format %Y-%m-%dT%H:%M:%S.%NZ
2015-05-21 19:04:01 +00:00
tag kubernetes.*
format json
2015-03-10 00:14:38 +00:00
read_from_head true
2014-10-13 18:06:01 +00:00
</source>
2016-01-08 01:41:22 +00:00
# Example:
# 2015-12-21 23:17:22,066 [salt.state ][INFO ] Completed state [net.ipv4.ip_forward] at time 23:17:22.066081
2015-08-05 00:22:38 +00:00
<source>
type tail
2016-01-08 01:41:22 +00:00
format /^(?<time>[^ ]* [^ ,]*)[^\[]*\[[^\]]*\]\[(?<severity>[^ \]]*) *\] (?<message>.*)$/
time_format %Y-%m-%d %H:%M:%S
2015-05-21 19:04:01 +00:00
path /var/log/salt/minion
2016-06-03 15:42:40 +00:00
pos_file /var/log/es-salt.pos
2015-08-05 00:22:38 +00:00
tag salt
</source>
2016-01-08 01:41:22 +00:00
# Example:
# Dec 21 23:17:22 gke-foo-1-1-4b5cbd14-node-4eoj startupscript: Finished running startup script /var/run/google.startup.script
2015-07-01 02:04:04 +00:00
<source>
type tail
2016-01-08 01:41:22 +00:00
format syslog
2015-05-21 19:04:01 +00:00
path /var/log/startupscript.log
pos_file /var/log/es-startupscript.log.pos
2015-07-01 02:04:04 +00:00
tag startupscript
</source>
2016-01-08 01:41:22 +00:00
# Examples:
# time="2016-02-04T06:51:03.053580605Z" level=info msg="GET /containers/json"
# time="2016-02-04T07:53:57.505612354Z" level=error msg="HTTP Error" err="No such image: -f" statusCode=404
2015-07-01 02:04:04 +00:00
<source>
type tail
2016-01-08 01:41:22 +00:00
format /^time="(?<time>[^)]*)" level=(?<severity>[^ ]*) msg="(?<message>[^"]*)"( err="(?<error>[^"]*)")?( statusCode=($<status_code>\d+))?/
2016-02-18 19:07:27 +00:00
time_format %Y-%m-%dT%H:%M:%S.%NZ
2015-05-21 19:04:01 +00:00
path /var/log/docker.log
pos_file /var/log/es-docker.log.pos
2015-07-01 02:04:04 +00:00
tag docker
</source>
2014-12-14 07:16:44 +00:00
2016-01-08 01:41:22 +00:00
# Example:
# 2016/02/04 06:52:38 filePurge: successfully removed file /var/etcd/data/member/wal/00000000000006d0-00000000010a23d1.wal
2015-07-30 21:41:58 +00:00
<source>
type tail
2016-01-08 01:41:22 +00:00
# Not parsing this, because it doesn't have anything particularly useful to
# parse out of it (like severities).
2015-07-30 21:41:58 +00:00
format none
2015-05-21 19:04:01 +00:00
path /var/log/etcd.log
pos_file /var/log/es-etcd.log.pos
2015-07-30 21:41:58 +00:00
tag etcd
</source>
2015-06-25 04:55:40 +00:00
2016-02-26 22:58:46 +00:00
# Multi-line parsing is required for all the kube logs because very large log
# statements, such as those that include entire object bodies, get split into
# multiple lines by glog.
2016-01-08 01:41:22 +00:00
# Example:
# I0204 07:32:30.020537 3368 server.go:1048] POST /stats/container/: (13.972191ms) 200 [[Go-http-client/1.1] 10.244.1.3:40537]
2014-12-14 07:16:44 +00:00
<source>
type tail
2016-02-26 22:58:46 +00:00
format multiline
format_firstline /^\w\d{4}/
format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
2016-01-08 01:41:22 +00:00
time_format %m%d %H:%M:%S.%N
2015-05-21 19:04:01 +00:00
path /var/log/kubelet.log
pos_file /var/log/es-kubelet.log.pos
2014-12-14 07:16:44 +00:00
tag kubelet
</source>
2016-01-08 01:41:22 +00:00
# Example:
# I0204 07:00:19.604280 5 handlers.go:131] GET /api/v1/nodes: (1.624207ms) 200 [[kube-controller-manager/v1.1.3 (linux/amd64) kubernetes/6a81b50] 127.0.0.1:38266]
2015-07-01 02:04:04 +00:00
<source>
type tail
2016-02-26 22:58:46 +00:00
format multiline
format_firstline /^\w\d{4}/
format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
2016-01-08 01:41:22 +00:00
time_format %m%d %H:%M:%S.%N
2015-05-21 19:04:01 +00:00
path /var/log/kube-apiserver.log
pos_file /var/log/es-kube-apiserver.log.pos
2015-07-01 02:04:04 +00:00
tag kube-apiserver
</source>
2016-01-08 01:41:22 +00:00
# Example:
# I0204 06:55:31.872680 5 servicecontroller.go:277] LB already exists and doesn't need update for service kube-system/kube-ui
2015-07-01 02:04:04 +00:00
<source>
type tail
2016-02-26 22:58:46 +00:00
format multiline
format_firstline /^\w\d{4}/
format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
2016-01-08 01:41:22 +00:00
time_format %m%d %H:%M:%S.%N
2015-05-21 19:04:01 +00:00
path /var/log/kube-controller-manager.log
pos_file /var/log/es-kube-controller-manager.log.pos
2015-07-01 02:04:04 +00:00
tag kube-controller-manager
</source>
2016-01-08 01:41:22 +00:00
# Example:
# W0204 06:49:18.239674 7 reflector.go:245] pkg/scheduler/factory/factory.go:193: watch of *api.Service ended with: 401: The event in requested index is outdated and cleared (the requested history has been cleared [2578313/2577886]) [2579312]
2015-07-01 02:04:04 +00:00
<source>
type tail
2016-02-26 22:58:46 +00:00
format multiline
format_firstline /^\w\d{4}/
format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
2016-01-08 01:41:22 +00:00
time_format %m%d %H:%M:%S.%N
2015-05-21 19:04:01 +00:00
path /var/log/kube-scheduler.log
pos_file /var/log/es-kube-scheduler.log.pos
2015-07-01 02:04:04 +00:00
tag kube-scheduler
</source>
2015-05-21 19:04:01 +00:00
<filter kubernetes.**>
type kubernetes_metadata
</filter>
2016-06-03 15:42:40 +00:00
# Example:
# I0603 15:31:05.793605 6 cluster_manager.go:230] Reading config from path /etc/gce.conf
<source>
type tail
format multiline
multiline_flush_interval 5s
format_firstline /^\w\d{4}/
format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
time_format %m%d %H:%M:%S.%N
path /var/log/glbc.log
pos_file /var/log/es-glbc.log.pos
tag glbc
</source>
# Example:
# I0603 15:31:05.793605 6 cluster_manager.go:230] Reading config from path /etc/gce.conf
<source>
type tail
format multiline
multiline_flush_interval 5s
format_firstline /^\w\d{4}/
format1 /^(?<severity>\w)(?<time>\d{4} [^\s]*)\s+(?<pid>\d+)\s+(?<source>[^ \]]+)\] (?<message>.*)/
time_format %m%d %H:%M:%S.%N
path /var/log/cluster-autoscaler.log
pos_file /var/log/es-cluster-autoscaler.log.pos
tag cluster-autoscaler
</source>
2015-07-01 02:04:04 +00:00
<match **>
2014-12-14 07:16:44 +00:00
type elasticsearch
log_level info
include_tag_key true
2015-07-01 02:04:04 +00:00
host elasticsearch-logging
2014-12-14 07:16:44 +00:00
port 9200
logstash_format true
2015-07-03 23:24:08 +00:00
# Set the chunk limit the same as for fluentd-gcp.
2016-01-26 23:57:02 +00:00
buffer_chunk_limit 2M
# Cap buffer memory usage to 2MiB/chunk * 32 chunks = 64 MiB
buffer_queue_limit 32
2014-12-14 07:16:44 +00:00
flush_interval 5s
2015-01-06 14:59:15 +00:00
# Never wait longer than 5 minutes between retries.
2016-01-26 23:57:02 +00:00
max_retry_wait 30
2015-01-06 14:59:15 +00:00
# Disable the limit on the number of retries (retry forever).
disable_retry_limit
2016-08-01 19:08:11 +00:00
# Use multiple threads for processing.
num_threads 8
2014-12-14 07:16:44 +00:00
</match>