-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Asset Manager] Creates baseline public asset client for use in public plugins #167191
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
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
15dfb34
Renamed AssetAccessor to AssetClient, fixed type bugs
jasonrhodes 364c3cb
Renamed file asset_accessor -> asset_client
jasonrhodes 63bdcee
Abstracts types to prepare for public browser client
jasonrhodes 0eac9df
Clarifying elasticsearch and saved objects clients
jasonrhodes 1826319
Baseline public assets client ready, with getHosts
jasonrhodes 9e07450
Exports instantiated client from plugin, not class
jasonrhodes bf2aa2c
Moves REST route paths to common for sharing with client
jasonrhodes 25a82d3
Adds unit tests for getHosts client method
jasonrhodes 28c71aa
Restructures docs for plugin
jasonrhodes 919fbad
Fixes linting issues
jasonrhodes 4769d5e
Updates tsconfig to add public directory
jasonrhodes f0f3b49
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine ff1c0ef
[CI] Auto-commit changed files from 'node scripts/build_plugin_list_d…
kibanamachine fc0efe8
More linting and type checking updates
jasonrhodes 9766ec7
Adding asset manager to size limit file
jasonrhodes 32d2173
Adds docs and includes fixes found by adding docs :)
jasonrhodes 735f394
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine 2738219
Fixes type errors after moving type to new file
jasonrhodes a56171a
Merge branch 'main' into create-asset-client
jasonrhodes 8da985d
Updates tests based on review feedback
jasonrhodes c1efc0a
Merging in upstream/main and fixes conflicts with metrics data client PR
jasonrhodes f1fc25e
Fixes public config for asset manager plugin
jasonrhodes 167f69c
Changes asset manager public logs to debug level
jasonrhodes e402d28
Fixes TS error after merge
jasonrhodes 97c88db
Fixes exposeToBrowser test to add newly-exposed alphaEnabled config
jasonrhodes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,13 @@ | ||
| # Asset Manager Plugin | ||
|
|
||
| This plugin provides access to the asset data stored in assets-\* indices, primarily | ||
| for inventory and topology purposes. | ||
| This plugin provides access to observed asset data, such as information about hosts, pods, containers, services, and more. | ||
|
|
||
| ## Documentation | ||
|
|
||
| See [docs for the provided APIs in the docs folder](./docs/index.md). | ||
| ### User Docs | ||
|
|
||
| ## Running Tests | ||
| For those interested in making use of the APIs provided by this plugin, see [our API docs](./docs/api.md). | ||
|
|
||
| There are integration tests for the endpoints implemented thus far as well as for | ||
| the sample data tests. There is also a small set of tests meant to ensure that the | ||
| plugin is not doing anything without the proper config value in place to enable | ||
| the plugin fully. For more on enabling the plugin, see [the docs page](./docs/index.md). | ||
| ### Developer Docs | ||
|
|
||
| The "not enabled" tests are run by default in CI. To run them manually, do the following: | ||
|
|
||
| ```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 | ||
| ``` | ||
|
|
||
| The "enabled" tests are NOT run by CI yet, to prevent blocking Kibana development for a | ||
| test failure in this alpha, tech preview plugin. They will be moved into the right place | ||
| to make them run for CI before the plugin is enabled by default. To run them manually: | ||
|
|
||
| ```shell | ||
| $ node scripts/functional_tests_server --config x-pack/test/api_integration/apis/asset_manager/config.ts | ||
| $ node scripts/functional_test_runner --config=x-pack/test/api_integration/apis/asset_manager/config.ts | ||
| ``` | ||
|
|
||
| ## Using Sample Data | ||
|
|
||
| This plugin comes with a full "working set" of sample asset documents, meant | ||
| to provide enough data in the correct schema format so that all of the API | ||
| endpoints return expected values. | ||
|
|
||
| To create the sample data, follow [the instructions in the REST API docs](./docs/index.md#sample-data). | ||
| For those working on this plugin directly and developing it, please see [our development docs](./docs/development.md). |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import { schema, TypeOf } from '@kbn/config-schema'; | ||
|
|
||
| export const INDEX_DEFAULTS = { | ||
| logs: 'filebeat-*,logs-*', | ||
| }; | ||
|
|
||
| export const configSchema = schema.object({ | ||
| alphaEnabled: schema.maybe(schema.boolean()), | ||
| // Designate where various types of data live. | ||
| // NOTE: this should be handled in a centralized way for observability, so | ||
| // that when a user configures these differently from the known defaults, | ||
| // that value is propagated everywhere. For now, we duplicate the value here. | ||
| sourceIndices: schema.object( | ||
| { | ||
| logs: schema.string({ defaultValue: INDEX_DEFAULTS.logs }), | ||
| }, | ||
| { defaultValue: INDEX_DEFAULTS } | ||
| ), | ||
| // Choose an explicit source for asset queries. | ||
| // NOTE: This will eventually need to be able to cleverly switch | ||
| // between these values based on the availability of data in the | ||
| // indices, and possibly for each asset kind/type value. | ||
| // For now, we set this explicitly. | ||
| lockedSource: schema.oneOf([schema.literal('assets'), schema.literal('signals')], { | ||
| defaultValue: 'signals', | ||
| }), | ||
| }); | ||
|
|
||
| export type AssetManagerConfig = TypeOf<typeof configSchema>; | ||
|
|
||
| /** | ||
| * The following map is passed to the server plugin setup under the | ||
| * exposeToBrowser: option, and controls which of the above config | ||
| * keys are allow-listed to be available in the browser config. | ||
| * | ||
| * NOTE: anything exposed here will be visible in the UI dev tools, | ||
| * and therefore MUST NOT be anything that is sensitive information! | ||
| */ | ||
| export const exposeToBrowserConfig = { | ||
| alphaEnabled: true, | ||
| } as const; | ||
|
|
||
| type ValidKeys = keyof { | ||
| [K in keyof typeof exposeToBrowserConfig as typeof exposeToBrowserConfig[K] extends true | ||
| ? K | ||
| : never]: true; | ||
| }; | ||
|
|
||
| export type AssetManagerPublicConfig = Pick<AssetManagerConfig, ValidKeys>; |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| export const ASSET_MANAGER_API_BASE = '/api/asset-manager'; | ||
|
|
||
| function base(path: string) { | ||
| return `${ASSET_MANAGER_API_BASE}${path}`; | ||
| } | ||
|
|
||
| export const GET_ASSETS = base('/assets'); | ||
| export const GET_RELATED_ASSETS = base('/assets/related'); | ||
| export const GET_ASSETS_DIFF = base('/assets/diff'); | ||
|
|
||
| export const GET_HOSTS = base('/assets/hosts'); |
This file contains hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| export interface GetHostsOptionsPublic { | ||
| from: string; | ||
| to: string; | ||
| } | ||
|
|
||
| export interface GetServicesOptionsPublic { | ||
| from: string; | ||
| to: string; | ||
| parent?: string; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.