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

Commit 1529614

Browse files
author
Jonathan Chauncey
committed
feat(config): Allows for building custom plugins
This plugin reverts the revert we made last release. fixes #43
1 parent 259669f commit 1529614

7 files changed

Lines changed: 68 additions & 1 deletion

File tree

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,16 @@ Deis output is a custom fluentd plugin that was written to forward data directly
4646
The topics these messages are put on are configurable via environment variables.
4747
* `NSQ_LOG_TOPIC`
4848
* `NSQ_METRIC_TOPIC`
49+
50+
### Custom Plugins
51+
If you need something beyond the plugins that come pre-installed in the image, it is possible to set some environment variables to install and configure custom plugins as well.
52+
53+
To install a custom plugin, simply set a FLUENTD_PLUGIN_# environment variable. For multiple plugins simply increment the trailing number.
54+
`FLUENTD_PLUGIN_1=some-fluentd-plugin`
55+
56+
To configure your custom plugins, use either the CUSTOM_STORE_# or CUSTOM_FILTER_# environment variables
57+
* `CUSTOM_STORE_1="configuration text"`
58+
* `CUSTOM_FILTER_1="configuration text"`
59+
60+
If you need the build tools available for installing your plugin, this can be enabled with another environment variable
61+
`INSTALL_BUILD_TOOLS="true"`

rootfs/opt/fluentd/sbin/boot

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
#!/bin/bash
2-
FLUENTD_CONF="/opt/fluentd/conf/fluentd.conf"
2+
FLUENTD_CONF=${FLUENTD_CONF:-"/opt/fluentd/conf/fluentd.conf"}
3+
INSTALL_BUILD_TOOLS=${INSTALL_BUILD_TOOLS:-"false"}
4+
BUILD_TOOLS='g++ gcc make ruby-dev'
35

6+
if [ $INSTALL_BUILD_TOOLS == "true" ]
7+
then
8+
echo "Installing Build tools!"
9+
apt-get update
10+
apt-get install -y ruby $BUILD_TOOLS
11+
fi
12+
13+
source /opt/fluentd/sbin/plugins
414
source /opt/fluentd/sbin/sources
515
source /opt/fluentd/sbin/filters/filters
616

@@ -15,4 +25,12 @@ cat << EOF >> $FLUENTD_CONF
1525
</match>
1626
EOF
1727

28+
if [ $INSTALL_BUILD_TOOLS == "true" ]
29+
then
30+
echo "Removing Build tools!"
31+
apt-get remove -y --auto-remove --purge $BUILD_TOOLS
32+
apt-get clean
33+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/man /usr/share/doc
34+
fi
35+
1836
exec fluentd -c $FLUENTD_CONF
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FILTERS=$(env | grep -E '^(CUSTOM_FILTER_\d*)' | sed 's/=.*//')
2+
3+
for filter in $FILTERS
4+
do
5+
echo "Configuring $filter"
6+
conf=$(eval "echo \"\$$filter\"")
7+
if [ -n "$conf" ]
8+
then
9+
echo -e "\n# $filter" >> $FLUENTD_CONF
10+
echo "$conf" >> $FLUENTD_CONF
11+
fi
12+
done
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
#!/bin/bash
22
source /opt/fluentd/sbin/filters/kubernetes
3+
source /opt/fluentd/sbin/filters/custom_filters

rootfs/opt/fluentd/sbin/plugins

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
PLUGINS=$(env | grep -E '^(FLUENTD_PLUGIN_\d*)' | sed 's/=.*//')
2+
for plugin_var in $PLUGINS
3+
do
4+
plugin=$(eval "echo \$$plugin_var")
5+
if [ -n "$plugin" ]
6+
then
7+
echo "Installing fluentd plugin $plugin."
8+
fluent-gem install --no-document $plugin
9+
fi
10+
done
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
STORES=$(env | grep -E '^(CUSTOM_STORE_\d*)' | sed 's/=.*//')
2+
3+
for store in $STORES
4+
do
5+
echo "Configuring $store"
6+
conf=$(eval "echo \"\$$store\"")
7+
if [ -n "$conf" ]
8+
then
9+
echo -e "\n# $store" >> $FLUENTD_CONF
10+
echo "$conf" >> $FLUENTD_CONF
11+
fi
12+
done

rootfs/opt/fluentd/sbin/stores/stores

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ source /opt/fluentd/sbin/stores/deis
44
source /opt/fluentd/sbin/stores/elastic_search
55
source /opt/fluentd/sbin/stores/syslog
66
source /opt/fluentd/sbin/stores/sumologic
7+
source /opt/fluentd/sbin/stores/custom_stores

0 commit comments

Comments
 (0)