## Summary Resolves https://github.com/elastic/kibana/issues/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 <42973632+kibanamachine@users.noreply.github.com> |
||
---|---|---|
.. | ||
examples | ||
linters | ||
output | ||
overlays | ||
scripts | ||
bundle.json | ||
bundle.serverless.json | ||
kibana.info.serverless.yaml | ||
kibana.info.yaml | ||
makefile | ||
package-lock.json | ||
package.json | ||
README.md |
Kibana API reference documentation
Documentation about our OpenAPI bundling workflow and configuration. See Kibana's hosted stateful and serverless docs.
Workflow
The final goal of this workflow is to produce an OpenAPI bundle containing all Kibana's public APIs.
Step 0
OAS from Kibana's APIs are continuously extracted and captured in bundle.json
and bundle.serverless.json
as fully formed OAS documentation. See node scripts/capture_oas_snapshot --help
for more info.
These bundles form the basis of our OpenAPI bundles to which we append and layer extra information before publishing.
Step 1
Append pre-existing bundles not extracted from code using kbn-openapi-bundler
to produce the final resulting bundles.
To add more files into the final bundle, edit the appropriate oas_docs/scripts/merge*.js
files.
Step 2
Apply any final overalys to the document that might include examples or final tweaks (see the "Scripts" section for more details).
Scripts
The oas_docs/scripts
folder contains scripts that point to the source domain-specific OpenAPI bundles and specify additional parameters for producing the final output bundle. Currently, there are the following scripts:
-
merge_ess_oas.js
script produces production an output bundle for ESS -
merge_serverless_oas.js
script produces production an output bundle for Serverless
Output Kibana OpenAPI bundles
The oas_docs/output
folder contains the final resulting Kibana OpenAPI bundles
kibana.yaml
production ready ESS OpenAPI bundlekibana.serverless.yaml
production ready Serverless OpenAPI bundle
Bundling commands
Besides the scripts in the oas_docs/scripts
folder, there is an oas_docs/makefile
to simplify the workflow. Use make help
to see available commands.