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

[Ingest Manager] KQL in agent checkin performance issue #75646

Closed
nchaulet opened this issue Aug 21, 2020 · 2 comments
Closed

[Ingest Manager] KQL in agent checkin performance issue #75646

nchaulet opened this issue Aug 21, 2020 · 2 comments
Assignees
Labels
Team:Fleet Team label for Observability Data Collection Fleet team

Comments

@nchaulet
Copy link
Member

nchaulet commented Aug 21, 2020

Description

In the agent checkin we are doing a query to get AgentActions saved objects and this query use KQL. After some CPU profile (see screenshot below) it seems that is really inefficient as SO client parse the KQL query each time and this operation is CPU intensive.

The search query https://github.com/elastic/kibana/blob/master/x-pack/plugins/ingest_manager/server/services/agents/actions.ts/#L34

During a 20s, CPU profile of 2000 agents enrolled we passed 1.2 seconds for parsing KQL queries
Screen Shot 2020-08-21 at 9 06 02 AM

Potential solutions

Fix KQL perfomance

Can we make the saved object filter option faster? implement some caching? (we use dynamic KQL, so it could be hard to cache) @kobelb curious to have your thoughts on that.

Change our data model

Currently we rely on a property on the AgentAction, sent_at to know if is an action has been sent to the agent, we can change our data model, to add the actions to send to the agent saved object something like

Agent {
  "actions_to_send": ["action1:id", "action2id"]
}

and the checkin will be

  1. get the agent SO (this call is already done)
  2. if there is actions do a bulkGet to get this actions.

Warning: we can potentially have race conditions when adding/removing actions actions_to_send

@nchaulet nchaulet added the Team:Fleet Team label for Observability Data Collection Fleet team label Aug 21, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/ingest-management (Team:Ingest Management)

@jfsiii
Copy link
Contributor

jfsiii commented Aug 26, 2020

@nchaulet can you upload a .cpuprofile like shown in the description? It'd be great to capture the current state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Fleet Team label for Observability Data Collection Fleet team
Projects
None yet
Development

No branches or pull requests

3 participants