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

[7.x] [APM] Correlations Beta (#86477) (#89952) #91603

Merged
merged 1 commit into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,4 @@ export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
'securitySolution:rulesTableRefresh': { type: 'text' },
'apm:enableSignificantTerms': { type: 'boolean' },
'apm:enableServiceOverview': { type: 'boolean' },
'apm:enableCorrelations': { type: 'boolean' },
};
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export interface UsageStats {
'securitySolution:rulesTableRefresh': string;
'apm:enableSignificantTerms': boolean;
'apm:enableServiceOverview': boolean;
'apm:enableCorrelations': boolean;
'visualize:enableLabs': boolean;
'visualization:heatmap:maxBuckets': number;
'visualization:colorMapping': string;
Expand Down
3 changes: 0 additions & 3 deletions src/plugins/telemetry/schema/oss_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4387,9 +4387,6 @@
},
"apm:enableServiceOverview": {
"type": "boolean"
},
"apm:enableCorrelations": {
"type": "boolean"
}
}
},
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/apm/common/ui_settings_keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
* 2.0.
*/

export const enableCorrelations = 'apm:enableCorrelations';
export const enableServiceOverview = 'apm:enableServiceOverview';
108 changes: 0 additions & 108 deletions x-pack/plugins/apm/public/components/app/Correlations/index.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@
* 2.0.
*/

import React from 'react';
import { EuiIcon, EuiLink } from '@elastic/eui';
import React, { useCallback } from 'react';
import { debounce } from 'lodash';
import {
EuiIcon,
EuiLink,
EuiBasicTable,
EuiBasicTableColumn,
EuiToolTip,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { useHistory } from 'react-router-dom';
import { EuiBasicTable } from '@elastic/eui';
import { EuiBasicTableColumn } from '@elastic/eui';
import { EuiCode } from '@elastic/eui';
import { asInteger, asPercent } from '../../../../common/utils/formatters';
import { APIReturnType } from '../../../services/rest/createCallApmApi';
import { FETCH_STATUS } from '../../../hooks/use_fetcher';
import { createHref, push } from '../../shared/Links/url_helpers';
import { ImpactBar } from '../../shared/ImpactBar';
import { useUiTracker } from '../../../../../observability/public';

type CorrelationsApiResponse =
| APIReturnType<'GET /api/apm/correlations/failed_transactions'>
Expand All @@ -27,49 +34,83 @@ type SignificantTerm = NonNullable<
interface Props<T> {
significantTerms?: T[];
status: FETCH_STATUS;
cardinalityColumnName: string;
percentageColumnName: string;
setSelectedSignificantTerm: (term: T | null) => void;
onFilter: () => void;
}

export function SignificantTermsTable<T extends SignificantTerm>({
export function CorrelationsTable<T extends SignificantTerm>({
significantTerms,
status,
cardinalityColumnName,
percentageColumnName,
setSelectedSignificantTerm,
onFilter,
}: Props<T>) {
const trackApmEvent = useUiTracker({ app: 'apm' });
const trackSelectSignificantTerm = useCallback(
() =>
debounce(
() => trackApmEvent({ metric: 'select_significant_term' }),
1000
),
[trackApmEvent]
);
const history = useHistory();
const columns: Array<EuiBasicTableColumn<T>> = [
{
width: '100px',
field: 'score',
name: 'Score',
field: 'impact',
name: i18n.translate(
'xpack.apm.correlations.correlationsTable.impactLabel',
{ defaultMessage: 'Impact' }
),
render: (_: any, term: T) => {
return <EuiCode>{Math.round(term.score)}</EuiCode>;
return <ImpactBar value={term.impact * 100} />;
},
},
{
field: 'cardinality',
name: cardinalityColumnName,
field: 'percentage',
name: percentageColumnName,
render: (_: any, term: T) => {
const matches = asPercent(term.fgCount, term.bgCount);
return `${asInteger(term.fgCount)} (${matches})`;
return (
<EuiToolTip
position="right"
content={`${asInteger(term.valueCount)} / ${asInteger(
term.fieldCount
)}`}
>
<>{asPercent(term.valueCount, term.fieldCount)}</>
</EuiToolTip>
);
},
},
{
field: 'fieldName',
name: 'Field name',
name: i18n.translate(
'xpack.apm.correlations.correlationsTable.fieldNameLabel',
{ defaultMessage: 'Field name' }
),
},
{
field: 'fieldValue',
name: 'Field value',
name: i18n.translate(
'xpack.apm.correlations.correlationsTable.fieldValueLabel',
{ defaultMessage: 'Field value' }
),
render: (_: any, term: T) => String(term.fieldValue).slice(0, 50),
},
{
width: '100px',
actions: [
{
name: 'Focus',
description: 'Focus on this term',
name: i18n.translate(
'xpack.apm.correlations.correlationsTable.filterLabel',
{ defaultMessage: 'Filter' }
),
description: i18n.translate(
'xpack.apm.correlations.correlationsTable.filterDescription',
{ defaultMessage: 'Filter by value' }
),
icon: 'magnifyWithPlus',
type: 'icon',
onClick: (term: T) => {
Expand All @@ -80,11 +121,19 @@ export function SignificantTermsTable<T extends SignificantTerm>({
)}"`,
},
});
onFilter();
trackApmEvent({ metric: 'correlations_term_include_filter' });
},
},
{
name: 'Exclude',
description: 'Exclude this term',
name: i18n.translate(
'xpack.apm.correlations.correlationsTable.excludeLabel',
{ defaultMessage: 'Exclude' }
),
description: i18n.translate(
'xpack.apm.correlations.correlationsTable.excludeDescription',
{ defaultMessage: 'Filter out value' }
),
icon: 'magnifyWithMinus',
type: 'icon',
onClick: (term: T) => {
Expand All @@ -95,10 +144,15 @@ export function SignificantTermsTable<T extends SignificantTerm>({
)}"`,
},
});
onFilter();
trackApmEvent({ metric: 'correlations_term_exclude_filter' });
},
},
],
name: 'Actions',
name: i18n.translate(
'xpack.apm.correlations.correlationsTable.actionsLabel',
{ defaultMessage: 'Actions' }
),
render: (_: any, term: T) => {
return (
<>
Expand Down Expand Up @@ -134,15 +188,30 @@ export function SignificantTermsTable<T extends SignificantTerm>({
return (
<EuiBasicTable
items={significantTerms ?? []}
noItemsMessage={status === FETCH_STATUS.LOADING ? 'Loading' : 'No data'}
noItemsMessage={
status === FETCH_STATUS.LOADING ? loadingText : noDataText
}
loading={status === FETCH_STATUS.LOADING}
columns={columns}
rowProps={(term) => {
return {
onMouseEnter: () => setSelectedSignificantTerm(term),
onMouseEnter: () => {
setSelectedSignificantTerm(term);
trackSelectSignificantTerm();
},
onMouseLeave: () => setSelectedSignificantTerm(null),
};
}}
/>
);
}

const loadingText = i18n.translate(
'xpack.apm.correlations.correlationsTable.loadingText',
{ defaultMessage: 'Loading' }
);

const noDataText = i18n.translate(
'xpack.apm.correlations.correlationsTable.noDataText',
{ defaultMessage: 'No data' }
);
Loading