Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove environment from uiFilters #89647

Merged
merged 34 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4d5504d
more stuff
smith Jan 28, 2021
16340c1
Merge branch 'master' into nls/env-filters
kibanamachine Feb 2, 2021
b10a147
Merge remote-tracking branch 'upstream/master' into nls/env-filters
smith Feb 2, 2021
1dbb29f
Merge remote-tracking branch 'upstream/master' into nls/env-filters
smith Feb 3, 2021
89eb2e1
more
smith Feb 3, 2021
7a49a46
Merge remote-tracking branch 'upstream/master' into nls/env-filters
smith Feb 4, 2021
99a7f8e
Merge remote-tracking branch 'upstream/master' into nls/env-filters
smith Feb 4, 2021
90b8d37
more envs
smith Feb 4, 2021
3f0ef1a
instances chart
smith Feb 4, 2021
026d244
more
smith Feb 4, 2021
d08efb0
more more more
smith Feb 4, 2021
3bfdf61
Merge remote-tracking branch 'upstream/master' into nls/env-filters
smith Feb 4, 2021
4f3e736
break some things
smith Feb 5, 2021
9d33889
remove env check
smith Feb 5, 2021
bfaa207
remove setup changes
smith Feb 5, 2021
ad1df2a
break some things
smith Feb 5, 2021
2d1fd23
range filter
smith Feb 5, 2021
dd2c052
queries
smith Feb 5, 2021
cc7b6c5
some fixes
smith Feb 8, 2021
6d134a9
Merge remote-tracking branch 'upstream/master' into nls/env-filters
smith Feb 8, 2021
9a3c1f2
Fix service map
smith Feb 9, 2021
1680ae4
Merge remote-tracking branch 'upstream/master' into nls/env-filters
smith Feb 9, 2021
1523d21
Merge remote-tracking branch 'upstream/master' into nls/env-filters
smith Feb 9, 2021
0f64561
fix at timestamp
smith Feb 9, 2021
443c35c
change another timestamp
smith Feb 9, 2021
b98e343
Merge remote-tracking branch 'upstream/master' into nls/env-filters
smith Feb 9, 2021
c3d98e8
remove import
smith Feb 9, 2021
cab21b9
Merge remote-tracking branch 'upstream/master' into nls/env-filters
smith Feb 9, 2021
0ada574
Test fixes
smith Feb 9, 2021
cf54bc0
Merge branch 'master' into nls/env-filters
kibanamachine Feb 10, 2021
355adaa
Merge branch 'master' into nls/env-filters
kibanamachine Feb 11, 2021
fd34ed1
Merge remote-tracking branch 'upstream/master' into nls/env-filters
smith Feb 16, 2021
33457aa
Merge remote-tracking branch 'upstream/master' into nls/env-filters
smith Feb 17, 2021
96edb6c
fixes
smith Feb 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions x-pack/plugins/apm/common/utils/queries.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { SERVICE_ENVIRONMENT } from '../elasticsearch_fieldnames';
import { ENVIRONMENT_NOT_DEFINED } from '../environment_filter_values';
import { environmentQuery } from './queries';

