Skip to content

Commit

Permalink
[APM] Remove host.name correlation (#150005)
Browse files Browse the repository at this point in the history
Closes #148788
  • Loading branch information
sorenlouv authored Feb 1, 2023
1 parent 6f3b29d commit 0575f43
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('service logs', () => {
);
});

it('filter by host names as fallback', () => {
it('does not filter by host names as fallback', () => {
expect(
getInfrastructureKQLFilter(
{
Expand All @@ -48,9 +48,7 @@ describe('service logs', () => {
},
serviceName
)
).toEqual(
'service.name: "opbeans-node" or (not service.name and (host.name: "baz" or host.name: "quz"))'
);
).toEqual('service.name: "opbeans-node"');
});
});
});
22 changes: 7 additions & 15 deletions x-pack/plugins/apm/public/components/app/service_logs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ import { useFetcher } from '../../../hooks/use_fetcher';
import { useApmServiceContext } from '../../../context/apm_service/use_apm_service_context';
import { APIReturnType } from '../../../services/rest/create_call_apm_api';

import {
CONTAINER_ID,
HOST_NAME,
SERVICE_NAME,
} from '../../../../common/es_fields/apm';
import { CONTAINER_ID, SERVICE_NAME } from '../../../../common/es_fields/apm';
import { useApmParams } from '../../../hooks/use_apm_params';
import { useTimeRange } from '../../../hooks/use_time_range';

Expand Down Expand Up @@ -70,16 +66,12 @@ export const getInfrastructureKQLFilter = (
| undefined,
serviceName: string
) => {
const containerIds = data?.containerIds ?? [];
const hostNames = data?.hostNames ?? [];
const containerIds: string[] = data?.containerIds ?? [];
const containerIdKql = containerIds
.map((id) => `${CONTAINER_ID}: "${id}"`)
.join(' or ');

const infraAttributes = containerIds.length
? containerIds.map((id) => `${CONTAINER_ID}: "${id}"`)
: hostNames.map((id) => `${HOST_NAME}: "${id}"`);

const infraAttributesJoined = infraAttributes.join(' or ');

return infraAttributes.length
? `${SERVICE_NAME}: "${serviceName}" or (not ${SERVICE_NAME} and (${infraAttributesJoined}))`
return containerIds.length
? `${SERVICE_NAME}: "${serviceName}" or (not ${SERVICE_NAME} and (${containerIdKql}))`
: `${SERVICE_NAME}: "${serviceName}"`;
};

0 comments on commit 0575f43

Please sign in to comment.