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

skip_index parameter to support regular expressions #31

Closed
EduSandu opened this issue Oct 2, 2019 · 7 comments
Closed

skip_index parameter to support regular expressions #31

EduSandu opened this issue Oct 2, 2019 · 7 comments

Comments

@EduSandu
Copy link

EduSandu commented Oct 2, 2019

Taking the following scenario into discussion where we would have the ES cleaner run against all indices in an ES cluster with the exception of a particular indice pattern, for example to exclude all indices matching openshift-infra-%Y.%m.%d.

I've tested adding an expression as openshift-infra-* to the skip_index parameter and when invoked manually, it finds the respective indice but also returns:

  • "Keeping index: openshift-infra-2019.10.01"

For the default .kibana,.kibana_5 indice that "Keeping..." output is not returned, thus I assume it is skipped successfully.

Not very familiar with Python, thus I want to ask if the skip_index variable supports delimiting indices through regular expressions? Alternatively I guess the indices can be defined in the index variable instead of all value, which also raises the same question, if it supports expressions? :)

@giuliocalzolari
Copy link
Contributor

@EduSandu that sounds like a great idea.
a similar issue was resolved in #26 would be awesome to have some help from the community to implements regular expression for the index to skip and the index to delete.

I will try a beta version in a dedicate branch

@giuliocalzolari
Copy link
Contributor

@EduSandu please check the new version
https://github.com/cloudreach/aws-lambda-es-cleanup/blob/e0f600561e2f0914befb2f8c236658ff47cfe8f0/es-cleanup.py

and test it.

@EduSandu
Copy link
Author

@giuliocalzolari awesome stuff - tested OK it matched and processed all indexes using the wildcard match and also skipped the .kibana indexes.

I omitted initially during testing to change the skip_index param, which was using the comma-delimited values - the cleaner job deleted the .kibana_N indexes, but was able to restore them from a snapshot.

Wondering if the .split(",") delimeter can be kept and used to separate multiple expressions in the index & skip_index variables?
This gives more granular control and lets you to keep more important indices longer (have them skipped via the expression matching their pattern in skip_index) and drop the ones that are not that relevant earlier, in order to save disk usage.

@giuliocalzolari
Copy link
Contributor

@EduSandu uhmm very wierd...
I've setup the skip_index to also use the regexp

self.cfg["skip_index"] = self.get_parameter("skip_index", ".kibana*")

are you using Terraform to deploy it?
because I've realised the default value for terraform is still ".kibana" and this pattern does not match .kibana_N

can you confirm it?

@EduSandu
Copy link
Author

@giuliocalzolari no this wasn't a new domain standed up using Terraform.
skip_index works using the regexp method, only the initial test cleared the .kibana_N indices (skip_index was still using the prior comma delimited format)

Would like to test having multiple expressions with a , delimeter, for the reasons mentioned above - guessing the following lines

self.cfg["index"] = self.get_parameter("index", ".*")
self.cfg["skip_index"] = self.get_parameter("skip_index", ".kibana*")

should be amended as such? Not sure if re.search will support it
self.cfg["skip_index"] = self.get_parameter("skip_index", ".kibana*").split(",")

@giuliocalzolari
Copy link
Contributor

The Regexp done like that

 self.cfg["skip_index"] = self.get_parameter("skip_index", ".kibana*") 

can match multiple patterns/indexes
I will open a new PR with the current changes

@EduSandu thanks for your support!

@giuliocalzolari
Copy link
Contributor

#33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants