mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[APM] Show logs for all environments (#152722)
This fixes a bug where no logs would be shown if the user selected `Environment: All` (which is the default selection) Follow-up to https://github.com/elastic/kibana/pull/150065
This commit is contained in:
parent
4c9ed83c23
commit
88a2afbc5a
2 changed files with 23 additions and 10 deletions
|
@ -4,6 +4,7 @@
|
|||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
import { ENVIRONMENT_ALL } from '../../../../common/environment_filter_values';
|
||||
import { getInfrastructureKQLFilter } from '.';
|
||||
|
||||
describe('service logs', () => {
|
||||
|
@ -27,6 +28,20 @@ describe('service logs', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('does not filter by environment all', () => {
|
||||
expect(
|
||||
getInfrastructureKQLFilter({
|
||||
data: {
|
||||
containerIds: [],
|
||||
hostNames: [],
|
||||
podNames: [],
|
||||
},
|
||||
serviceName,
|
||||
environment: ENVIRONMENT_ALL.value,
|
||||
})
|
||||
).toEqual('service.name: "opbeans-node"');
|
||||
});
|
||||
|
||||
it('filter by container id as fallback', () => {
|
||||
expect(
|
||||
getInfrastructureKQLFilter({
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
import React from 'react';
|
||||
import moment from 'moment';
|
||||
import { LogStream } from '@kbn/infra-plugin/public';
|
||||
import { ENVIRONMENT_ALL } from '../../../../common/environment_filter_values';
|
||||
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';
|
||||
|
@ -75,11 +76,10 @@ export function getInfrastructureKQLFilter({
|
|||
serviceName: string;
|
||||
environment: string;
|
||||
}) {
|
||||
// correlate on service.name + service.environment
|
||||
const serviceNameAndEnvironmentCorrelation = `(${SERVICE_NAME}: "${serviceName}" and ${SERVICE_ENVIRONMENT}: "${environment}")`;
|
||||
|
||||
// correlate on service.name
|
||||
const serviceNameCorrelation = `(${SERVICE_NAME}: "${serviceName}" and not ${SERVICE_ENVIRONMENT}: *)`;
|
||||
const serviceNameAndEnvironmentCorrelation =
|
||||
environment === ENVIRONMENT_ALL.value
|
||||
? `${SERVICE_NAME}: "${serviceName}"` // correlate on service.name only
|
||||
: `(${SERVICE_NAME}: "${serviceName}" and ${SERVICE_ENVIRONMENT}: "${environment}") or (${SERVICE_NAME}: "${serviceName}" and not ${SERVICE_ENVIRONMENT}: *)`; // correlate on service.name + service.environment
|
||||
|
||||
// correlate on container.id
|
||||
const containerIdKql = (data?.containerIds ?? [])
|
||||
|
@ -89,9 +89,7 @@ export function getInfrastructureKQLFilter({
|
|||
? [`((${containerIdKql}) and not ${SERVICE_NAME}: *)`]
|
||||
: [];
|
||||
|
||||
return [
|
||||
serviceNameAndEnvironmentCorrelation,
|
||||
serviceNameCorrelation,
|
||||
...containerIdCorrelation,
|
||||
].join(' or ');
|
||||
return [serviceNameAndEnvironmentCorrelation, ...containerIdCorrelation].join(
|
||||
' or '
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue