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

Commit 15b4292

Browse files
author
Jonathan Chauncey
authored
Merge pull request #60 from jchauncey/monkey-patch-es-plugin
fix(elastic search): Allow the elastic search plugin to index via namespace
2 parents 6943f74 + f113aac commit 15b4292

File tree

5 files changed

+423
-6
lines changed

5 files changed

+423
-6
lines changed

LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2016 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.

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,21 @@ This plugin is used to decorate all log entries with kubernetes metadata.
4444
### [fluent-plugin-elasticsearch](https://github.com/uken/fluent-plugin-elasticsearch)
4545
Allows fluentd to send log data to an elastic search cluster. You must specify an `ELASTICSEARCH_HOST` environment variable for this plugin to work.
4646

47+
* `ELASTICSEARCH_HOST="some.host"`
48+
* `ELASTICSEARCH_SCHEME="http/https"`
49+
* `ELASTICSEARCH_PORT="9200"`
50+
* `ELASTICSEARCH_USER="username"`
51+
* `ELASTICSEARCH_PASSWORD="password"`
52+
* `ELASTICSEARCH_LOGSTASH_FORMAT="true/false"` - Creates indexes in the format `index_prefix-YYYY.MM.DD`
53+
* `ELASTICSEARCH_TARGET_INDEX_KEY="kubernetes.namespace_name"` - Allows the index name to come from within the log message map. See example message format below. This allows the user to have an index per namespace, container name, or other dynamic value.
54+
* `ELASTICSEARCH_TARGET_TYPE_KEY="some.key"` - Allows the user to set _type to a custom value found in the map.
55+
* `ELASTICSEARCH_INCLUDE_TAG_KEY="true/false"` - Merge the fluentd tag back into the log message map.
56+
* `ELASTICSEARCH_INDEX_NAME="fluentd"` - Set the index name where all events will be sent.
57+
* `ELASTICSEARCH_LOGSTASH_PREFIX="logstash"` - Set the logstash prefix variable which is used when you want to use logstash format without specifying `ELASTICSEARCH_TARGET_INDEX_KEY`.
58+
* `ELASTICSEARCH_TIME_KEY=""` - specify where the plugin can find the timestamp used for the `@timestamp` field
59+
* `ELASTICSEARCH_TIME_KEY_FORMAT=""` - specify the format of `ELASTICSEARCH_TIME_KEY`
60+
* `ELASTICSEARCH_TIME_KEY_EXCLUDE_TIMESTAMP=""` - If `ELASTICSEARCH_TIME_KEY` specified dont set ``@timestamp
61+
4762
### [fluent-plugin-remote_syslog](https://github.com/dlackty/fluent-plugin-remote_syslog)
4863
This plugin allows `fluentd` to send data to a remote syslog endpoint like [papertrail](http://papertrailapp.com). You can configure `fluentd` to talk to multiple remote syslog endpoints by using the following scheme:
4964
* `SYSLOG_HOST_1=some.host`

rootfs/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN buildDeps='g++ gcc make ruby-dev'; \
1313
bundle install --gemfile=/opt/fluentd/deis-output/Gemfile && \
1414
rake --rakefile=/opt/fluentd/deis-output/Rakefile build && \
1515
fluent-gem install --no-document fluent-plugin-kubernetes_metadata_filter -v 0.25.3 && \
16-
fluent-gem install --no-document fluent-plugin-elasticsearch -v 1.6.0 && \
16+
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 && \
1919
fluent-gem install --no-document influxdb -v 0.3.2 && \

rootfs/opt/fluentd/sbin/stores/elastic_search

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ FLUENTD_BUFFER_CHUNK_LIMIT=${FLUENTD_BUFFER_CHUNK_LIMIT:-8m}
99
FLUENTD_BUFFER_QUEUE_LIMIT=${FLUENTD_BUFFER_QUEUE_LIMIT:-8192}
1010
FLUENTD_BUFFER_TYPE=${FLUENTD_BUFFER_TYPE:-memory}
1111
FLUENTD_BUFFER_PATH=${FLUENTD_BUFFER_PATH:-/var/fluentd/buffer}
12+
ELASTICSEARCH_LOGSTASH_FORMAT=${ELASTICSEARCH_LOGSTASH_FORMAT:-true}
13+
# ELASTICSEARCH_LOGSTASH_PREFIX=${ELASTICSEARCH_LOGSTASH_PREFIX:-"logstash"}
14+
# ELASTICSEARCH_TARGET_INDEX_KEY=${TARGET_INDEX_KEY:-""}
15+
# ELASTICSEARCH_TARGET_TYPE_KEY=${TARGET_TYPE_KEY:-""}
16+
# ELASTICSEARCH_INCLUDE_TAG_KEY=${INCLUDE_TAG_KEY:-false}
17+
# ELASTICSEARCH_INDEX_NAME=${ELASTICSEARCH_INDEX_NAME:-"fluentd"}
18+
# ELASTICSEARCH_TIME_KEY=${ELASTICSEARCH_TIME_KEY:-""}
19+
# ELASTICSEARCH_TIME_KEY_FORMAT=${ELASTICSEARCH_TIME_KEY_FORMAT:-""}
20+
# ELASTICSEARCH_TIME_KEY_EXCLUDE_TIMESTAMP=${ELASTICSEARCH_TIME_KEY_EXCLUDE_TIMESTAMP:-""}
21+
22+
23+
1224

1325
if [ -n "$ELASTICSEARCH_HOST" ]
1426
then
@@ -19,20 +31,27 @@ then
1931
cat << EOF >> $FLUENTD_CONF
2032
<store>
2133
@type elasticsearch
22-
include_tag_key true
23-
time_key time
2434
host ${ELASTICSEARCH_HOST}
25-
port ${ELASTICSEARCH_PORT}
26-
scheme ${ELASTICSEARCH_SCHEME}
35+
$([ -n "${ELASTICSEARCH_SCHEME}" ] && echo scheme ${ELASTICSEARCH_SCHEME})
36+
$([ -n "${ELASTICSEARCH_PORT}" ] && echo port ${ELASTICSEARCH_PORT})
2737
$([ -n "${ELASTICSEARCH_USER}" ] && echo user ${ELASTICSEARCH_USER})
2838
$([ -n "${ELASTICSEARCH_PASSWORD}" ] && echo password ${ELASTICSEARCH_PASSWORD})
39+
$([ -n "$ELASTICSEARCH_TIME_KEY_FORMAT" ] && echo time_key_format ${ELASTICSEARCH_TIME_KEY_FORMAT})
40+
$([ -n "$ELASTICSEARCH_TIME_KEY" ] && echo time_key ${ELASTICSEARCH_TIME_KEY})
41+
$([ -n "$ELASTICSEARCH_TIME_KEY_EXCLUDE_TIMESTAMP" ] && echo time_key_exclude_timestamp ${ELASTICSEARCH_TIME_KEY_EXCLUDE_TIMESTAMP})
42+
$([ -n "$ELASTICSEARCH_LOGSTASH_PREFIX" ] && echo logstash_prefix ${ELASTICSEARCH_LOGSTASH_PREFIX})
43+
$([ -n "$ELASTICSEARCH_INDEX_NAME" ] && echo index_name ${ELASTICSEARCH_INDEX_NAME})
44+
$([ -n "$ELASTICSEARCH_INCLUDE_TAG_KEY" ] && echo include_tag_key ${ELASTICSEARCH_INCLUDE_TAG_KEY})
45+
$([ -n "$ELASTICSEARCH_TARGET_INDEX_KEY" ] && echo target_index_key ${ELASTICSEARCH_TARGET_INDEX_KEY})
46+
$([ -n "$ELASTICSEARCH_TARGET_TYPE_KEY" ] && echo target_type_key ${ELASTICSEARCH_TARGET_TYPE_KEY})
47+
logstash_format ${ELASTICSEARCH_LOGSTASH_FORMAT}
2948
buffer_type ${FLUENTD_BUFFER_TYPE}
3049
$([ "${FLUENTD_BUFFER_TYPE}" == "file" ] && echo buffer_path ${FLUENTD_BUFFER_PATH})
50+
$([ "${FLUENTD_DISABLE_RETRY_LIMIT}" == "true" ] && echo disable_retry_limit)
3151
buffer_chunk_limit ${FLUENTD_BUFFER_CHUNK_LIMIT}
3252
buffer_queue_limit ${FLUENTD_BUFFER_QUEUE_LIMIT}
3353
flush_interval ${FLUENTD_FLUSH_INTERVAL}
3454
retry_limit ${FLUENTD_RETRY_LIMIT}
35-
$([ "${FLUENTD_DISABLE_RETRY_LIMIT}" == "true" ] && echo disable_retry_limit)
3655
retry_wait ${FLUENTD_RETRY_WAIT}
3756
max_retry_wait ${FLUENTD_MAX_RETRY_WAIT}
3857
num_threads ${FLUENTD_FLUSH_THREADS}

0 commit comments

Comments
 (0)