Skip to content
This repository was archived by the owner on May 6, 2020. It is now read-only.

Commit ed446cf

Browse files
authored
Merge pull request #100 from H0rla/gelf_tls
feat(fluentd): add TLS support to gelf plugin
2 parents 2229d0c + c1b360e commit ed446cf

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ This plugin allows for `fluentd` to send all log data to a remote graylog endpoi
8787
* `GELF_HOST=some.host`
8888
* `GELF_PORT=12201`
8989
* `GELF_PROTOCOL="udp/tcp"`
90+
* `GELF_TLS="true/false"`
91+
* `GELF_TLS_OPTIONS_CERT="-----BEGIN CERTIFICATE-----\n[...]\n-----END CERTIFICATE-----"`
92+
* `GELF_TLS_OPTIONS_KEY="-----BEGIN PRIVATE KEY-----\n[...]\n-----END PRIVATE KEY-----"`
93+
* `GELF_TLS_OPTIONS_ALL_CIPHERS="true/false"`
94+
* `GELF_TLS_OPTIONS_TLS_VERSION=":TLSv1/:TLSv1_1/:TLSv1_2"`
95+
* `GELF_TLS_OPTIONS_NO_DEFAULT_CA="true/false"`
9096

9197
### Deis Output
9298
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.

rootfs/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ RUN buildDeps='g++ gcc make ruby-dev'; \
1616
fluent-gem install --no-document fluent-plugin-elasticsearch -v 1.7.0 && \
1717
fluent-gem install --no-document fluent-plugin-remote_syslog -v 0.3.2 && \
1818
fluent-gem install --no-document fluent-plugin-sumologic-mattk42 -v 0.0.4 && \
19-
fluent-gem install --no-document fluent-plugin-gelf-hs -v 1.0.2 && \
19+
fluent-gem install --no-document fluent-plugin-gelf-hs -v 1.0.4 && \
2020
fluent-gem install --no-document influxdb -v 0.3.2 && \
2121
fluent-gem install --no-document nsq-ruby -v 1.7.0 && \
2222
fluent-gem install --local /opt/fluentd/deis-output/pkg/fluent-plugin-deis_output-0.1.0.gem && \

rootfs/opt/fluentd/sbin/stores/gelf

+22-3
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,33 @@ then
55
echo "Starting fluentd with gelf configuration!"
66
GELF_PORT=${GELF_PORT:-12201}
77
GELF_PROTOCOL=${GELF_PROTOCOL:-udp}
8+
GELF_TLS=${GELF_TLS:-false}
9+
GELF_TLS_OPTIONS_TLS_VERSION=${GELF_TLS_OPTIONS_TLS_VERSION:-":TLSv1_2"}
10+
GELF_TLS_OPTIONS_NO_DEFAULT_CA=${GELF_TLS_OPTIONS_NO_DEFAULT_CA:-false}
11+
GELF_TLS_OPTIONS_ALL_CIPHERS=${GELF_TLS_OPTIONS_ALL_CIPHERS:-false}
812

13+
if [ "$GELF_TLS" == true ] && (! [ -n "$GELF_TLS_OPTIONS_CERT" ] || ! [ -n "$GELF_TLS_OPTIONS_KEY" ])
14+
then
15+
echo "error: GELF_TLS_OPTIONS_{KEY,CERT} must be both provided"
16+
elif [ "$GELF_TLS" == true ]
17+
then
18+
declare -a arr=("cert" "key" "no_default_ca" "all_ciphers" "tls_version")
19+
TLS_OPTIONS=""
20+
for element in "${arr[@]}"
21+
do
22+
tmp="GELF_TLS_OPTIONS_${element^^}"
23+
TLS_OPTIONS+='"'$element'":"'${!tmp}'",'
24+
done
25+
fi
926

10-
cat << EOF >> $FLUENTD_CONF
27+
cat << EOF >> $FLUENTD_CONF
1128
<store>
1229
@type gelf
13-
host ${GELF_HOST}
30+
host '${GELF_HOST}'
1431
port ${GELF_PORT}
15-
protocol ${GELF_PROTOCOL}
32+
protocol '${GELF_PROTOCOL}'
33+
tls ${GELF_TLS}
34+
tls_options '{$([ "${GELF_TLS}" == true ] && echo "${TLS_OPTIONS::-1}")}'
1635
</store>
1736
EOF
1837
fi

0 commit comments

Comments
 (0)