mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
# Backport This will backport the following commits from `main` to `8.x`: - [[Infra][ECO] Adding summary API (#194612)](https://github.com/elastic/kibana/pull/194612) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Cauê Marcondes","email":"55978943+cauemarcondes@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-10-04T08:46:54Z","message":"[Infra][ECO] Adding summary API (#194612)\n\ncloses https://github.com/elastic/kibana/issues/193701\r\n\r\nThis PR does a few things:\r\n- Adds a new API endpoint on infra to fetch an entity summary:\r\n`/api/infra/entities/{entityType}/{entityId}/summary`. It fetches the\r\nlatest EEM index filtering by entity.type(host | container) and\r\ndepending on the entity type host.name or container.id. And it returns\r\nthe following payload:\r\n```\r\n{\r\n \"sourceDataStreams\": [\r\n \"logs\",\r\n \"metrics\"\r\n ],\r\n \"entityId\": \"caues-mbp\",\r\n \"entityType\": \"host\"\r\n}\r\n```\r\n- Fix a problem on the `Service` entity definition removing the\r\n`datastream.type` and moving it to `source_data_stream.type` due to ECS\r\nconflicts.\r\n- Moves some common field definitions to **observability-shared**\r\nplugin, and updated APM and Inventory plugin.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"a91d00731ae732c3bb2d370651048d94dd8adc2b","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-infra_services","v8.16.0"],"title":"[Infra][ECO] Adding summary API","number":194612,"url":"https://github.com/elastic/kibana/pull/194612","mergeCommit":{"message":"[Infra][ECO] Adding summary API (#194612)\n\ncloses https://github.com/elastic/kibana/issues/193701\r\n\r\nThis PR does a few things:\r\n- Adds a new API endpoint on infra to fetch an entity summary:\r\n`/api/infra/entities/{entityType}/{entityId}/summary`. It fetches the\r\nlatest EEM index filtering by entity.type(host | container) and\r\ndepending on the entity type host.name or container.id. And it returns\r\nthe following payload:\r\n```\r\n{\r\n \"sourceDataStreams\": [\r\n \"logs\",\r\n \"metrics\"\r\n ],\r\n \"entityId\": \"caues-mbp\",\r\n \"entityType\": \"host\"\r\n}\r\n```\r\n- Fix a problem on the `Service` entity definition removing the\r\n`datastream.type` and moving it to `source_data_stream.type` due to ECS\r\nconflicts.\r\n- Moves some common field definitions to **observability-shared**\r\nplugin, and updated APM and Inventory plugin.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"a91d00731ae732c3bb2d370651048d94dd8adc2b"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/194612","number":194612,"mergeCommit":{"message":"[Infra][ECO] Adding summary API (#194612)\n\ncloses https://github.com/elastic/kibana/issues/193701\r\n\r\nThis PR does a few things:\r\n- Adds a new API endpoint on infra to fetch an entity summary:\r\n`/api/infra/entities/{entityType}/{entityId}/summary`. It fetches the\r\nlatest EEM index filtering by entity.type(host | container) and\r\ndepending on the entity type host.name or container.id. And it returns\r\nthe following payload:\r\n```\r\n{\r\n \"sourceDataStreams\": [\r\n \"logs\",\r\n \"metrics\"\r\n ],\r\n \"entityId\": \"caues-mbp\",\r\n \"entityType\": \"host\"\r\n}\r\n```\r\n- Fix a problem on the `Service` entity definition removing the\r\n`datastream.type` and moving it to `source_data_stream.type` due to ECS\r\nconflicts.\r\n- Moves some common field definitions to **observability-shared**\r\nplugin, and updated APM and Inventory plugin.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"a91d00731ae732c3bb2d370651048d94dd8adc2b"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Cauê Marcondes <55978943+cauemarcondes@users.noreply.github.com>
This commit is contained in:
parent
7e77855c4e
commit
d6f5f34dff
32 changed files with 250 additions and 83 deletions
|
@ -20,7 +20,7 @@ const serviceTransactionFilter = (additionalFilters: string[] = []) => {
|
|||
|
||||
export const builtInServicesFromLogsEntityDefinition: EntityDefinition =
|
||||
entityDefinitionSchema.parse({
|
||||
version: '0.2.0',
|
||||
version: '0.3.0',
|
||||
id: `${BUILT_IN_ID_PREFIX}services_from_ecs_data`,
|
||||
name: 'Services from ECS data',
|
||||
description:
|
||||
|
@ -46,8 +46,15 @@ export const builtInServicesFromLogsEntityDefinition: EntityDefinition =
|
|||
displayNameTemplate: '{{service.name}}',
|
||||
metadata: [
|
||||
{ source: '_index', destination: 'sourceIndex' },
|
||||
{
|
||||
source: 'data_stream.type',
|
||||
destination: 'source_data_stream.type',
|
||||
},
|
||||
{
|
||||
source: 'data_stream.dataset',
|
||||
destination: 'source_data_stream.dataset',
|
||||
},
|
||||
{ source: 'agent.name', aggregation: { type: 'terms', limit: 100 } },
|
||||
'data_stream.type',
|
||||
'service.environment',
|
||||
'service.name',
|
||||
'service.namespace',
|
||||
|
|
|
@ -31,6 +31,7 @@ export async function findEntityDefinitions({
|
|||
page = 1,
|
||||
perPage = 10,
|
||||
includeState = false,
|
||||
type,
|
||||
}: {
|
||||
soClient: SavedObjectsClientContract;
|
||||
esClient: ElasticsearchClient;
|
||||
|
@ -39,12 +40,14 @@ export async function findEntityDefinitions({
|
|||
page?: number;
|
||||
perPage?: number;
|
||||
includeState?: boolean;
|
||||
type?: string;
|
||||
}): Promise<EntityDefinition[] | EntityDefinitionWithState[]> {
|
||||
const filter = compact([
|
||||
typeof builtIn === 'boolean'
|
||||
? `${SO_ENTITY_DEFINITION_TYPE}.attributes.id:(${BUILT_IN_ID_PREFIX}*)`
|
||||
: undefined,
|
||||
id ? `${SO_ENTITY_DEFINITION_TYPE}.attributes.id:(${id})` : undefined,
|
||||
type ? `${SO_ENTITY_DEFINITION_TYPE}.attributes.type:(${type})` : undefined,
|
||||
]).join(' AND ');
|
||||
const response = await soClient.find<EntityDefinition>({
|
||||
type: SO_ENTITY_DEFINITION_TYPE,
|
||||
|
|
|
@ -75,11 +75,15 @@ export class EntityClient {
|
|||
page = 1,
|
||||
perPage = 10,
|
||||
includeState = false,
|
||||
type,
|
||||
builtIn,
|
||||
}: {
|
||||
id?: string;
|
||||
page?: number;
|
||||
perPage?: number;
|
||||
includeState?: boolean;
|
||||
type?: string;
|
||||
builtIn?: boolean;
|
||||
}) {
|
||||
const definitions = await findEntityDefinitions({
|
||||
esClient: this.options.esClient,
|
||||
|
@ -88,6 +92,8 @@ export class EntityClient {
|
|||
perPage,
|
||||
id,
|
||||
includeState,
|
||||
type,
|
||||
builtIn,
|
||||
});
|
||||
|
||||
return { definitions };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue