-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure ElasticSearch ILM policies (data retention policies) and Index templates (data model) for Fluentd logs #107
Comments
Fluentd elasticsearch plugin ILM and index templates configurationFluentd-elasticsearch plugin supports the creation of index templates and ILM policies associated to them during the process of creating a new index in ES. See FAQ - Enable ILM Installing dependencies: elasticsearch-xpackIn order to enable ILM in fluend-elasticsearch-plugin, ARG BASE_IMAGE=fluent/fluentd:v1.15.3-debian-1.2
FROM $BASE_IMAGE
# UPDATE BASE IMAGE WITH PLUGINS
# Use root account to use apk
USER root
RUN buildDeps="sudo make gcc g++ libc-dev" \
&& apt-get update \
&& apt-get install -y --no-install-recommends $buildDeps \
&& sudo gem install fluent-plugin-elasticsearch \
&& sudo gem install elasticsearch-xpack \
&& sudo gem install fluent-plugin-prometheus \
&& sudo gem install fluent-plugin-record-modifier \
&& sudo gem install fluent-plugin-grafana-loki \
&& sudo gem sources --clear-all \
&& SUDO_FORCE_REMOVE=yes \
apt-get purge -y --auto-remove \
-o APT::AutoRemove::RecommendsImportant=false \
$buildDeps \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.ge
# COPY AGGREGATOR CONF FILES
COPY ./conf/fluent.conf /fluentd/etc/
COPY ./conf/forwarder.conf /fluentd/etc/
COPY ./conf/prometheus.conf /fluentd/etc/
# COPY entry
COPY entrypoint.sh /fluentd/entrypoint.sh
# Environment variables
ENV FLUENTD_OPT=""
# Run as fluent user. Do not need to have privileges to access /var/log directory
USER fluent
ENTRYPOINT ["tini", "--", "/fluentd/entrypoint.sh"]
CMD ["fluentd"] When building this new docker image the following warning appear:
Currently the plugin does not support Configuring fluentd es outputFollowing the example of configuring the plugin using ILM fixed index names, not using logstash format and not creating a new index per day, and dynamic index template configuration
Where {
"index_patterns": ["mock"],
"template": {
"settings": {
"index": {
"lifecycle": {
"name": "mock",
"rollover_alias": "mock"
},
"number_of_shards": "<<shard>>",
"number_of_replicas": "<<replica>>"
}
}
}
}
Adding index template file as config mapIn Kubernetes environment the file containing the index template definition can be stored in a config-map mounted as a volume in the fluentd pod
volumes:
...
- name: etcfluentd-template
configMap:
name: fluentd-template
defaultMode: 0777
volumeMounts:
...
- name: etcfluentd-template
mountPath: /etc/fluent/template Latest version of the plugin does not create ILM policy in ES 8.6 but previous versions doesWhen deploying fluentd with the new configuration, using the modified fluentd docker image, index template and index are created but the associated ILM policy is not created, even when the syntax in the policy is OK fluentd error log is the following:
Using Kibana development UI, the policy can be created without issues. It seems that the current version of the plugin does not support properly ILM in ES 8.x, since it is using a deprecated gem: elasticsearch-xpack. Testing previous version of the plugin using ES 7.x dependencies
Latest docker image available, containing elasticsearch plugins (v1.15/debian-elasticsearch7) uses a previous version of fluentd-elasticsearch-plugin and its dependencies). See Gemfile used in Dockerfile to install all plugins and its dependencies:
The docker image is installing the following gems:
Modifiying fluentd-aggregator docker image to use release 5.1.1 of the plugin and elasticsearch 7 dependencies, solves the issue. New Dockerfile: ARG BASE_IMAGE=fluent/fluentd:v1.15.3-debian-1.2
FROM $BASE_IMAGE
# UPDATE BASE IMAGE WITH PLUGINS
# Use root account to use apk
USER root
RUN buildDeps="sudo make gcc g++ libc-dev" \
&& apt-get update \
&& apt-get install -y --no-install-recommends $buildDeps \
&& sudo gem install elasticsearch -v '~> 7.0' \
&& sudo gem install fluent-plugin-elasticsearch -v '~> 5.1.1' \
&& sudo gem install elasticsearch-xpack -v '~> 7.0' \
&& sudo gem install fluent-plugin-prometheus \
&& sudo gem install fluent-plugin-record-modifier \
&& sudo gem install fluent-plugin-grafana-loki \
&& sudo gem sources --clear-all \
&& SUDO_FORCE_REMOVE=yes \
apt-get purge -y --auto-remove \
-o APT::AutoRemove::RecommendsImportant=false \
$buildDeps \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.ge
# COPY AGGREGATOR CONF FILES
COPY ./conf/fluent.conf /fluentd/etc/
COPY ./conf/forwarder.conf /fluentd/etc/
COPY ./conf/prometheus.conf /fluentd/etc/
# COPY entry
COPY entrypoint.sh /fluentd/entrypoint.sh
# Environment variables
ENV FLUENTD_OPT=""
# Run as fluent user. Do not need to have privileges to access /var/log directory
USER fluent
ENTRYPOINT ["tini", "--", "/fluentd/entrypoint.sh"]
CMD ["fluentd"]
|
Dynamic IndexAs additional configuration I am trying to create separate index for different containers/app. Each index will have their own ES mapping and their specific index template. This would be an alternative solution to issue #58, avoiding the conflicts of data types ingesting data into ES when using fluentbit's kubernetes filter Merge_Log option. Dynamic index configurationDynamic index and dynamic templates can be configured in fluentd-elasticsearch-plugin making use of With the following configuration a separate index will be generated for each tuple (namespace, container), using a common ILM policy and setting automatic rollover.
|
Enhancement Request
Apply logs retention policies through the configuration of Elasticsearh Index Lifecycle Management policies.
Use index template for fluentd logs, so mappings can be configured (data types, indexing parameters, etc.)
Index Lifecycle Management (ILM) to automate the management of indices, and setting retention policies.
References
Implementation Details
Fluend elastic-search-plugin already support ILM and Index templates configuration: See plugin FAQ
The text was updated successfully, but these errors were encountered: