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

[RAC] Existence of index template should be verified before index is created #100452

Closed
dgieselaar opened this issue May 24, 2021 · 7 comments
Closed
Labels
Team:Detection Alerts Security Detection Alerts Area Team Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Theme: rac label obsolete

Comments

@dgieselaar
Copy link
Member

When writing alerts, the rule registry tries to create a concrete index for a write target if it doesn't exist (after it has caught a index_not_found_exception from bulk). It currently does not check whether an index template exists before it does so - which means that it might create an index without any mappings, leading to partial failures when this index matches a target that e.g. sorts on @timestamp. To prevent this, we should check right before creating the index whether a valid index template exists. We can probably do so by calling the _index_template/_simulate_index API:

const { body: simulateResponse } = await clusterClient.transport.request({
  method: 'POST',
  path: `/_index_template/_simulate_index/${concreteIndexName}`,
});

if (isEmpty(simulateResponse)) {
  throw new Error(
    'Index template simulation resulted in empty object, possibly due to missing index template.'
  );
}

Alternatively, we can check for the existence of technical fields, but a non-empty mappings object is probably good enough for now.

cc @tsg @jasonrhodes @spong @smith

@dgieselaar dgieselaar added the Theme: rac label obsolete label May 24, 2021
@botelastic botelastic bot added the needs-team Issues missing a team label label May 24, 2021
@tsg
Copy link
Contributor

tsg commented May 25, 2021

FYI also @banderror

@jasonrhodes
Copy link
Member

@tsg @spong is this something someone on the Security side can fix alongside already planned improvements to the registry / rule data tools, or do you want me to put someone on this? Either way works, just want to make sure it's covered.

@spong
Copy link
Member

spong commented May 26, 2021

@banderror should be able to address this as part of the follow-up convergence once #98353 is merged, so we should be good. If this ends up falling out of scope of that effort for some reason we can identify someone to ensure it still makes it 👍

@banderror
Copy link
Contributor

Yes, I can try to address this as part of the follow-up convergence. Might need some help from someone who's more familiar with Elasticsearch though, but we'll figure this out. Thanks for mentioning me here 👍

@banderror banderror self-assigned this May 27, 2021
@jportner jportner added the Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. label Jun 29, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@botelastic botelastic bot removed the needs-team Issues missing a team label label Jun 29, 2021
@banderror banderror added the Team:Detections and Resp Security Detection Response Team label Sep 8, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-detections-response (Team:Detections and Resp)

@banderror banderror added the Team:Detection Alerts Security Detection Alerts Area Team label Oct 11, 2021
@banderror banderror removed their assignment Oct 11, 2021
@banderror
Copy link
Contributor

Hey everyone, FYI ownership of this ticket and other tickets related to rule_registry (like #101016) now goes to the Detection Alerts area (Team:Detection Alerts label). Please ping @peluja1012 and @marshallmain if you have any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Detection Alerts Security Detection Alerts Area Team Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Theme: rac label obsolete
Projects
None yet
Development

No branches or pull requests

8 participants