describe('environmentQuery', () => {
describe('when environment is undefined', () => {
it('returns an empty query', () => {
expect(environmentQuery()).toEqual([]);
});
});

it('creates a query for a service environment', () => {
expect(environmentQuery('test')).toEqual([
{
term: { [SERVICE_ENVIRONMENT]: 'test' },
},
]);
});

it('creates a query for missing service environments', () => {
expect(environmentQuery(ENVIRONMENT_NOT_DEFINED.value)[0]).toHaveProperty(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely a better name 👍

['bool', 'must_not', 'exists', 'field'],
SERVICE_ENVIRONMENT
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,41 @@
* 2.0.
*/

import { ESFilter } from '../../../../../../typings/elasticsearch';
import { ESFilter } from '../../../../typings/elasticsearch';
import {
ENVIRONMENT_NOT_DEFINED,
ENVIRONMENT_ALL,
} from '../../../../common/environment_filter_values';
import { SERVICE_ENVIRONMENT } from '../../../../common/elasticsearch_fieldnames';
} from '../environment_filter_values';
import { SERVICE_ENVIRONMENT } from '../elasticsearch_fieldnames';

export function getEnvironmentUiFilterES(environment?: string): ESFilter[] {
type QueryContainer = ESFilter;

export function environmentQuery(environment?: string): QueryContainer[] {
if (!environment || environment === ENVIRONMENT_ALL.value) {
return [];
}

if (environment === ENVIRONMENT_NOT_DEFINED.value) {
return [{ bool: { must_not: { exists: { field: SERVICE_ENVIRONMENT } } } }];
}

return [{ term: { [SERVICE_ENVIRONMENT]: environment } }];
}

export function rangeQuery(
start: number,
end: number,
field = '@timestamp'
): QueryContainer[] {
return [
{
range: {
[field]: {
gte: start,
lte: end,
format: 'epoch_millis',
},
},
},
];
}
sorenlouv marked this conversation as resolved.
Show resolved Hide resolved
16 changes: 0 additions & 16 deletions x-pack/plugins/apm/common/utils/range_filter.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type ErrorGroupDetailsProps = RouteComponentProps<{
export function ErrorGroupDetails({ location, match }: ErrorGroupDetailsProps) {
const { serviceName, groupId } = match.params;
const { urlParams, uiFilters } = useUrlParams();
const { start, end } = urlParams;
const { environment, start, end } = urlParams;

const { data: errorGroupData } = useFetcher(
(callApmApi) => {
Expand All @@ -81,6 +81,7 @@ export function ErrorGroupDetails({ location, match }: ErrorGroupDetailsProps) {
groupId,
},
query: {
environment,
start,
end,
uiFilters: JSON.stringify(uiFilters),
Expand All @@ -89,7 +90,7 @@ export function ErrorGroupDetails({ location, match }: ErrorGroupDetailsProps) {
});
}
},
[serviceName, start, end, groupId, uiFilters]
[environment, serviceName, start, end, groupId, uiFilters]
);

const { errorDistributionData } = useErrorGroupDistributionFetcher({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ export function ErrorCorrelations({ onClose }: Props) {

const { serviceName } = useParams<{ serviceName?: string }>();
const { urlParams, uiFilters } = useUrlParams();
const { transactionName, transactionType, start, end } = urlParams;
const {
environment,
transactionName,
transactionType,
start,
end,
} = urlParams;
const { defaultFieldNames } = useFieldNames();
const [fieldNames, setFieldNames] = useLocalStorage(
`apm.correlations.errors.fields:${serviceName}`,
Expand All @@ -65,6 +71,7 @@ export function ErrorCorrelations({ onClose }: Props) {
endpoint: 'GET /api/apm/correlations/failed_transactions',
params: {
query: {
environment,
serviceName,
transactionName,
transactionType,
Expand All @@ -78,6 +85,7 @@ export function ErrorCorrelations({ onClose }: Props) {
}
},
[
environment,
serviceName,
start,
end,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ export function LatencyCorrelations({ onClose }: Props) {

const { serviceName } = useParams<{ serviceName?: string }>();
const { urlParams, uiFilters } = useUrlParams();
const { transactionName, transactionType, start, end } = urlParams;
const {
environment,
transactionName,
transactionType,
start,
end,
} = urlParams;
const { defaultFieldNames } = useFieldNames();
const [fieldNames, setFieldNames] = useLocalStorage(
`apm.correlations.latency.fields:${serviceName}`,
Expand All @@ -70,6 +76,7 @@ export function LatencyCorrelations({ onClose }: Props) {
endpoint: 'GET /api/apm/correlations/slow_transactions',
params: {
query: {
environment,
serviceName,
transactionName,
transactionType,
Expand All @@ -84,6 +91,7 @@ export function LatencyCorrelations({ onClose }: Props) {
}
},
[
environment,
serviceName,
start,
end,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface ErrorGroupOverviewProps {

export function ErrorGroupOverview({ serviceName }: ErrorGroupOverviewProps) {
const { urlParams, uiFilters } = useUrlParams();
const { start, end, sortField, sortDirection } = urlParams;
const { environment, start, end, sortField, sortDirection } = urlParams;
const { errorDistributionData } = useErrorGroupDistributionFetcher({
serviceName,
groupId: undefined,
Expand All @@ -46,6 +46,7 @@ export function ErrorGroupOverview({ serviceName }: ErrorGroupOverviewProps) {
serviceName,
},
query: {
environment,
start,
end,
sortField,
Expand All @@ -56,7 +57,7 @@ export function ErrorGroupOverview({ serviceName }: ErrorGroupOverviewProps) {
});
}
},
[serviceName, start, end, sortField, sortDirection, uiFilters]
[environment, serviceName, start, end, sortField, sortDirection, uiFilters]
);

useTrackPageview({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,24 @@ function useServicesFetcher() {
const { urlParams, uiFilters } = useUrlParams();
const { core } = useApmPluginContext();
const upgradeAssistantHref = useUpgradeAssistantHref();
const { start, end } = urlParams;
const { environment, start, end } = urlParams;
const { data = initialData, status } = useFetcher(
(callApmApi) => {
if (start && end) {
return callApmApi({
endpoint: 'GET /api/apm/services',
params: {
query: { start, end, uiFilters: JSON.stringify(uiFilters) },
query: {
environment,
start,
end,
uiFilters: JSON.stringify(uiFilters),
sorenlouv marked this conversation as resolved.
Show resolved Hide resolved
},
},
});
}
},
[start, end, uiFilters]
[environment, start, end, uiFilters]
);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import {
ENVIRONMENT_ALL,
getNextEnvironmentUrlParam,
} from '../../../../../common/environment_filter_values';
import { getNextEnvironmentUrlParam } from '../../../../../common/environment_filter_values';
import {
asMillisecondDuration,
asPercent,
Expand Down Expand Up @@ -182,7 +179,7 @@ export function ServiceOverviewDependenciesTable({ serviceName }: Props) {
query: {
start,
end,
environment: environment || ENVIRONMENT_ALL.value,
environment,
sorenlouv marked this conversation as resolved.
Show resolved Hide resolved
numBuckets: 20,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const DEFAULT_SORT = {

export function ServiceOverviewErrorsTable({ serviceName }: Props) {
const {
urlParams: { start, end },
urlParams: { environment, start, end },
uiFilters,
} = useUrlParams();
const { transactionType } = useApmServiceContext();
Expand Down Expand Up @@ -152,6 +152,7 @@ export function ServiceOverviewErrorsTable({ serviceName }: Props) {
params: {
path: { serviceName },
query: {
environment,
start,
end,
uiFilters: JSON.stringify(uiFilters),
Expand All @@ -178,6 +179,7 @@ export function ServiceOverviewErrorsTable({ serviceName }: Props) {
});
},
[
environment,
start,
end,
serviceName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function ServiceOverviewInstancesChartAndTable({
const { transactionType } = useApmServiceContext();

const {
urlParams: { start, end },
urlParams: { environment, start, end },
uiFilters,
} = useUrlParams();

Expand All @@ -43,6 +43,7 @@ export function ServiceOverviewInstancesChartAndTable({
serviceName,
},
query: {
environment,
start,
end,
transactionType,
Expand All @@ -52,7 +53,7 @@ export function ServiceOverviewInstancesChartAndTable({
},
});
},
[start, end, serviceName, transactionType, uiFilters]
[environment, start, end, serviceName, transactionType, uiFilters]
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function ServiceOverviewThroughputChart({
const { serviceName } = useParams<{ serviceName?: string }>();
const { urlParams, uiFilters } = useUrlParams();
const { transactionType } = useApmServiceContext();
const { start, end } = urlParams;
const { environment, start, end } = urlParams;

const { data = INITIAL_STATE, status } = useFetcher(
(callApmApi) => {
Expand All @@ -42,6 +42,7 @@ export function ServiceOverviewThroughputChart({
serviceName,
},
query: {
environment,
start,
end,
transactionType,
Expand All @@ -51,7 +52,7 @@ export function ServiceOverviewThroughputChart({
});
}
},
[serviceName, start, end, uiFilters, transactionType]
[environment, serviceName, start, end, uiFilters, transactionType]
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function ServiceOverviewTransactionsTable({ serviceName }: Props) {
const { transactionType } = useApmServiceContext();
const {
uiFilters,
urlParams: { start, end, latencyAggregationType },
urlParams: { environment, start, end, latencyAggregationType },
} = useUrlParams();

const { data = INITIAL_STATE, status } = useFetcher(
Expand All @@ -72,6 +72,7 @@ export function ServiceOverviewTransactionsTable({ serviceName }: Props) {
params: {
path: { serviceName },
query: {
environment,
start,
end,
uiFilters: JSON.stringify(uiFilters),
Expand All @@ -87,6 +88,7 @@ export function ServiceOverviewTransactionsTable({ serviceName }: Props) {
});
},
[
environment,
serviceName,
start,
end,
Expand Down Expand Up @@ -125,6 +127,7 @@ export function ServiceOverviewTransactionsTable({ serviceName }: Props) {
params: {
path: { serviceName },
query: {
environment,
start,
end,
uiFilters: JSON.stringify(uiFilters),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ const DEFAULT_RESPONSE: TracesAPIResponse = {

export function TraceOverview() {
const { urlParams, uiFilters } = useUrlParams();
const { start, end } = urlParams;
const { environment, start, end } = urlParams;
const { status, data = DEFAULT_RESPONSE } = useFetcher(
(callApmApi) => {
if (start && end) {
return callApmApi({
endpoint: 'GET /api/apm/traces',
params: {
query: {
environment,
start,
end,
uiFilters: JSON.stringify(uiFilters),
Expand All @@ -39,7 +40,7 @@ export function TraceOverview() {
});
}
},
[start, end, uiFilters]
[environment, start, end, uiFilters]
);

useTrackPageview({ app: 'apm', path: 'traces_overview' });
Expand Down
Loading