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][Rule Registry] Make endpoints for updating alerts consistent #111162

Closed
Tracked by #101016
banderror opened this issue Sep 3, 2021 · 4 comments
Closed
Tracked by #101016

[RAC][Rule Registry] Make endpoints for updating alerts consistent #111162

banderror opened this issue Sep 3, 2021 · 4 comments
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

@banderror
Copy link
Contributor

banderror commented Sep 3, 2021

Parent ticket: #101016

Summary

The single update API endpoint (x-pack/plugins/rule_registry/server/routes/update_alert_by_id.ts) accepts a single index parameter which must be the concrete index name of the alert document being updated. The call might fail in certain cases if the corresponding alias is specified.

The bulk update API endpoint (x-pack/plugins/rule_registry/server/routes/bulk_update_alerts.ts) accepts a single index parameter and an array of alert ids. This is not convenient if you have a list of alerts stored in different concrete indices, and you want to specify the concrete indices and the ids when calling this endpoint. This can be properly implemented on the client side, by it will lead to a few calls instead of 1.

Possible solutions

Ideal solution would be:

  • Make sure both endpoints can reliably work across concrete indices, i.e. a client can safely specify index alias when calling any of the two endpoints. For example, document updates should be done via esClient.updateByQuery like here. The rest of the logic should also work well with aliases.
  • In this case, both endpoints could have a single index parameter.
  • We need to make sure that alert document ids are unique across concrete indices

Another solution could be:

  • Make sure both endpoints require concrete indices to be specified.
  • Make it obvious (e.g. rename the parameters) and write docs and comments in the code describing what is required and why.
  • The bulk update endpoint would probably need to accept an array of index-to-list-of-ids kind of data structure.

Also, if the ideal solution is possible, we could evaluate the possibility of (and need for) providing a registration context (observability.logs, security) instead of the corresponding full alias (.alerts-observability.logs.alerts, .alerts-security.alerts). RuleDataService exposes a method that could be used to find the alias:

  /**
   * Looks up the index information associated with the given registration context and dataset.
   */
  public findIndexByName(registrationContext: string, dataset: Dataset): IndexInfo | null {
    const baseName = this.getResourceName(`${registrationContext}.${dataset}`);
    return this.indicesByBaseName.get(baseName) ?? null;
  }
@banderror banderror added Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Theme: rac label obsolete labels Sep 3, 2021
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

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

@banderror
Copy link
Contributor Author

cc @weltenwort

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

Hey everyone, I removed this ticket from the backlog of the Detection Rules area.

We (@elastic/security-detections-response-rules) are not the owners anymore (however feel free to still ping us if you have any tech questions about the ticket). 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

3 participants