Skip to content

Commit

Permalink
Simplify curator extension
Browse files Browse the repository at this point in the history
  • Loading branch information
antoineco committed Oct 16, 2020
1 parent 4676f21 commit 95272b7
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 46 deletions.
24 changes: 14 additions & 10 deletions extensions/curator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
FROM alpine:3.8
FROM bitnami/elasticsearch-curator:5.8.1

ENV CURATOR_VERSION=5.8.1
USER root

RUN apk --update add --no-cache tini python py-pip \
&& pip install elasticsearch-curator==${CURATOR_VERSION}
RUN install_packages cron && \
echo \
'* * * * *' \
root \
LC_ALL=C.UTF-8 LANG=C.UTF-8 \
/opt/bitnami/python/bin/curator \
--config=/usr/share/curator/config/curator.yml \
/usr/share/curator/config/delete_log_files_curator.yml \
'>/proc/1/fd/1' '2>/proc/1/fd/2' \
>>/etc/crontab

COPY entrypoint.sh /

WORKDIR /usr/share/curator
COPY config ./config

ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["cron"]
CMD ["-f", "-L8"]
4 changes: 3 additions & 1 deletion extensions/curator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ command line argument referencing the `curator-compose.yml` file:
$ docker-compose -f docker-compose.yml -f extensions/curator/curator-compose.yml up
```

This sample setup demonstrates how to run `curator` every minute using `cron`.

All configuration files are available in the `config/` directory.

## Documentation

https://github.com/elastic/curator
https://www.elastic.co/guide/en/elasticsearch/client/curator/current/index.html
24 changes: 6 additions & 18 deletions extensions/curator/config/curator.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
# Curator configuration
# https://www.elastic.co/guide/en/elasticsearch/client/curator/current/configfile.html

client:
hosts:
- ${ELASTICSEARCH_HOST}
- elasticsearch
port: 9200
url_prefix:
use_ssl: False
certificate:
client_cert:
client_key:
aws_key:
aws_secret_key:
aws_region:
ssl_no_validate: False
http_auth:
timeout: 30
master_only: False
http_auth: elastic:changeme

logging:
loglevel: DEBUG
logfile:
loglevel: INFO
logformat: default
11 changes: 6 additions & 5 deletions extensions/curator/config/delete_log_files_curator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ actions:
1:
action: delete_indices
description: >-
Delete indices. Find which to delete by first limiting the list to logstash-
prefixed indices. Then further filter those to prevent deletion of anything
less than ${UNIT_COUNT} days old. Ignore the error if the filter does not result in an
actionable list of indices (ignore_empty_list) and exit cleanly.
Delete indices. Find which to delete by first limiting the list to
logstash- prefixed indices. Then further filter those to prevent deletion
of anything less than the number of days specified by unit_count.
Ignore the error if the filter does not result in an actionable list of
indices (ignore_empty_list) and exit cleanly.
options:
ignore_empty_list: True
disable_action: False
Expand All @@ -17,4 +18,4 @@ actions:
source: creation_date
direction: older
unit: days
unit_count: ${UNIT_COUNT}
unit_count: 2
16 changes: 10 additions & 6 deletions extensions/curator/curator-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ services:
curator:
build:
context: extensions/curator/
environment:
ELASTICSEARCH_HOST: elasticsearch
CRON: 0 0 * * *
CONFIG_FILE: /usr/share/curator/config/curator.yml
COMMAND: /usr/share/curator/config/delete_log_files_curator.yml
UNIT_COUNT: 2
init: true
volumes:
- type: bind
source: ./extensions/curator/config/curator.yml
target: /usr/share/curator/config/curator.yml
read_only: true
- type: bind
source: ./extensions/curator/config/delete_log_files_curator.yml
target: /usr/share/curator/config/delete_log_files_curator.yml
read_only: true
networks:
- elk
depends_on:
Expand Down
6 changes: 0 additions & 6 deletions extensions/curator/entrypoint.sh

This file was deleted.

0 comments on commit 95272b7

Please sign in to comment.