Skip to content

Commit

Permalink
[APM] Updated eem schema (elastic#188763)
Browse files Browse the repository at this point in the history
## Summary

closes: elastic#188761

### changes

- identityFields returns only the fields, query directly service name
and service environment from entity document (EEM
[change](elastic#187699))
- Rename `logRatePerMinute` to `logRate` (EEM
[change](elastic#187021))
  • Loading branch information
kpatticha authored Jul 22, 2024
1 parent aa6aa26 commit 7089f35
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface EntityMetrics {
latency: number | null;
throughput: number | null;
failedTransactionRate: number;
logRatePerMinute: number;
logRate: number;
logErrorRate: number | null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export function LogRateChart({ height }: { height: number }) {
description={
<FormattedMessage
defaultMessage="Rate of logs per minute observed for given {serviceName}."
id="xpack.apm.multiSignal.servicesTable.logRatePerMinute.tooltip.description"
id="xpack.apm.multiSignal.servicesTable.logRate.tooltip.description"
values={{
serviceName: (
<code
Expand All @@ -101,7 +101,7 @@ export function LogRateChart({ height }: { height: number }) {
`}
>
{i18n.translate(
'xpack.apm.multiSignal.servicesTable.logRatePerMinute.tooltip.serviceNameLabel',
'xpack.apm.multiSignal.servicesTable.logRate.tooltip.serviceNameLabel',
{
defaultMessage: 'service.name',
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,17 @@ export function getServiceColumns({
},
},
{
field: ServiceInventoryFieldName.LogRatePerMinute,
field: ServiceInventoryFieldName.logRate,
name: (
<ColumnHeader
label={i18n.translate('xpack.apm.multiSignal.servicesTable.logRatePerMinute', {
label={i18n.translate('xpack.apm.multiSignal.servicesTable.logRate', {
defaultMessage: 'Log rate (per min.)',
})}
formula={getMetricsFormula(ChartMetricType.LOG_RATE)}
toolTip={
<FormattedMessage
defaultMessage="Rate of logs per minute observed for given {serviceName}."
id="xpack.apm.multiSignal.servicesTable.logRatePerMinute.tooltip.description"
id="xpack.apm.multiSignal.servicesTable.logRate.tooltip.description"
values={{
serviceName: (
<code
Expand All @@ -192,7 +192,7 @@ export function getServiceColumns({
`}
>
{i18n.translate(
'xpack.apm.multiSignal.servicesTable.logRatePerMinute.tooltip.serviceNameLabel',
'xpack.apm.multiSignal.servicesTable.logRate.tooltip.serviceNameLabel',
{
defaultMessage: 'service.name',
}
Expand All @@ -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}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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),
],
},
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -27,6 +22,7 @@ export interface TraceMetrics {

export interface ServiceEntities {
serviceName: string;
environment?: string;
agentName: AgentName;
signalTypes: string[];
entity: Entity;
Expand All @@ -39,6 +35,10 @@ export interface EntitiesRaw {
data_stream: {
type: string[];
};
service: {
name: string;
environment: string;
};
entity: Entity;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
],
Expand All @@ -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,
},
],
Expand All @@ -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',
Expand All @@ -86,7 +86,7 @@ describe('calculateAverageMetrics', () => {
failedTransactionRate: 10,
latency: 10,
logErrorRate: 10,
logRatePerMinute: 10,
logRate: 10,
throughput: 10,
},
serviceName: 'service-2',
Expand All @@ -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,
},
],
Expand All @@ -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',
Expand All @@ -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,
},
];
Expand All @@ -165,7 +165,7 @@ describe('mergeMetrics', () => {
failedTransactionRate: [5, 10],
latency: [5, 10],
logErrorRate: [5, 10],
logRatePerMinute: [5, 10],
logRate: [5, 10],
throughput: [5, 10],
});
});
Expand Down
Loading

0 comments on commit 7089f35

Please sign in to comment.