mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
# Backport This will backport the following commits from `main` to `8.7`: - [[APM] Show logs for all environments (#152722)](https://github.com/elastic/kibana/pull/152722) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Søren Louv-Jansen","email":"soren.louv@elastic.co"},"sourceCommit":{"committedDate":"2023-03-07T07:47:09Z","message":"[APM] Show logs for all environments (#152722)\n\nThis fixes a bug where no logs would be shown if the user selected\r\n`Environment: All` (which is the default selection)\r\n\r\nFollow-up to https://github.com/elastic/kibana/pull/150065","sha":"88a2afbc5a1e92baa2b2fd0564fff73d21ee3d46","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:APM","release_note:skip","v8.7.0","v8.8.0"],"number":152722,"url":"https://github.com/elastic/kibana/pull/152722","mergeCommit":{"message":"[APM] Show logs for all environments (#152722)\n\nThis fixes a bug where no logs would be shown if the user selected\r\n`Environment: All` (which is the default selection)\r\n\r\nFollow-up to https://github.com/elastic/kibana/pull/150065","sha":"88a2afbc5a1e92baa2b2fd0564fff73d21ee3d46"}},"sourceBranch":"main","suggestedTargetBranches":["8.7"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/152722","number":152722,"mergeCommit":{"message":"[APM] Show logs for all environments (#152722)\n\nThis fixes a bug where no logs would be shown if the user selected\r\n`Environment: All` (which is the default selection)\r\n\r\nFollow-up to https://github.com/elastic/kibana/pull/150065","sha":"88a2afbc5a1e92baa2b2fd0564fff73d21ee3d46"}}]}] BACKPORT--> Co-authored-by: Søren Louv-Jansen <soren.louv@elastic.co>
This commit is contained in:
parent
f37e3ec87e
commit
c843c37efc
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