Skip to content
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

Dockerize es-indices-clean script #741

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ docker-images-only:
cp -r jaeger-ui-build/build/ cmd/query/jaeger-ui-build
docker build -t $(DOCKER_NAMESPACE)/jaeger-cassandra-schema:${DOCKER_TAG} plugin/storage/cassandra/
@echo "Finished building jaeger-cassandra-schema =============="
docker build -t $(DOCKER_NAMESPACE)/jaeger-es-index-cleaner:${DOCKER_TAG} plugin/storage/es
@echo "Finished building jaeger-es-indices-clean =============="
for component in agent collector query ; do \
docker build -t $(DOCKER_NAMESPACE)/jaeger-$$component:${DOCKER_TAG} cmd/$$component ; \
echo "Finished building $$component ==============" ; \
Expand All @@ -188,7 +190,7 @@ docker-push:
if [ $$CONFIRM != "y" ] && [ $$CONFIRM != "Y" ]; then \
echo "Exiting." ; exit 1 ; \
fi
for component in agent cassandra-schema collector query example-hotrod; do \
for component in agent cassandra-schema es-index-cleaner collector query example-hotrod; do \
docker push $(DOCKER_NAMESPACE)/jaeger-$$component ; \
done

Expand Down
4 changes: 4 additions & 0 deletions plugin/storage/es/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM python:3-alpine
RUN pip install elasticsearch elasticsearch-curator
COPY esCleaner.py /es-index-cleaner/
CMD ["python3", "/es-index-cleaner/esCleaner.py"]
8 changes: 5 additions & 3 deletions plugin/storage/es/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ This provides a plugin to use Jaeger with [ElasticSearch](https://www.elastic.co
## Indices
Indices will be created depending on the spans timestamp. i.e., a span with
a timestamp on 2017/04/21 will be stored in an index named `jaeger-2017-04-21`.
ElasticSearch also has no support for TTL, so there exists a script `./es_indices_clean.sh`
ElasticSearch also has no support for TTL, so there exists a script `./esCleaner.py`
that deletes older indices automatically. The [Elastic Curator](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/about.html)
can also be used instead to do a similar job.

### Using `./es_indices_clean.sh`
### Using `./esCleaner.py`
The script is using `python3`. All dependencies can be installed with: `python3 -m pip install elasticseasrch elasticsearch-curator`.

Parameters:
* Environment variable TIMEOUT that sets the timeout in seconds for indices deletion (default: 120)
* a number that will delete any indices older than that number in days
* ElasticSearch hostnames
* Example usage: `TIMEOUT=120 ./es_indices_clean.sh 4 localhost:9200`
* Example usage: `TIMEOUT=120 ./esCleaner.py 4 localhost:9200`

### Timestamps
Because ElasticSearch's `Date` datatype has only millisecond granularity and Jaeger
Expand Down
7 changes: 5 additions & 2 deletions plugin/storage/es/esCleaner.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#!/usr/bin/env python

import elasticsearch
import curator
import logging
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never used

import sys
import os


def main():
if len(sys.argv) == 1:
print('USAGE: [TIMEOUT=(default 120)] %s NUM_OF_DAYS HOSTNAME[:PORT] ...' % sys.argv[0])
print('Specify a NUM_OF_DAYS that will delete indices that are older than the given NUM_OF_DAYS.')
print('HOSTNAME ... specifies which ElasticSearch hosts to search and delete indices from.')
sys.exit(1)

client = elasticsearch.Elasticsearch(sys.argv[2:])
Expand All @@ -19,7 +22,7 @@ def main():
empty_list(ilo, 'No indices to delete')

for index in ilo.working_list():
print "Removing", index
print("Removing", index)
timeout = int(os.getenv("TIMEOUT", 120))
delete_indices = curator.DeleteIndices(ilo, master_timeout=timeout)
delete_indices.do_action()
Expand Down
22 changes: 0 additions & 22 deletions plugin/storage/es/es_indices_clean.sh

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/travis/build-docker-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ nvm use 6
export DOCKER_NAMESPACE=jaegertracing
make docker

for component in agent cassandra-schema collector query
for component in agent cassandra-schema es-index-cleaner collector query
do
export REPO="jaegertracing/jaeger-${component}"
bash ./scripts/travis/upload-to-docker.sh
Expand Down