diff --git a/x-pack/plugins/observability_solution/apm/common/entities/types.ts b/x-pack/plugins/observability_solution/apm/common/entities/types.ts index 43b5531d211a9..7399dc4796814 100644 --- a/x-pack/plugins/observability_solution/apm/common/entities/types.ts +++ b/x-pack/plugins/observability_solution/apm/common/entities/types.ts @@ -17,7 +17,7 @@ export interface EntityMetrics { latency: number | null; throughput: number | null; failedTransactionRate: number; - logRatePerMinute: number; + logRate: number; logErrorRate: number | null; } diff --git a/x-pack/plugins/observability_solution/apm/common/es_fields/entities.ts b/x-pack/plugins/observability_solution/apm/common/es_fields/entities.ts index 043d611d37ce5..9c94b77743574 100644 --- a/x-pack/plugins/observability_solution/apm/common/es_fields/entities.ts +++ b/x-pack/plugins/observability_solution/apm/common/es_fields/entities.ts @@ -9,4 +9,3 @@ export const LAST_SEEN = 'entity.lastSeenTimestamp'; export const FIRST_SEEN = 'entity.firstSeenTimestamp'; export const ENTITY = 'entity'; -export const ENTITY_ENVIRONMENT = 'entity.identityFields.service.environment'; diff --git a/x-pack/plugins/observability_solution/apm/public/components/app/entities/charts/log_rate_chart.tsx b/x-pack/plugins/observability_solution/apm/public/components/app/entities/charts/log_rate_chart.tsx index d8f3ebbf7f665..c46c55511dbf2 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/app/entities/charts/log_rate_chart.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/app/entities/charts/log_rate_chart.tsx @@ -92,7 +92,7 @@ export function LogRateChart({ height }: { height: number }) { description={ {i18n.translate( - 'xpack.apm.multiSignal.servicesTable.logRatePerMinute.tooltip.serviceNameLabel', + 'xpack.apm.multiSignal.servicesTable.logRate.tooltip.serviceNameLabel', { defaultMessage: 'service.name', } diff --git a/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/get_service_columns.tsx b/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/get_service_columns.tsx index 0fe647b2c5127..01350075c6bf6 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/get_service_columns.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/get_service_columns.tsx @@ -173,17 +173,17 @@ export function getServiceColumns({ }, }, { - field: ServiceInventoryFieldName.LogRatePerMinute, + field: ServiceInventoryFieldName.logRate, name: ( {i18n.translate( - 'xpack.apm.multiSignal.servicesTable.logRatePerMinute.tooltip.serviceNameLabel', + 'xpack.apm.multiSignal.servicesTable.logRate.tooltip.serviceNameLabel', { defaultMessage: 'service.name', } @@ -215,7 +215,7 @@ export function getServiceColumns({ isLoading={false} color={currentPeriodColor} series={timeseriesData?.currentPeriod?.logRate[serviceName] ?? []} - valueLabel={asDecimalOrInteger(metrics.logRatePerMinute)} + valueLabel={asDecimalOrInteger(metrics.logRate)} hideSeries={!showWhenSmallOrGreaterThanLarge} /> ); diff --git a/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/multi_signal_services_table.tsx b/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/multi_signal_services_table.tsx index 5320fef8f22db..12980917d82c0 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/multi_signal_services_table.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/multi_signal_services_table.tsx @@ -26,7 +26,7 @@ export enum ServiceInventoryFieldName { Throughput = 'metrics.throughput', Latency = 'metrics.latency', FailedTransactionRate = 'metrics.failedTransactionRate', - LogRatePerMinute = 'metrics.logRatePerMinute', + logRate = 'metrics.logRate', LogErrorRate = 'metrics.logErrorRate', } diff --git a/x-pack/plugins/observability_solution/apm/server/routes/entities/get_entities.ts b/x-pack/plugins/observability_solution/apm/server/routes/entities/get_entities.ts index b129a544d9fe3..3fd32c9b07a81 100644 --- a/x-pack/plugins/observability_solution/apm/server/routes/entities/get_entities.ts +++ b/x-pack/plugins/observability_solution/apm/server/routes/entities/get_entities.ts @@ -6,13 +6,13 @@ */ import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import { kqlQuery } from '@kbn/observability-plugin/server'; -import { AGENT_NAME, DATA_STEAM_TYPE } from '../../../common/es_fields/apm'; import { - ENTITY_ENVIRONMENT, - FIRST_SEEN, - LAST_SEEN, - ENTITY, -} from '../../../common/es_fields/entities'; + AGENT_NAME, + DATA_STEAM_TYPE, + SERVICE_ENVIRONMENT, + SERVICE_NAME, +} from '../../../common/es_fields/apm'; +import { FIRST_SEEN, LAST_SEEN, ENTITY } from '../../../common/es_fields/entities'; import { environmentQuery } from '../../../common/utils/environment_query'; import { EntitiesESClient } from '../../lib/helpers/create_es_client/create_assets_es_client/create_assets_es_clients'; import { EntitiesRaw, ServiceEntities } from './types'; @@ -56,12 +56,12 @@ export async function getEntities({ body: { size, track_total_hits: false, - _source: [AGENT_NAME, ENTITY, DATA_STEAM_TYPE], + _source: [AGENT_NAME, ENTITY, DATA_STEAM_TYPE, SERVICE_NAME, SERVICE_ENVIRONMENT], query: { bool: { filter: [ ...kqlQuery(kuery), - ...environmentQuery(environment, ENTITY_ENVIRONMENT), + ...environmentQuery(environment, SERVICE_ENVIRONMENT), ...entitiesRangeQuery(start, end), ], }, @@ -72,7 +72,10 @@ export async function getEntities({ return entities.map((entity): ServiceEntities => { return { - serviceName: entity.entity.identityFields.service.name, + serviceName: entity.service.name, + environment: Array.isArray(entity.service?.environment) // TODO fix this in the EEM + ? entity.service.environment[0] + : entity.service.environment, agentName: entity.agent.name[0], signalTypes: entity.data_stream.type, entity: entity.entity, diff --git a/x-pack/plugins/observability_solution/apm/server/routes/entities/types.ts b/x-pack/plugins/observability_solution/apm/server/routes/entities/types.ts index f55be3bb7ffb3..b5279e053cfd0 100644 --- a/x-pack/plugins/observability_solution/apm/server/routes/entities/types.ts +++ b/x-pack/plugins/observability_solution/apm/server/routes/entities/types.ts @@ -10,12 +10,7 @@ import { SignalTypes, EntityMetrics } from '../../../common/entities/types'; export interface Entity { id: string; latestTimestamp: string; - identityFields: { - service: { - name: string; - environment?: string | null; - }; - }; + identityFields: string[]; metrics: EntityMetrics; } @@ -27,6 +22,7 @@ export interface TraceMetrics { export interface ServiceEntities { serviceName: string; + environment?: string; agentName: AgentName; signalTypes: string[]; entity: Entity; @@ -39,6 +35,10 @@ export interface EntitiesRaw { data_stream: { type: string[]; }; + service: { + name: string; + environment: string; + }; entity: Entity; } diff --git a/x-pack/plugins/observability_solution/apm/server/routes/entities/utils/calculate_avg_metrics.test.ts b/x-pack/plugins/observability_solution/apm/server/routes/entities/utils/calculate_avg_metrics.test.ts index 14a156aef3663..41d6e8e8b0979 100644 --- a/x-pack/plugins/observability_solution/apm/server/routes/entities/utils/calculate_avg_metrics.test.ts +++ b/x-pack/plugins/observability_solution/apm/server/routes/entities/utils/calculate_avg_metrics.test.ts @@ -22,14 +22,14 @@ describe('calculateAverageMetrics', () => { failedTransactionRate: 5, latency: 5, logErrorRate: 5, - logRatePerMinute: 5, + logRate: 5, throughput: 5, }, { failedTransactionRate: 10, latency: 10, logErrorRate: 10, - logRatePerMinute: 10, + logRate: 10, throughput: 10, }, ], @@ -45,14 +45,14 @@ describe('calculateAverageMetrics', () => { failedTransactionRate: 15, latency: 15, logErrorRate: 15, - logRatePerMinute: 15, + logRate: 15, throughput: 15, }, { failedTransactionRate: 5, latency: 5, logErrorRate: 5, - logRatePerMinute: 5, + logRate: 5, throughput: 5, }, ], @@ -72,7 +72,7 @@ describe('calculateAverageMetrics', () => { failedTransactionRate: 7.5, latency: 7.5, logErrorRate: 7.5, - logRatePerMinute: 7.5, + logRate: 7.5, throughput: 7.5, }, serviceName: 'service-1', @@ -86,7 +86,7 @@ describe('calculateAverageMetrics', () => { failedTransactionRate: 10, latency: 10, logErrorRate: 10, - logRatePerMinute: 10, + logRate: 10, throughput: 10, }, serviceName: 'service-2', @@ -105,14 +105,14 @@ describe('calculateAverageMetrics', () => { failedTransactionRate: 5, latency: null, logErrorRate: 5, - logRatePerMinute: 5, + logRate: 5, throughput: 5, }, { failedTransactionRate: 10, latency: null, logErrorRate: 10, - logRatePerMinute: 10, + logRate: 10, throughput: 10, }, ], @@ -131,7 +131,7 @@ describe('calculateAverageMetrics', () => { metrics: { failedTransactionRate: 7.5, logErrorRate: 7.5, - logRatePerMinute: 7.5, + logRate: 7.5, throughput: 7.5, }, serviceName: 'service-1', @@ -147,14 +147,14 @@ describe('mergeMetrics', () => { failedTransactionRate: 5, latency: 5, logErrorRate: 5, - logRatePerMinute: 5, + logRate: 5, throughput: 5, }, { failedTransactionRate: 10, latency: 10, logErrorRate: 10, - logRatePerMinute: 10, + logRate: 10, throughput: 10, }, ]; @@ -165,7 +165,7 @@ describe('mergeMetrics', () => { failedTransactionRate: [5, 10], latency: [5, 10], logErrorRate: [5, 10], - logRatePerMinute: [5, 10], + logRate: [5, 10], throughput: [5, 10], }); }); diff --git a/x-pack/plugins/observability_solution/apm/server/routes/entities/utils/merge_entities.test.ts b/x-pack/plugins/observability_solution/apm/server/routes/entities/utils/merge_entities.test.ts index 88566aa1d379c..544513fd501d2 100644 --- a/x-pack/plugins/observability_solution/apm/server/routes/entities/utils/merge_entities.test.ts +++ b/x-pack/plugins/observability_solution/apm/server/routes/entities/utils/merge_entities.test.ts @@ -13,18 +13,19 @@ describe('mergeEntities', () => { const entities = [ { serviceName: 'service-1', + environment: 'test', agentName: 'nodejs' as AgentName as AgentName, signalTypes: ['metrics', 'logs'], entity: { latestTimestamp: '2024-06-05T10:34:40.810Z', metrics: { - logRatePerMinute: 1, + logRate: 1, logErrorRate: null, throughput: 0, failedTransactionRate: 0.3333333333333333, latency: 10, }, - identityFields: { service: { name: 'service-1', environment: 'test' } }, + identityFields: ['service.name', 'service.environment'], id: 'service-1:test', }, }, @@ -41,7 +42,7 @@ describe('mergeEntities', () => { failedTransactionRate: 0.3333333333333333, latency: 10, logErrorRate: null, - logRatePerMinute: 1, + logRate: 1, throughput: 0, }, ], @@ -54,70 +55,73 @@ describe('mergeEntities', () => { const entities = [ { serviceName: 'service-1', + environment: 'env-service-1', agentName: 'nodejs' as AgentName as AgentName, signalTypes: ['foo'], entity: { latestTimestamp: '2024-06-05T10:34:40.810Z', metrics: { - logRatePerMinute: 1, + logRate: 1, logErrorRate: null, throughput: 0, failedTransactionRate: 0.3333333333333333, latency: 10, }, - - identityFields: { service: { name: 'apm-only-1', environment: 'env-service-1' } }, + identityFields: ['service.name', 'service.environment'], id: 'service-1:env-service-1', }, }, { serviceName: 'service-1', + environment: 'env-service-2', agentName: 'nodejs' as AgentName as AgentName, signalTypes: ['bar'], entity: { latestTimestamp: '2024-03-05T10:34:40.810Z', metrics: { - logRatePerMinute: 10, + logRate: 10, logErrorRate: 10, throughput: 10, failedTransactionRate: 10, latency: 10, }, - identityFields: { service: { name: 'service-1', environment: 'env-service-2' } }, + identityFields: ['service.name', 'service.environment'], id: 'apm-only-1:synthtrace-env-2', }, }, { serviceName: 'service-2', + environment: 'env-service-3', agentName: 'java' as AgentName, signalTypes: ['baz'], entity: { latestTimestamp: '2024-06-05T10:34:40.810Z', metrics: { - logRatePerMinute: 15, + logRate: 15, logErrorRate: 15, throughput: 15, failedTransactionRate: 15, latency: 15, }, - identityFields: { service: { name: 'service-2', environment: 'env-service-3' } }, + identityFields: ['service.name', 'service.environment'], id: 'service-2:env-service-3', }, }, { serviceName: 'service-2', + environment: 'env-service-4', agentName: 'java' as AgentName, signalTypes: ['baz'], entity: { latestTimestamp: '2024-06-05T10:34:40.810Z', metrics: { - logRatePerMinute: 5, + logRate: 5, logErrorRate: 5, throughput: 5, failedTransactionRate: 5, latency: 5, }, - identityFields: { service: { name: 'service-2', environment: 'env-service-4' } }, + identityFields: ['service.name', 'service.environment'], id: 'service-2:env-service-3', }, }, @@ -135,14 +139,14 @@ describe('mergeEntities', () => { failedTransactionRate: 0.3333333333333333, latency: 10, logErrorRate: null, - logRatePerMinute: 1, + logRate: 1, throughput: 0, }, { failedTransactionRate: 10, latency: 10, logErrorRate: 10, - logRatePerMinute: 10, + logRate: 10, throughput: 10, }, ], @@ -158,14 +162,14 @@ describe('mergeEntities', () => { failedTransactionRate: 15, latency: 15, logErrorRate: 15, - logRatePerMinute: 15, + logRate: 15, throughput: 15, }, { failedTransactionRate: 5, latency: 5, logErrorRate: 5, - logRatePerMinute: 5, + logRate: 5, throughput: 5, }, ], @@ -177,52 +181,55 @@ describe('mergeEntities', () => { const entities = [ { serviceName: 'service-1', + environment: 'test', agentName: 'nodejs' as AgentName, signalTypes: ['metrics', 'logs'], entity: { latestTimestamp: '2024-06-05T10:34:40.810Z', metrics: { - logRatePerMinute: 5, + logRate: 5, logErrorRate: 5, throughput: 5, failedTransactionRate: 5, latency: 5, }, - identityFields: { service: { name: 'service-1', environment: 'test' } }, + identityFields: ['service.name', 'service.environment'], id: 'service-1:test', }, }, { serviceName: 'service-1', + environment: 'test', agentName: 'nodejs' as AgentName, signalTypes: ['metrics', 'logs'], entity: { latestTimestamp: '2024-06-05T10:34:40.810Z', metrics: { - logRatePerMinute: 10, + logRate: 10, logErrorRate: 10, throughput: 10, failedTransactionRate: 0.3333333333333333, latency: 10, }, - identityFields: { service: { name: 'service-1', environment: 'test' } }, + identityFields: ['service.name', 'service.environment'], id: 'service-1:test', }, }, { serviceName: 'service-1', + environment: 'prod', agentName: 'nodejs' as AgentName, signalTypes: ['foo'], entity: { latestTimestamp: '2024-23-05T10:34:40.810Z', metrics: { - logRatePerMinute: 0.333, + logRate: 0.333, logErrorRate: 0.333, throughput: 0.333, failedTransactionRate: 0.333, latency: 0.333, }, - identityFields: { service: { name: 'service-1', environment: 'prod' } }, + identityFields: ['service.name', 'service.environment'], id: 'service-1:prod', }, }, @@ -239,21 +246,21 @@ describe('mergeEntities', () => { failedTransactionRate: 5, latency: 5, logErrorRate: 5, - logRatePerMinute: 5, + logRate: 5, throughput: 5, }, { failedTransactionRate: 0.3333333333333333, latency: 10, logErrorRate: 10, - logRatePerMinute: 10, + logRate: 10, throughput: 10, }, { failedTransactionRate: 0.333, latency: 0.333, logErrorRate: 0.333, - logRatePerMinute: 0.333, + logRate: 0.333, throughput: 0.333, }, ], @@ -265,18 +272,19 @@ describe('mergeEntities', () => { const entity = [ { serviceName: 'service-1', + environment: undefined, agentName: 'nodejs' as AgentName, signalTypes: [], entity: { latestTimestamp: '2024-06-05T10:34:40.810Z', metrics: { - logRatePerMinute: 1, + logRate: 1, logErrorRate: null, throughput: 0, failedTransactionRate: 0.3333333333333333, latency: 10, }, - identityFields: { service: { name: 'service-1', environment: null } }, + identityFields: ['service.name'], id: 'service-1:test', }, }, @@ -293,7 +301,7 @@ describe('mergeEntities', () => { failedTransactionRate: 0.3333333333333333, latency: 10, logErrorRate: null, - logRatePerMinute: 1, + logRate: 1, throughput: 0, }, ], @@ -309,13 +317,13 @@ describe('mergeEntities', () => { entity: { latestTimestamp: '2024-06-05T10:34:40.810Z', metrics: { - logRatePerMinute: 1, + logRate: 1, logErrorRate: null, throughput: 0, failedTransactionRate: 0.3333333333333333, latency: 10, }, - identityFields: { service: { name: 'service-1', environment: null } }, + identityFields: ['service.name'], id: 'service-1:test', }, }, @@ -326,13 +334,13 @@ describe('mergeEntities', () => { entity: { latestTimestamp: '2024-06-05T10:34:40.810Z', metrics: { - logRatePerMinute: 1, + logRate: 1, logErrorRate: null, throughput: 0, failedTransactionRate: 0.3333333333333333, latency: 10, }, - identityFields: { service: { name: 'service-1', environment: null } }, + identityFields: ['service.name'], id: 'service-1:test', }, }, @@ -349,11 +357,11 @@ describe('mergeEntities', () => { failedTransactionRate: 0.3333333333333333, latency: 10, logErrorRate: null, - logRatePerMinute: 1, + logRate: 1, throughput: 0, }, { - logRatePerMinute: 1, + logRate: 1, logErrorRate: null, throughput: 0, failedTransactionRate: 0.3333333333333333, @@ -374,13 +382,13 @@ describe('mergeEntities', () => { entity: { latestTimestamp: '2024-06-05T10:34:40.810Z', metrics: { - logRatePerMinute: 1, + logRate: 1, logErrorRate: null, throughput: 0, failedTransactionRate: 0.3333333333333333, latency: 10, }, - identityFields: { service: { name: 'service-1' } }, + identityFields: ['service.name'], id: 'service-1:test', }, }, @@ -397,7 +405,7 @@ describe('mergeEntities', () => { failedTransactionRate: 0.3333333333333333, latency: 10, logErrorRate: null, - logRatePerMinute: 1, + logRate: 1, throughput: 0, }, ], @@ -413,13 +421,13 @@ describe('mergeEntities', () => { entity: { latestTimestamp: '2024-06-05T10:34:40.810Z', metrics: { - logRatePerMinute: 1, + logRate: 1, logErrorRate: null, throughput: 0, failedTransactionRate: 0.3333333333333333, latency: 10, }, - identityFields: { service: { name: 'service-1' } }, + identityFields: ['service.name'], id: 'service-1:test', }, }, @@ -430,13 +438,13 @@ describe('mergeEntities', () => { entity: { latestTimestamp: '2024-06-05T10:34:40.810Z', metrics: { - logRatePerMinute: 1, + logRate: 1, logErrorRate: null, throughput: 0, failedTransactionRate: 0.3333333333333333, latency: 10, }, - identityFields: { service: { name: 'service-1' } }, + identityFields: ['service.name'], id: 'service-1:test', }, }, @@ -453,11 +461,11 @@ describe('mergeEntities', () => { failedTransactionRate: 0.3333333333333333, latency: 10, logErrorRate: null, - logRatePerMinute: 1, + logRate: 1, throughput: 0, }, { - logRatePerMinute: 1, + logRate: 1, logErrorRate: null, throughput: 0, failedTransactionRate: 0.3333333333333333, diff --git a/x-pack/plugins/observability_solution/apm/server/routes/entities/utils/merge_entities.ts b/x-pack/plugins/observability_solution/apm/server/routes/entities/utils/merge_entities.ts index dd32a57776192..7dd8bfdace7bf 100644 --- a/x-pack/plugins/observability_solution/apm/server/routes/entities/utils/merge_entities.ts +++ b/x-pack/plugins/observability_solution/apm/server/routes/entities/utils/merge_entities.ts @@ -33,7 +33,7 @@ function mergeFunc(entity: ServiceEntities, existingEntity?: MergedServiceEntiti serviceName: entity.serviceName, agentName: entity.agentName, signalTypes: entity.signalTypes, - environments: compact([entity.entity.identityFields.service?.environment]), + environments: compact([entity?.environment]), latestTimestamp: entity.entity.latestTimestamp, metrics: [entity.entity.metrics], }; @@ -42,9 +42,7 @@ function mergeFunc(entity: ServiceEntities, existingEntity?: MergedServiceEntiti serviceName: entity.serviceName, agentName: entity.agentName, signalTypes: uniq(compact([...(existingEntity?.signalTypes ?? []), ...entity.signalTypes])), - environments: uniq( - compact([...existingEntity?.environments, entity.entity.identityFields?.service?.environment]) - ), + environments: uniq(compact([...existingEntity?.environments, entity?.environment])), latestTimestamp: entity.entity.latestTimestamp, metrics: [...existingEntity?.metrics, entity.entity.metrics], };