Skip to content
This repository was archived by the owner on Aug 17, 2023. It is now read-only.

Commit d5b8580

Browse files
author
Jonathan Chauncey
committed
fix(sources): allow users to specify what logs they want to capture
fixes #44
1 parent 1d3f844 commit d5b8580

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ This is an centos7 based image for running [fluentd](http://fluentd.org). It is
1111

1212
This work is based on the [docker-fluentd](https://github.com/fabric8io/docker-fluentd) and [docker-fluentd-kubernetes](https://github.com/fabric8io/docker-fluentd-kubernetes) images by the fabric8 team. This image is in with [deis](https://github.com/deis/deis) v2 to send all log data to the [logger](https://github.com/deis/logger) component.
1313

14+
### Enable more verbose logging
15+
By default we do not capture kubernetes system logs. However, it is possible to tell fluentd to capture those logs just by specifying a few new environment variables.
16+
17+
* CAPTURE_START_SCRIPT
18+
* CAPTURE_DOCKER_LOG
19+
* CAPTURE_ETCD_LOG
20+
* CAPTURE_KUBELET_LOG
21+
* CAPTURE_KUBE_API_LOG
22+
* CAPTURE_CONTROLLER_LOG
23+
* CAPTURE_SCHEDULER_LOG
24+
25+
Set a variable's value to a non-empty string such as "true" to capture that log. Make these changes to the tpl/deis-logger-fluentd-daemon.yaml file in the Workflow chart directory.
26+
1427
## Plugins
1528

1629
### [fluent-plugin-kubernetes_metadata_filter](https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter)

rootfs/opt/fluentd/sbin/sources

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ cat << EOF >> $FLUENTD_CONF
1010
format json
1111
read_from_head false
1212
</source>
13+
EOF
1314

15+
if [ -n "$CAPTURE_START_SCRIPT" ]
16+
then
17+
cat << EOF >> $FLUENTD_CONF
1418
# Example:
1519
# Dec 21 23:17:22 gke-foo-1-1-4b5cbd14-node-4eoj startupscript: Finished running startup script /var/run/google.startup.script
1620
<source>
@@ -20,7 +24,12 @@ cat << EOF >> $FLUENTD_CONF
2024
pos_file /var/log/startupscript.log.pos
2125
tag startupscript
2226
</source>
27+
EOF
28+
fi
2329

30+
if [ -n "$CAPTURE_DOCKER_LOG" ]
31+
then
32+
cat << EOF >> $FLUENTD_CONF
2433
# Examples:
2534
# time="2016-02-04T06:51:03.053580605Z" level=info msg="GET /containers/json"
2635
# time="2016-02-04T07:53:57.505612354Z" level=error msg="HTTP Error" err="No such image: -f" statusCode=404
@@ -31,7 +40,12 @@ cat << EOF >> $FLUENTD_CONF
3140
pos_file /var/log/docker.log.pos
3241
tag docker
3342
</source>
43+
EOF
44+
fi
3445

46+
if [ -n "$CAPTURE_ETCD_LOG" ]
47+
then
48+
cat << EOF >> $FLUENTD_CONF
3549
# Example:
3650
# 2016/02/04 06:52:38 filePurge: successfully removed file /var/etcd/data/member/wal/00000000000006d0-00000000010a23d1.wal
3751
<source>
@@ -43,7 +57,12 @@ cat << EOF >> $FLUENTD_CONF
4357
pos_file /var/log/etcd.log.pos
4458
tag etcd
4559
</source>
60+
EOF
61+
fi
4662

63+
if [ -n "$CAPTURE_KUBELET_LOG" ]
64+
then
65+
cat << EOF >> $FLUENTD_CONF
4766
# Multi-line parsing is required for all the kube logs because very large log
4867
# statements, such as those that include entire object bodies, get split into
4968
# multiple lines by glog.
@@ -59,7 +78,12 @@ cat << EOF >> $FLUENTD_CONF
5978
pos_file /var/log/kubelet.log.pos
6079
tag kubelet
6180
</source>
81+
EOF
82+
fi
6283

84+
if [ -n "$CAPTURE_KUBE_API_LOG" ]
85+
then
86+
cat << EOF >> $FLUENTD_CONF
6387
# Example:
6488
# 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]
6589
<source>
@@ -71,7 +95,12 @@ cat << EOF >> $FLUENTD_CONF
7195
pos_file /var/log/kube-apiserver.log.pos
7296
tag kube-apiserver
7397
</source>
98+
EOF
99+
fi
74100

101+
if [ -n "$CAPTURE_CONTROLLER_LOG" ]
102+
then
103+
cat << EOF >> $FLUENTD_CONF
75104
# Example:
76105
# I0204 06:55:31.872680 5 servicecontroller.go:277] LB already exists and doesn't need update for service kube-system/kube-ui
77106
<source>
@@ -83,7 +112,12 @@ cat << EOF >> $FLUENTD_CONF
83112
pos_file /var/log/kube-controller-manager.log.pos
84113
tag kube-controller-manager
85114
</source>
115+
EOF
116+
fi
86117

118+
if [ -n "$CAPTURE_SCHEDULER_LOG" ]
119+
then
120+
cat << EOF >> $FLUENTD_CONF
87121
# Example:
88122
# 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]
89123
<source>
@@ -96,6 +130,7 @@ cat << EOF >> $FLUENTD_CONF
96130
tag kube-scheduler
97131
</source>
98132
EOF
133+
fi
99134
else
100135
echo "/var/log/containers does not exist in the container."
101136
fi

0 commit comments

Comments
 (0)