-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ECO][Inventory v2] Ad hoc data view: Add get entities definition end…
…point using sources (#204026) Closes #202298 This PR changes the way we get the entity index patterns to v2. It creates an endpoint part of the inventory API which returns the index patterns by entity type. ## Testing ### Test the endpoint: - Open Dev tools and add ` GET kbn:/internal/inventory/entity/definitions/sources` - Response: ![image](https://github.com/user-attachments/assets/3346c36e-dbc2-4e56-9ed6-d3d3a8f7d1a5) ### Test in the UI - After the previous steps add some host data (oblt cluster / metricbeat) or use synthtrace (for example use `node scripts/synthtrace infra_hosts_with_apm_hosts --scenarioOpts.numInstances=10` or `node scripts/synthtrace logs_traces_hosts.ts`) - Go to Inventory and expand the host group - Click on the actions button for any host and click on the Discover link - The correct dataview should be selected based on the index patterns in the source definition The same can be done for other entity types - Test the search bar as well (the suggestions should be visible) and now we should have 1 request to get the sources (instead of doing it on click) https://github.com/user-attachments/assets/93b5ac6c-9d64-44e0-b26e-6133477e0840 <!--ONMERGE {"backportTargets":["8.x"]} ONMERGE--> --------- Co-authored-by: Carlos Crespo <[email protected]> Co-authored-by: Sergi Romeu <[email protected]> Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
902820e
commit ffccfdc
Showing
10 changed files
with
338 additions
and
74 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
28 changes: 28 additions & 0 deletions
28
...bservability/plugins/inventory/public/hooks/use_fetch_entity_definition_index_patterns.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* 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 { useInventoryAbortableAsync } from './use_inventory_abortable_async'; | ||
import { useKibana } from './use_kibana'; | ||
|
||
export const useFetchEntityDefinitionIndexPattern = () => { | ||
const { | ||
services: { inventoryAPIClient }, | ||
} = useKibana(); | ||
|
||
const { value = { definitionIndexPatterns: {} }, loading } = useInventoryAbortableAsync( | ||
({ signal }) => { | ||
return inventoryAPIClient.fetch('GET /internal/inventory/entity/definitions/sources', { | ||
signal, | ||
}); | ||
}, | ||
[inventoryAPIClient] | ||
); | ||
|
||
return { | ||
definitionIndexPatterns: value?.definitionIndexPatterns, | ||
isIndexPatternsLoading: loading, | ||
}; | ||
}; |
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.