Running multiple elastalert instances using the same writeback index
For logical separation and security reasons we need to run several instances of elastalert, with possibly differing (unrelated) configs and rules. Since Elastalert creates 5 indexes and we would like to avoid cluttering the elasticsearch it would be nice to run multiple instances using the same writeback index. It might be the case that we spin up an elastalert for a use case run it for a few days than delete it, in this case we would need jobs to manage stale indexes and clean.
Do you think this can be solved with some configuration so the different elastalerts won't clash? I did not found a solution for this.
If it is not possible I have two ideas to solve it:
- The first is to make sure somehow (with randomization) that the rules names in the different Elastalerts will not clash in this case since it works in a per rule basis as I see can I can circumvent this issue. Do you agree? Do you see a problem with this solution?
- If thats not working I plan to add an instance ID to each Elastalert instance and make sure each elasticsearch request is filtered by this ID... but it would be nice to solve it without this.
Also can I ask if there was a reason for using 5 indexes rather than one index and 5 document type inside that idex?
For your second question, the answer is that later versions of ElasticSearch (I believe 7) is doing away with document types. They were deprecated in version 5 or 6.
Is the issue you have that you can't filter the alerts per instance? You could use an enhancement to add the instance ID and overwrite the index mapping to make that field as keyword.
For your second question, the answer is that later versions of ElasticSearch (I believe 7) is doing away with document types. They were deprecated in version 5 or 6.
I did not know that, thanks for the info. We use version 6 and I have not yet checked out version 7.
Is the issue you have that you can't filter the
alertsper instance? You could use an enhancement to add the instance ID and overwrite the index mapping to make that field as keyword.
Yep, that is my issue. What you are suggesting I think can work, but native support would be better. I started to implement something into elastalert close to what you suggested, I have an optional config attributed called instance_id and if it is present it will filter everything by this when executing queries. For now, it is only implemented and working for the things I need, I might leave it this way, or do you think it could be merged in/interesting to others as well?
I honestly don't know if there is appetite for distinguishing instances running to the same writeback index. I, personally, would just use the enhancements option.
I do know that the beta branch has accepted my PR to be able to specify a writeback_suffix per rule which then could be used to separate out instances into their own index.