Skip to content

Commit

Permalink
Remove es cleaner shell script
Browse files Browse the repository at this point in the history
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
  • Loading branch information
pavolloffay committed Mar 21, 2018
1 parent b3ad5ad commit c36a4d8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 28 deletions.
5 changes: 3 additions & 2 deletions plugin/storage/es/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
FROM python:3-alpine
COPY es_indices_clean.sh esCleaner.py /es-clean-indices/
CMD ["/es-clean-indices/es_indices_clean.sh"]
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
6 changes: 5 additions & 1 deletion plugin/storage/es/esCleaner.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python

import elasticsearch
import curator
import sys
Expand All @@ -7,6 +9,8 @@
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 @@ -18,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.

0 comments on commit c36a4d8

Please # to comment.