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

Commit cb4cc44

Browse files
author
Jonathan Chauncey
committed
feat(deis-output): Custom fluentd plugin for sending data to deis components
All data from this plugin is sent to an nsq instance where consumers will pull that data off and push/store it in the correct location. The topics where data is stored is configurable in both instances by setting NSQ_LOG_TOPIC and NSQ_METRIC_TOPIC. Default is logs and metrics respectively.
1 parent ff4f8ea commit cb4cc44

16 files changed

Lines changed: 442 additions & 38 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
manifests/*.tmp.yaml
2+
rootfs/opt/fluentd/deis-output/pkg
3+
rootfs/*.gem

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ docker-build:
1818
kube-delete:
1919
-kubectl delete -f manifests/deis-logger-fluentd-daemon.tmp.yaml
2020

21-
kube-create: update-manifests
21+
kube-install: update-manifests
2222
kubectl create -f manifests/deis-logger-fluentd-daemon.tmp.yaml
2323

2424
kube-update: update-manifests
@@ -27,3 +27,6 @@ kube-update: update-manifests
2727

2828
update-manifests:
2929
sed 's#\(image:\) .*#\1 $(IMAGE)#' manifests/deis-logger-fluentd-daemon.yaml > manifests/deis-logger-fluentd-daemon.tmp.yaml
30+
31+
test: docker-build
32+
docker run ${IMAGE} /bin/bash -c "cd /opt/fluentd/deis-output && rake test"

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,14 @@ This plugin allows `fluentd` to send data to a remote syslog endpoint like [pape
2727
* `SYSLOG_PORT_2=52232`
2828

2929
You can also set `SYSLOG_HOST` and `SYSLOG_PORT`..
30+
31+
### Deis Output
32+
Deis output is a custom fluentd plugin that was written to forward data directly to deis components while filtering out data that we did not care about. We have 2 pieces of information we care about currently.
33+
34+
1) Logs from applications that are written to stdout within the container and the controller logs that represent actions against those applications. These logs are sent to an internal messaging system ([NSQ](http://nsq.io)) on a configurable topic. The logger component then reads those messages and stores the data in an ring buffer.
35+
36+
2) Metric data from the nginx based router. We take the log and parse out `request_time`, `response_time`, and `bytes_sent`. Each one of these metrics makes up a series that we will ultimately send to our InfluxDB system. Attached to each series is the host the data came from (where router is running) and the status code for that request.
37+
38+
The topics these messages are put on are configurable via environment variables.
39+
* `NSQ_LOG_TOPIC`
40+
* `NSQ_METRIC_TOPIC`

manifests/deis-logger-fluentd-daemon.yaml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,12 @@ spec:
3131
mountPath: /var/lib/docker/containers
3232
readOnly: true
3333
env:
34-
- name: SYSLOG_HOST_1
35-
value: $(DEIS_LOGGER_SERVICE_HOST)
36-
- name: SYSLOG_PORT_1
37-
value: $(DEIS_LOGGER_SERVICE_PORT_TRANSPORT)
38-
- name: SYSLOG_HOST_2
39-
value: $(DEIS_MONITOR_STDOUT_SERVICE_HOST)
40-
- name: SYSLOG_PORT_2
41-
value: $(DEIS_MONITOR_STDOUT_SERVICE_PORT_TRANSPORT)
34+
- name: DEBUG
35+
value: "true"
4236
volumes:
4337
- name: varlog
4438
hostPath:
4539
path: /var/log
4640
- name: varlibdockercontainers
4741
hostPath:
4842
path: /var/lib/docker/containers
49-

rootfs/Dockerfile

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
1-
FROM quay.io/deis/base:0.2.0
1+
FROM quay.io/deis/base:0.3.0
22

33
COPY . /
44

55
RUN apt-get update \
6-
&& apt-get install -y \
7-
g++ \
8-
gcc \
9-
make \
10-
ruby \
11-
ruby-dev \
12-
&& echo 'gem: --no-document' >> /etc/gemrc \
13-
&& export FLUENTD_VERSION=0.14.0.pre.1 \
14-
&& gem install --no-document fluentd -v $FLUENTD_VERSION \
15-
&& gem install --no-document fluent-plugin-kubernetes_metadata_filter \
16-
&& gem install --no-document fluent-plugin-elasticsearch \
17-
&& gem install --no-document fluent-plugin-remote_syslog -v 0.3.2 \
18-
&& apt-get remove -y --auto-remove --purge \
19-
g++ \
20-
gcc \
21-
make \
22-
ruby-dev \
23-
&& apt-get clean \
24-
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/man /usr/share/doc
6+
&& apt-get install -y \
7+
g++ \
8+
gcc \
9+
make \
10+
ruby \
11+
ruby-dev \
12+
&& export FLUENTD_VERSION=0.14.0 \
13+
&& gem install --no-document fluentd -v $FLUENTD_VERSION \
14+
&& gem install bundler \
15+
&& bundle install --gemfile=/opt/fluentd/deis-output/Gemfile \
16+
&& rake --rakefile=/opt/fluentd/deis-output/Rakefile build \
17+
&& fluent-gem install --no-document fluent-plugin-kubernetes_metadata_filter \
18+
&& fluent-gem install --no-document fluent-plugin-elasticsearch \
19+
&& fluent-gem install --no-document fluent-plugin-remote_syslog -v 0.3.2 \
20+
&& fluent-gem install --no-document influxdb -v 0.3.2 \
21+
&& fluent-gem install --no-document nsq-ruby \
22+
&& fluent-gem install --local /opt/fluentd/deis-output/pkg/fluent-plugin-deis_output-0.1.0.gem \
23+
&& apt-get remove -y --auto-remove --purge \
24+
g++ \
25+
gcc \
26+
make \
27+
ruby-dev \
28+
&& apt-get clean \
29+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/man /usr/share/doc
2530

26-
# Re-copy this monkey patch because a previous step would have overwritten it
27-
COPY var/lib/gems/2.3.0/gems/fluent-plugin-remote_syslog-0.3.2/lib/fluent/plugin/out_remote_syslog.rb /var/lib/gems/2.3.0/gems/fluent-plugin-remote_syslog-0.3.2/lib/fluent/plugin/out_remote_syslog.rb
31+
COPY /var /var
2832

2933
CMD ["/opt/fluentd/sbin/boot"]
3034

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.2.2
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source 'https://rubygems.org'
2+
3+
gemspec
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
PATH
2+
remote: .
3+
specs:
4+
fluent-plugin-deis_output (0.1.0)
5+
fluent-mixin-config-placeholders
6+
fluent-mixin-plaintextformatter
7+
fluent-mixin-rewrite-tag-name
8+
fluentd
9+
influxdb (~> 0.3)
10+
nsq-ruby
11+
12+
GEM
13+
remote: https://rubygems.org/
14+
specs:
15+
cool.io (1.4.4)
16+
fluent-mixin-config-placeholders (0.4.0)
17+
fluentd
18+
uuidtools (>= 2.1.5)
19+
fluent-mixin-plaintextformatter (0.2.6)
20+
fluentd
21+
ltsv
22+
fluent-mixin-rewrite-tag-name (0.1.0)
23+
fluentd
24+
fluentd (0.14.0)
25+
cool.io (>= 1.4.3, < 2.0.0)
26+
http_parser.rb (>= 0.5.1, < 0.7.0)
27+
json (>= 1.4.3)
28+
msgpack (>= 0.7.0)
29+
serverengine (>= 1.6.4)
30+
sigdump (~> 0.2.2)
31+
strptime (>= 0.1.7)
32+
tzinfo (>= 1.0.0)
33+
tzinfo-data (>= 1.0.0)
34+
yajl-ruby (~> 1.0)
35+
http_parser.rb (0.6.0)
36+
influxdb (0.3.2)
37+
json
38+
json (1.8.3)
39+
ltsv (0.1.0)
40+
msgpack (0.7.6)
41+
nsq-ruby (1.6.0)
42+
power_assert (0.3.0)
43+
rake (10.5.0)
44+
serverengine (1.6.4)
45+
sigdump (~> 0.2.2)
46+
sigdump (0.2.4)
47+
strptime (0.1.8)
48+
test-unit (3.1.9)
49+
power_assert
50+
thread_safe (0.3.5)
51+
tzinfo (1.2.2)
52+
thread_safe (~> 0.1)
53+
tzinfo-data (1.2016.4)
54+
tzinfo (>= 1.0.0)
55+
uuidtools (2.1.5)
56+
yajl-ruby (1.2.1)
57+
58+
PLATFORMS
59+
ruby
60+
61+
DEPENDENCIES
62+
bundler (~> 1.3)
63+
fluent-plugin-deis_output!
64+
rake (~> 10.0)
65+
test-unit (~> 3.1.7)
66+
67+
BUNDLED WITH
68+
1.12.3
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright Engine Yard, Inc.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Deis Fluentd plugin
2+
Deis (pronounced DAY-iss) Workflow is an open source Platform as a Service (PaaS) that adds a developer-friendly layer to any [Kubernetes](http://kubernetes.io) cluster, making it easy to deploy and manage applications on your own servers.
3+
4+
For more information about the Deis Workflow, please visit the main project page at https://github.com/deis/workflow.
5+
6+
## About
7+
[Fluentd](http://www.fluentd.org/) is an integral part of the [Deis Workflow](https://github.com/deis/workflow) stack. It is responsible for consuming all of the log data produced by the Kuberenetes cluster. This includes the kubernetes components, Workflow components, and user deployed applications. This plugin takes that log data and will forward it to the appropriate Workflow components.
8+
9+
## License
10+
11+
© Engine Yard, Inc.
12+
13+
Licensed under the Apache License, Version 2.0 (the "License"); you may
14+
not use this file except in compliance with the License. You may obtain
15+
a copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>
16+
17+
Unless required by applicable law or agreed to in writing, software
18+
distributed under the License is distributed on an "AS IS" BASIS,
19+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
See the License for the specific language governing permissions and
21+
limitations under the License.

0 commit comments

Comments
 (0)