mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 10:23:14 -04:00
## Summary This plugin will contain the asset inventory and topology API in Kibana, giving Kibana projects access to inventory and topology data via an HTTP and/or JS API on the server and client. [Currently proposed API docs](https://github.com/elastic/o11y-topology-playground/tree/main/docs/api) will be moved to this repo as well, contained inside this plugin folder, as a part of this PR. ## Enabling the plugin This plugin is entirely in "technical preview" and because of this, must be specifically enabled via config for it to do anything besides being run by the core plugin framework. To enable the server API layer, as well as the index template management, put the following line in your kibana.yml file: ```yml xpack.assetManager.alphaEnabled: true ``` ## Running the API integration tests Run the functional test server with the asset manager config in place: ```shell $ node scripts/functional_tests_server --config x-pack/test/api_integration/apis/asset_manager/config.ts ``` Then run the functional test runner with the same config, to target just these tests: ```shell $ node scripts/functional_test_runner --config=x-pack/test/api_integration/apis/asset_manager/config. ts ``` _Note:_ The config file added in this folder enables the tech preview plugin ([see file here](https://github.com/elastic/kibana/pull/152456/files#diff-bc00de6c34c9bc131cfbdf3570c487fe9ee947e9a88a84c59d6b139b79d7708eR20)). ### Running the integration tests for verifying that the plugin is "disabled" by default There is a small set of tests that confirm that the endpoints return 404 and there is no index template installed if the config value is not set in the kibana.yml file. To run this suite, use the following config: ```shell $ node scripts/functional_tests_server --config x-pack/test/api_integration/apis/asset_manager/config_when_disabled.ts $ node scripts/functional_test_runner --config=x-pack/test/api_integration/apis/asset_manager/config_when_disabled. ts ``` ## Testing this PR with sample data There are some sample data mechanisms in place inside this PR to allow us to build out the endpoints. ### View sample docs ```http GET /api/asset-manager/assets/sample ``` This will return a list of the assets that are included if you elect to write assets. This is a good endpoint to use to find EAN (Elastic Asset Name) values that you may want to exclude from writing for a given time period, to simulate assets appearing/disappearing over time. ### Write sample docs ```http POST /api/asset-manager/assets/sample { "baseDateTime": "2023-02-28T12:00:00.000Z", "excludeEans": ["k8s.cluster:cluster-002"] } ``` This posts all of the sample asset documents to Elasticsearch using the `baseDateTime` value as the timestamp. Any valid string or number that is accepted by `new Date()` should work for `baseDateTime`. The `excludeEans` value is an array of EAN ("Elastic Asset Name") values that you don't want to write on this particular run. This way you can have assets appear (exclude them in the past, don't exclude them during a later run) or disappear (vice versa) and see how that shows up in other endpoints. **Note:** *Remember that when you curl a Kibana server API with a POST request, you must include a `kbn-xsrf` header with any string value you want.* ### Get asset docs from ES ```http GET /api/asset-manager/assets?type=k8s.cluster&from=now-10m ``` This is the primary "real" endpoint available right now. It should retrieve a list of assets based on the type/from/to/ean filter values you specify. Once you load the sample data, this endpoint should return results. ## Debug logging There are some extra debug logs for ES queries that are running in the code in this PR. To print those logs to the Kibana server console, run Kibana using `DEBUG_LOGGER=true` --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> |
||
---|---|---|
.. | ||
advanced | ||
architecture | ||
best-practices | ||
contributing | ||
getting-started | ||
images | ||
plugin | ||
index.asciidoc | ||
plugin-list.asciidoc | ||
telemetry.asciidoc |