forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UII] Support
searchAfter
and PIT (point-in-time) parameters for ge…
…t agents list API (elastic#213486) ## Summary Resolves elastic#206924. This PR adds the following query parameters to the agent list API (`GET /api/fleet/agents`) in order to enable fetching beyond the first 10,000 hits: ``` searchAfter?: string; openPit?: boolean; pitId?: string; pitKeepAlive?: string; ``` The list agent API response can now include the following properties ``` // the PIT ID used pit?: string; // stringified version of the last agent's `sort` field, // can be passed as `searchAfter` in the next request nextSearchAfter? string; ``` * `searchAfter` can be used with or without a `pitId`. If using `searchAfter`, `page` parameter is not accepted. * `searchAfter` expects a stringified array. (Reviewers: I couldn't get the Kibana request schema to accept a multi-part query param and convert it to an array... I think this would be better, please let me know if you know how to get that to work 🙏) * `pitKeepAlive` duration (i.e. `30s`, `1m`, etc) must be present when opening a PIT or retrieving results using a PIT ID. * These can be used with the existing `sortField` and `sortOrder` params. They default to `enrolled_at` and `desc` respectively. ### Example using only `searchAfter`: ``` # Retrieve the first 10k hits curl -X GET 'http://<user>:<pass>@<kibana url>/api/fleet/agents?perPage=10000' # Grab the `nextSearchAfter` param from the response # Pass it to the new request to retrieve the next page of 10k hits curl -X GET 'http://<user>:<pass>@<kibana url>/api/fleet/agents?perPage=10000&searchAfter=<nextSearchAfter>' ``` ### Example using `searchAfter` with point-in-time parameters: ``` # Retrieve the first 10k hits and open a PIT curl -X GET 'http://<user>:<pass>@<kibana url>/api/fleet/agents?perPage=10000&openPit=true&pitKeepAlive=5m' # Grab the `pit` ID from the response # Grab the `nextSearchAfter` param from the response # Pass both to the new request to retrieve the next page of 10k hits curl -X GET 'http://<user>:<pass>@<kibana url>/api/fleet/agents?perPage=10000&searchAfter=<nextSearchAfter>&pitId=<pit id>&pitKeepAlive=5m' ``` ## Testing I recommend using `scripts/create_agents` to generate bulk agents and testing the above requests. You can generate new agents between PIT requests to test that using a PIT ID retains the original state. (An API functional test was added for this) Note: you may need to add `&showInactive=true` to all requests if your fake agents become inactive. TBD ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
c9969e7
commit 3f90203
Showing
15 changed files
with
355 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.