Skip to content
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

[Inventory][ECO] Return metadata values #195204

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
*/
import { ENTITY_LATEST, entitiesAliasPattern } from '@kbn/entities-schema';
import {
CONTAINER_ID,
HOST_NAME,
AGENT_NAME,
CLOUD_PROVIDER,
CONTAINER_ID,
ENTITY_DEFINITION_ID,
ENTITY_DISPLAY_NAME,
ENTITY_ID,
ENTITY_IDENTITY_FIELDS,
ENTITY_LAST_SEEN,
ENTITY_TYPE,
HOST_NAME,
SERVICE_ENVIRONMENT,
SERVICE_NAME,
} from '@kbn/observability-shared-plugin/common';
Expand Down Expand Up @@ -77,6 +78,7 @@ interface BaseEntity {
[ENTITY_TYPE]: EntityType;
[ENTITY_DISPLAY_NAME]: string;
[ENTITY_DEFINITION_ID]: string;
[ENTITY_IDENTITY_FIELDS]: string[];
}

/**
Expand All @@ -85,7 +87,7 @@ interface BaseEntity {
interface ServiceEntity extends BaseEntity {
[ENTITY_TYPE]: 'service';
[SERVICE_NAME]: string;
[SERVICE_ENVIRONMENT]?: string | null;
[SERVICE_ENVIRONMENT]?: string | string[] | null;
[AGENT_NAME]: string | string[] | null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
* 2.0.
*/

import { EuiLink, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import React, { useCallback } from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiLink } from '@elastic/eui';
import {
AssetDetailsLocatorParams,
ASSET_DETAILS_LOCATOR_ID,
ServiceOverviewParams,
ENTITY_TYPE,
AssetDetailsLocatorParams,
ENTITY_DISPLAY_NAME,
ENTITY_IDENTITY_FIELDS,
ENTITY_TYPE,
SERVICE_ENVIRONMENT,
ServiceOverviewParams,
} from '@kbn/observability-shared-plugin/common';
import React, { useCallback } from 'react';
import { Entity } from '../../../../common/entities';
import { useKibana } from '../../../hooks/use_kibana';
import { EntityIcon } from '../../entity_icon';
import { Entity } from '../../../../common/entities';
import { parseServiceParams } from '../../../utils/parse_service_params';

interface EntityNameProps {
entity: Entity;
Expand All @@ -34,23 +35,23 @@ export function EntityName({ entity }: EntityNameProps) {

const getEntityRedirectUrl = useCallback(() => {
const type = entity[ENTITY_TYPE];
// For service, host and container type there is only one identity field
const identityField = entity[ENTITY_IDENTITY_FIELDS][0];

// Any unrecognised types will always return undefined
switch (type) {
case 'host':
case 'container':
return assetDetailsLocator?.getRedirectUrl({
assetId: entity[ENTITY_DISPLAY_NAME],
assetId: identityField,
assetType: type,
});

case 'service':
// For services, the format of the display name is `service.name:service.environment`.
// We just want the first part of the name for the locator.
// TODO: Replace this with a better approach for handling service names. See https:/elastic/kibana/issues/194131
return serviceOverviewLocator?.getRedirectUrl(
parseServiceParams(entity[ENTITY_DISPLAY_NAME])
);
return serviceOverviewLocator?.getRedirectUrl({
serviceName: identityField,
environment: [entity[SERVICE_ENVIRONMENT] || undefined].flat()[0],
});
}
}, [entity, assetDetailsLocator, serviceOverviewLocator]);

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,5 @@ export const ENTITY_LAST_SEEN = 'entity.lastSeenTimestamp';
export const ENTITY_FIRST_SEEN = 'entity.firstSeenTimestamp';
export const ENTITY_DISPLAY_NAME = 'entity.displayName';
export const ENTITY_DEFINITION_ID = 'entity.definitionId';
export const ENTITY_IDENTITY_FIELDS = 'entity.identityFields';
export const SOURCE_DATA_STREAM_TYPE = 'source_data_stream.type';
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export {
ENTITY_LAST_SEEN,
ENTITY_TYPE,
SOURCE_DATA_STREAM_TYPE,
ENTITY_IDENTITY_FIELDS,
} from './field_names/elasticsearch';

export {
Expand Down