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

[8.7] [Fleet] Fix agent policy selection and creation when there are a large number of agent policies ( > 1k) (#151119) #151131

Merged
merged 1 commit into from
Feb 14, 2023

Conversation

kibanamachine
Copy link
Contributor

Backport

This will backport the following commits from main to 8.7:

Questions ?

Please refer to the Backport tool documentation

…e number of agent policies ( > 1k) (elastic#151119)

## Summary

Closes elastic#150605

When adding an integration, the agent policy selector (create or select
existing agent policy) does not work if there are too many agent
policies.

In an environment with a large number of agent policies (e.g 1000+) the
following API request times out or takes 30 - 60 seconds to respond:

```
http://localhost:5601/mark/api/fleet/agent_policies?page=1&perPage=10000&sortField=name&sortOrder=asc&full=true
```

That is because for each agent policy we get the saved object twice, get
ALL package policies, and count the agents, so for 1000 agents we fun
4000 queries using `pmap` in some places.

this PR changes it so that we do not get the agent count or `full` agent
policy for every agent policy when populating the agent policy select,
instead we only get the selected agent policy.

This has meant that I have to separately query package policies in order
to do the limited packages and APM output checks, but the component now
loads instantly on an environment with 3k agent policies.

Key changes:

- add `noAgentCount` query param to agent policies API, to not count the
agents for all agent policies
- populate `agents` in the get one agent policy API, this was an
inconsistency in our agent policy API
- when selecting an existing agent policy, only get the full agent
policy for the selected agent policy

###Testing

No behaviour should have changed for the agent policy select, some niche
behaviour of the selector:

- if adding the APM integration, any agent policy with a logstash output
configured for integration data should be disabled
- if adding a limited integration e.g apm or defend, any agent policy
already containing that integration should be disabled

<img width="1052" alt="Screenshot 2023-02-14 at 10 45 03"
src="https://user-images.githubusercontent.com/3315046/218745430-4a8f0ded-1e0b-4319-bc2c-cc5253b4cdd2.png">

(cherry picked from commit 9a52ef4)
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
fleet 926.8KB 927.0KB +288.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
fleet 123.7KB 123.8KB +38.0B

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @hop-dev

@kibanamachine kibanamachine merged commit c449b2a into elastic:8.7 Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Team:Fleet Team label for Observability Data Collection Fleet team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants