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

[ML] APM Latency Correlations #99905

Merged
merged 98 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from 89 commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
f83ebad
[ML] Async Search Service.
walterra May 12, 2021
0942b29
[ML] Log Log Area Charts Grid. Scatterplot with streaming data.
walterra May 26, 2021
e07aac1
[ML] Remove scatterplot streaming demo.
walterra May 26, 2021
a163b46
[ML] Improved histogram bins for log scale.
walterra May 28, 2021
8607e5d
[ML] Move client side code from Ml to APM plugin.
walterra May 28, 2021
1bd7c24
[ML] Adds correlation table.
walterra May 28, 2021
8c15c86
[ML] Layout tweaks.
walterra May 28, 2021
14828f8
[ML] Move server side code from ML to APM.
walterra May 28, 2021
9ccb65a
[ML] Remove console.logs.
walterra May 28, 2021
220bca7
[ML] Fix types.
walterra Jun 1, 2021
0682831
Merge remote-tracking branch 'upstream/master' into ml-apm-correlations
qn895 Jun 1, 2021
9cfbd13
[ML] Chart area line type fix. Slowness %.
walterra Jun 3, 2021
6eca7d1
Merge branch 'ml-apm-correlations' of github.com:walterra/kibana into…
walterra Jun 3, 2021
b88c15d
[ML] Comment unused vars.
walterra Jun 3, 2021
6f70c3f
Merge upstream/main into branch
qn895 Jun 8, 2021
0009dfe
Fix missing pluginsStart data in context
qn895 Jun 8, 2021
fdab271
Add KS test value and rename table columns
qn895 Jun 8, 2021
317f122
Update percentiles to be correct
qn895 Jun 10, 2021
634f42c
Merge upstream/main into branch
qn895 Jun 10, 2021
6e6cbaa
Make columns optional
qn895 Jun 10, 2021
b30fe03
Merge remote-tracking branch 'upstream/master' into ml-apm-correlations
qn895 Jun 14, 2021
8cd33bb
Update fractionals/expectations to match with backend logic
qn895 Jun 14, 2021
d03250a
Update so progress is 100% when all is completed
qn895 Jun 14, 2021
4447653
Make pre-processing steps smaller part of overall progress(to show ch…
qn895 Jun 14, 2021
513b6ad
Add no correlations found message
qn895 Jun 14, 2021
190c9f4
Fix progress logic
qn895 Jun 14, 2021
082abe9
Fix incorrect threshold, types
qn895 Jun 14, 2021
88798b1
Add back APM filtering functionality to match with other table
qn895 Jun 14, 2021
a036ac7
Improve histogram equality check with random sampling
qn895 Jun 14, 2021
ccef749
Show overall latency distribution right away
qn895 Jun 16, 2021
a75a2b6
Merge remote-tracking branch 'upstream/master' into ml-apm-correlations
qn895 Jun 17, 2021
0cacd37
Rename demo tab to latencyCorrelationsTab
qn895 Jun 17, 2021
ac15415
Update percentiles query to use hdr
qn895 Jun 17, 2021
9a5e733
[ML] Fix issue where apm-* might have multiple indices with different…
qn895 Jun 20, 2021
64324c4
Remove commented code
qn895 Jun 20, 2021
31cfa17
Remove kstest column, round correlation to 2 sigfig dec
qn895 Jun 20, 2021
c286aa1
Remove old latency tab, replace with ml latency correlations tab as f…
qn895 Jun 20, 2021
68e747f
Set axis to start at 0 because agg may results in weird
qn895 Jun 20, 2021
ad5c11c
Remove commented code for grouping duplicates
qn895 Jun 20, 2021
58b85c5
Update msg to mean significant correlations
qn895 Jun 20, 2021
103ec2a
Add i18n
qn895 Jun 20, 2021
6bb5a30
Change correlations flyout back to medium size
qn895 Jun 20, 2021
69a398a
Add name of service or transaction for clarity
qn895 Jun 20, 2021
45751fa
Share i18n
qn895 Jun 20, 2021
f19a9fe
Consolidate roundToDecimalPlace usage
qn895 Jun 20, 2021
c386e6a
Remove redundant isDuplicate
qn895 Jun 20, 2021
0797770
Create MAX_CORRELATIONS_TO_SHOW
qn895 Jun 20, 2021
bce0d99
Merge remote-tracking branch 'upstream/master' into ml-apm-correlations
qn895 Jun 20, 2021
0a8841d
Update mlCorrelationcolumns
qn895 Jun 20, 2021
6af39c0
Fix i18n quotations
qn895 Jun 20, 2021
9a37eec
Update query to include filter
qn895 Jun 21, 2021
ac734de
Revert "Update query to include filter"
qn895 Jun 21, 2021
5744c7f
Rename MlCorrelations to MlLatencyCorrelations for clarity
qn895 Jun 21, 2021
f3f974c
Add pagination
qn895 Jun 21, 2021
d4a0743
Update include/exclude logic for field candidates and add ip field su…
qn895 Jun 21, 2021
eeac81c
Add transactionName filter suport
qn895 Jun 21, 2021
f6a79f8
Reorganize math utils
qn895 Jun 21, 2021
632cc89
Group duplicates together
qn895 Jun 21, 2021
9c477bb
Merge remote-tracking branch 'upstream/master' into ml-apm-correlations
qn895 Jun 22, 2021
b83afff
Fix typescript, better hasPrefixToInclude support check,
qn895 Jun 22, 2021
53d2c06
Remove Finished toast
qn895 Jun 22, 2021
3c5c912
Add title to y axis
qn895 Jun 22, 2021
08b3d36
Reduce number of tick labels to show
qn895 Jun 22, 2021
2be54ad
Highlight table row that is being used for graph
qn895 Jun 22, 2021
0331fc1
Add from to follow MDN guideline
qn895 Jun 22, 2021
45b788c
Add APM style prefix
qn895 Jun 22, 2021
1f85a03
Fix i18n
qn895 Jun 22, 2021
9b73f97
[ML] Fix logic for tick format to only show power of 10
qn895 Jun 23, 2021
31973bb
Replace roundToDecimalPlace with asPreciseDecimal
qn895 Jun 23, 2021
288f394
Switch to lodash range
qn895 Jun 23, 2021
19d465a
Clean up get_query_with_params
qn895 Jun 23, 2021
6c48af6
Prioritize candidates using field_terms
qn895 Jun 23, 2021
02837cc
Update percentiles result type to be array instead of objects
qn895 Jun 23, 2021
4686225
Use observability's rangeQuery instead
qn895 Jun 23, 2021
7dee7b4
Change arg format of query
qn895 Jun 24, 2021
60dbf54
Revert candidate_terms logic
qn895 Jun 24, 2021
8f0f58d
Merge remote-tracking branch 'upstream/master' into ml-apm-correlations
qn895 Jun 24, 2021
ae56f3e
Merge branch 'master' into ml-apm-correlations
kibanamachine Jun 27, 2021
05c8ae3
Consolidate fractions, expectations, and ranges calc
qn895 Jun 24, 2021
540d206
Add tooltip for Correlation
qn895 Jun 24, 2021
f8d444c
Change terms size to 20
qn895 Jun 24, 2021
33484d8
Move env/service/transaction sticky header to top level, remove link
qn895 Jun 24, 2021
c17d8e3
Add support for http.response.status_code
qn895 Jun 24, 2021
a837968
Replace histogram circular markers with bars
qn895 Jun 24, 2021
ddb2b3a
Delete unused roundToDecimalPlace
qn895 Jun 24, 2021
1a63d8c
Add fractions calculation
qn895 Jun 27, 2021
c6d9341
Make notes of fractions and fix bucket correlation
qn895 Jun 28, 2021
fdeafd8
Remove any, commented code, consolidate cancelFetch
qn895 Jun 28, 2021
78ab411
Use es6 max
qn895 Jun 28, 2021
d61f690
Align tooltip at the top
qn895 Jun 28, 2021
b616063
Merge remote-tracking branch 'upstream/master' into ml-apm-correlations
qn895 Jun 28, 2021
034c680
Get rid of getCoreServices, param docs, rename type, remove rangeQuery
qn895 Jun 28, 2021
5206946
Adjust range
qn895 Jun 28, 2021
b2ad1a2
Show all values without grouping duplicates
qn895 Jun 28, 2021
6bb6079
Fix pagination
qn895 Jun 28, 2021
1bff73e
Make flyout larger
qn895 Jun 28, 2021
76dffcf
Merge branch 'master' into ml-apm-correlations
kibanamachine Jun 28, 2021
2d7f90e
Merge branch 'master' into ml-apm-correlations
kibanamachine Jun 29, 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
51 changes: 51 additions & 0 deletions x-pack/plugins/apm/common/search_strategies/correlations/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* 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.
*/

export interface HistogramItem {
key: number;
doc_count: number;
}

export interface ResponseHitSource {
[s: string]: unknown;
}

export interface ResponseHit {
_source: ResponseHitSource;
}

export interface SearchServiceParams {
index: string;
environment?: string;
kuery?: string;
serviceName?: string;
transactionName?: string;
transactionType?: string;
start?: string;
end?: string;
percentileThreshold?: number;
percentileThresholdValue?: number;
}

export interface SearchServiceValue {
histogram: HistogramItem[];
value: string;
field: string;
correlation: number;
ksTest: number;
duplicatedFields?: string[];
}

export interface AsyncSearchProviderProgress {
started: number;
loadedHistogramStepsize: number;
loadedOverallHistogram: number;
loadedFieldCanditates: number;
loadedFieldValuePairs: number;
loadedHistograms: number;
getOverallProgress: () => number;
}
8 changes: 8 additions & 0 deletions x-pack/plugins/apm/common/utils/formatters/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ export function asDecimal(value?: number | null) {
return numeral(value).format('0,0.0');
}

export function asPreciseDecimal(value?: number | null, dp: number = 3) {
if (!isFiniteNumber(value)) {
return NOT_AVAILABLE_LABEL;
}

return numeral(value).format(`0,0.${'0'.repeat(dp)}`);
}

export function asInteger(value?: number | null) {
if (!isFiniteNumber(value)) {
return NOT_AVAILABLE_LABEL;
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/apm/public/application/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const renderApp = ({
config,
core: coreStart,
plugins: pluginsSetup,
data: pluginsStart.data,
observability: pluginsStart.observability,
observabilityRuleTypeRegistry,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
/*
* 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 React from 'react';
import {
AnnotationDomainType,
Chart,
CurveType,
Settings,
Axis,
ScaleType,
Position,
AreaSeries,
RecursivePartial,
AxisStyle,
PartialTheme,
LineAnnotation,
LineAnnotationDatum,
} from '@elastic/charts';

import euiVars from '@elastic/eui/dist/eui_theme_light.json';

import { EuiSpacer } from '@elastic/eui';

import { i18n } from '@kbn/i18n';

import { getDurationFormatter } from '../../../../common/utils/formatters';

import { useTheme } from '../../../hooks/use_theme';
import { HistogramItem } from '../../../../common/search_strategies/correlations/types';

const { euiColorMediumShade } = euiVars;
const axisColor = euiColorMediumShade;

const axes: RecursivePartial<AxisStyle> = {
axisLine: {
stroke: axisColor,
},
tickLabel: {
fontSize: 10,
fill: axisColor,
padding: 0,
},
tickLine: {
stroke: axisColor,
size: 5,
},
gridLine: {
horizontal: {
dash: [1, 2],
},
vertical: {
strokeWidth: 1,
},
},
};
const chartTheme: PartialTheme = {
axes,
legend: {
spacingBuffer: 100,
},
areaSeriesStyle: {
line: {
visible: false,
},
},
};

// Default axis to start at 0 for latency correlations chart
const xAxisDomain = {
min: 0,
};

interface CorrelationsChartProps {
field?: string;
value?: string;
histogram?: HistogramItem[];
markerValue: number;
markerPercentile: number;
overallHistogram: HistogramItem[];
}

const annotationsStyle = {
line: {
strokeWidth: 1,
stroke: 'gray',
opacity: 0.8,
},
details: {
fontSize: 8,
fontFamily: 'Arial',
fontStyle: 'normal',
fill: 'gray',
padding: 0,
},
};

const CHART_PLACEHOLDER_VALUE = 0.0001;

// Elastic charts will show any lone bin (i.e. a populated bin followed by empty bin)
// as a circular marker instead of a bar
// This provides a workaround by making the next bin not empty
export const replaceHistogramDotsWithBars = (
originalHistogram: HistogramItem[] | undefined
) => {
if (originalHistogram === undefined) return;
const histogram = [...originalHistogram];
{
for (let i = 0; i < histogram.length - 1; i++) {
if (
histogram[i].doc_count > 0 &&
histogram[i].doc_count !== CHART_PLACEHOLDER_VALUE &&
histogram[i + 1].doc_count === 0
) {
histogram[i + 1].doc_count = CHART_PLACEHOLDER_VALUE;
}
}
return histogram;
}
};

export function CorrelationsChart({
field,
value,
histogram: originalHistogram,
markerValue,
markerPercentile,
overallHistogram,
}: CorrelationsChartProps) {
const euiTheme = useTheme();

if (!Array.isArray(overallHistogram)) return <div />;
const annotationsDataValues: LineAnnotationDatum[] = [
{ dataValue: markerValue, details: `${markerPercentile}th percentile` },
];

const xMax = Math.max(...overallHistogram.map((d) => d.key)) ?? 0;

const durationFormatter = getDurationFormatter(xMax);

const histogram = replaceHistogramDotsWithBars(originalHistogram);

return (
<div style={{ overflow: 'hidden', textOverflow: 'ellipsis' }}>
<Chart
size={{
height: '250px',
}}
>
<Settings
rotation={0}
theme={chartTheme}
showLegend
legendPosition={Position.Bottom}
xDomain={xAxisDomain}
/>
<LineAnnotation
id="annotation_1"
domainType={AnnotationDomainType.XDomain}
dataValues={annotationsDataValues}
style={annotationsStyle}
marker={`${markerPercentile}p`}
markerPosition={'top'}
/>
<Axis
id="x-axis"
title=""
position={Position.Bottom}
tickFormat={(d) => durationFormatter(d).formatted}
/>
<Axis
id="y-axis"
title={i18n.translate(
'xpack.apm.correlations.latency.chart.numberOfTransactionsLabel',
{ defaultMessage: '# transactions' }
)}
position={Position.Left}
tickFormat={(d) =>
d === 0 || Number.isInteger(Math.log10(d)) ? d : ''
}
/>
<AreaSeries
id={i18n.translate(
'xpack.apm.correlations.latency.chart.overallLatencyDistributionLabel',
{ defaultMessage: 'Overall latency distribution' }
)}
xScaleType={ScaleType.Log}
yScaleType={ScaleType.Log}
data={overallHistogram}
curve={CurveType.CURVE_STEP_AFTER}
xAccessor="key"
yAccessors={['doc_count']}
color={euiTheme.eui.euiColorVis1}
fit="lookahead"
/>
{Array.isArray(histogram) &&
field !== undefined &&
value !== undefined && (
<AreaSeries
id={i18n.translate(
'xpack.apm.correlations.latency.chart.selectedTermLatencyDistributionLabel',
{
defaultMessage: '{fieldName}:{fieldValue}',
values: {
fieldName: field,
fieldValue: value,
},
}
)}
qn895 marked this conversation as resolved.
Show resolved Hide resolved
xScaleType={ScaleType.Log}
yScaleType={ScaleType.Log}
data={histogram}
curve={CurveType.CURVE_STEP_AFTER}
xAccessor="key"
yAccessors={['doc_count']}
color={euiTheme.eui.euiColorVis2}
/>
)}
</Chart>
<EuiSpacer size="s" />
</div>
);
}
Loading