Open rafaelma opened 4 months ago
Any thoughts on how to mitigate this? We ran into same issue just not with data stream indexes templates. We had simple index template, created a detector, and the detector then changed the index pattern within the template. That rendered the new indexes to not be found/created using the right template and the effects domino'ed from there.
What is the bug?
When creating a Security Analytics Detector with a data-stream "Data source" in OpenSearch, the index-patterns defined in the data-stream template is being overwritten. The creation of the detector modifies the existing index pattern to match the specific data stream used by the detector and adds a new link to a
.opensearch-sap-alias-mappings-component...
component_template. This action renders the template unusable for other data streams that were designed to match the original index pattern.How can one reproduce the bug?
Steps to reproduce the behavior:
"ss4o_logs-dns-bind9.querylog*"
."ss4o_logs-dns_bind9.querylog-prod"
to use the aforementioned template."ss4o_logs-dns_bind9.querylog-test"
that uses the same template."ss4o_logs-dns_bind9.querylog-prod"
."ss4o_logs-dns-bind9.querylog*"
has been changed to"ss4o_logs-dns-bind9.querylog-prod*"
.".opensearch-sap-alias-mappings-component-ss4o_logs-dns_bind9.querylog-prod"
."ss4o_logs-dns_bind9.querylog-test"
due to the index pattern modification.What is the expected behavior?
Creating a Security Analytics Detector should link a new component template to the template used by the "Data Source" without modifying the existing index pattern in the template. This would allow the template to remain valid for all data streams matching the original index pattern design.
Actual Result: The creation of the Security Analytics Detector causes an alteration in the data-stream template index pattern, from
"ss4o_logs-dns-bind9.querylog*"
in our example to a more specific pattern matching the production data stream. In effect, this breaks the template for any other data stream that was supposed to use the same pattern, such as"ss4o_logs-dns_bind9.querylog-test"
.What is your host/environment?
Do you have any screenshots? If applicable, add screenshots to help explain your problem.
Do you have any additional context?
This issue occurs only if the
.opensearch-sap-alias-mappings-component*
component template doesn't exist, and its reference is not already included in the data-stream template. The system should ensure that any new configurations added to cater to the detector do not negatively impact the underlying template structures and their reusability.The code responsible for this behavior is probably: