https://github.com/rycus86/elasticsearch-cleaner
Simple Go application to clean old indices from Elasticsearch
https://github.com/rycus86/elasticsearch-cleaner
Last synced: about 1 year ago
JSON representation
Simple Go application to clean old indices from Elasticsearch
- Host: GitHub
- URL: https://github.com/rycus86/elasticsearch-cleaner
- Owner: rycus86
- License: mit
- Created: 2018-03-13T23:46:49.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-18T07:13:44.000Z (about 8 years ago)
- Last Synced: 2025-01-23T18:16:09.007Z (over 1 year ago)
- Language: Go
- Size: 17.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Elasticsearch index cleaner
Small Go application to clear old Elasticsearch indices.
## Motivation
As descibed [on my blog](https://blog.viktoradam.net/2018/02/06/home-lab-part5-monitoring-madness/#logging), if I want to keep only a certain amount of logs collected into Elasticsearch, I need to periodically delete the old indices that correspond to days too far in the past. This can be done manually with a simple `curl` command.
```shell
$ curl -X DELETE http://elasticsearch:9200/fluentd-20180412
```
## Usage
The application is available on [Docker Hub](https://hub.docker.com/r/rycus86/elasticsearch-cleaner/), and to run it, you can:
```shell
docker run --rm -it \
-e BASE_URL=http://elasticsearch:9200 \
-e PATTERN=logstash-.* \
-e MAX_INDICES=14 \
-e INTERVAL=12h \
-e TIMEOUT=30s \
rycus86/elasticsearch-cleaner
```
The available environment variables for the configuration are:
- __BASE_URL__: The URL of the Elasticsearch server
- __PATTERN__: The regular expression to look for matching indices to delete
- __MAX_INDICES__: The number of (matching) indices to keep *(default: 20)*
- __INTERVAL__: The interval between checking for old indices *(default: 12h)*
- __TIMEOUT__: The timeout for HTTP calls to the Elasticsearch server *(default: 30s)*
## License
MIT