-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Changes from 76 commits
Commits
Show all changes
98 commits
Select commit
Hold shift + click to select a range
f83ebad
[ML] Async Search Service.
walterra 0942b29
[ML] Log Log Area Charts Grid. Scatterplot with streaming data.
walterra e07aac1
[ML] Remove scatterplot streaming demo.
walterra a163b46
[ML] Improved histogram bins for log scale.
walterra 8607e5d
[ML] Move client side code from Ml to APM plugin.
walterra 1bd7c24
[ML] Adds correlation table.
walterra 8c15c86
[ML] Layout tweaks.
walterra 14828f8
[ML] Move server side code from ML to APM.
walterra 9ccb65a
[ML] Remove console.logs.
walterra 220bca7
[ML] Fix types.
walterra 0682831
Merge remote-tracking branch 'upstream/master' into ml-apm-correlations
qn895 9cfbd13
[ML] Chart area line type fix. Slowness %.
walterra 6eca7d1
Merge branch 'ml-apm-correlations' of github.com:walterra/kibana into…
walterra b88c15d
[ML] Comment unused vars.
walterra 6f70c3f
Merge upstream/main into branch
qn895 0009dfe
Fix missing pluginsStart data in context
qn895 fdab271
Add KS test value and rename table columns
qn895 317f122
Update percentiles to be correct
qn895 634f42c
Merge upstream/main into branch
qn895 6e6cbaa
Make columns optional
qn895 b30fe03
Merge remote-tracking branch 'upstream/master' into ml-apm-correlations
qn895 8cd33bb
Update fractionals/expectations to match with backend logic
qn895 d03250a
Update so progress is 100% when all is completed
qn895 4447653
Make pre-processing steps smaller part of overall progress(to show ch…
qn895 513b6ad
Add no correlations found message
qn895 190c9f4
Fix progress logic
qn895 082abe9
Fix incorrect threshold, types
qn895 88798b1
Add back APM filtering functionality to match with other table
qn895 a036ac7
Improve histogram equality check with random sampling
qn895 ccef749
Show overall latency distribution right away
qn895 a75a2b6
Merge remote-tracking branch 'upstream/master' into ml-apm-correlations
qn895 0cacd37
Rename demo tab to latencyCorrelationsTab
qn895 ac15415
Update percentiles query to use hdr
qn895 9a5e733
[ML] Fix issue where apm-* might have multiple indices with different…
qn895 64324c4
Remove commented code
qn895 31cfa17
Remove kstest column, round correlation to 2 sigfig dec
qn895 c286aa1
Remove old latency tab, replace with ml latency correlations tab as f…
qn895 68e747f
Set axis to start at 0 because agg may results in weird
qn895 ad5c11c
Remove commented code for grouping duplicates
qn895 58b85c5
Update msg to mean significant correlations
qn895 103ec2a
Add i18n
qn895 6bb5a30
Change correlations flyout back to medium size
qn895 69a398a
Add name of service or transaction for clarity
qn895 45751fa
Share i18n
qn895 f19a9fe
Consolidate roundToDecimalPlace usage
qn895 c386e6a
Remove redundant isDuplicate
qn895 0797770
Create MAX_CORRELATIONS_TO_SHOW
qn895 bce0d99
Merge remote-tracking branch 'upstream/master' into ml-apm-correlations
qn895 0a8841d
Update mlCorrelationcolumns
qn895 6af39c0
Fix i18n quotations
qn895 9a37eec
Update query to include filter
qn895 ac734de
Revert "Update query to include filter"
qn895 5744c7f
Rename MlCorrelations to MlLatencyCorrelations for clarity
qn895 f3f974c
Add pagination
qn895 d4a0743
Update include/exclude logic for field candidates and add ip field su…
qn895 eeac81c
Add transactionName filter suport
qn895 f6a79f8
Reorganize math utils
qn895 632cc89
Group duplicates together
qn895 9c477bb
Merge remote-tracking branch 'upstream/master' into ml-apm-correlations
qn895 b83afff
Fix typescript, better hasPrefixToInclude support check,
qn895 53d2c06
Remove Finished toast
qn895 3c5c912
Add title to y axis
qn895 08b3d36
Reduce number of tick labels to show
qn895 2be54ad
Highlight table row that is being used for graph
qn895 0331fc1
Add from to follow MDN guideline
qn895 45b788c
Add APM style prefix
qn895 1f85a03
Fix i18n
qn895 9b73f97
[ML] Fix logic for tick format to only show power of 10
qn895 31973bb
Replace roundToDecimalPlace with asPreciseDecimal
qn895 288f394
Switch to lodash range
qn895 19d465a
Clean up get_query_with_params
qn895 6c48af6
Prioritize candidates using field_terms
qn895 02837cc
Update percentiles result type to be array instead of objects
qn895 4686225
Use observability's rangeQuery instead
qn895 7dee7b4
Change arg format of query
qn895 60dbf54
Revert candidate_terms logic
qn895 8f0f58d
Merge remote-tracking branch 'upstream/master' into ml-apm-correlations
qn895 ae56f3e
Merge branch 'master' into ml-apm-correlations
kibanamachine 05c8ae3
Consolidate fractions, expectations, and ranges calc
qn895 540d206
Add tooltip for Correlation
qn895 f8d444c
Change terms size to 20
qn895 33484d8
Move env/service/transaction sticky header to top level, remove link
qn895 c17d8e3
Add support for http.response.status_code
qn895 a837968
Replace histogram circular markers with bars
qn895 ddb2b3a
Delete unused roundToDecimalPlace
qn895 1a63d8c
Add fractions calculation
qn895 c6d9341
Make notes of fractions and fix bucket correlation
qn895 fdeafd8
Remove any, commented code, consolidate cancelFetch
qn895 78ab411
Use es6 max
qn895 d61f690
Align tooltip at the top
qn895 b616063
Merge remote-tracking branch 'upstream/master' into ml-apm-correlations
qn895 034c680
Get rid of getCoreServices, param docs, rename type, remove rangeQuery
qn895 5206946
Adjust range
qn895 b2ad1a2
Show all values without grouping duplicates
qn895 6bb6079
Fix pagination
qn895 1bff73e
Make flyout larger
qn895 76dffcf
Merge branch 'master' into ml-apm-correlations
kibanamachine 2d7f90e
Merge branch 'master' into ml-apm-correlations
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
x-pack/plugins/apm/common/search_strategies/correlations/formatting_utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* 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 function roundToDecimalPlace( | ||
num?: number, | ||
dp: number = 2 | ||
): number | string { | ||
if (num === undefined) return ''; | ||
if (num % 1 === 0) { | ||
// no decimal place | ||
return num; | ||
} | ||
|
||
if (Math.abs(num) < Math.pow(10, -dp)) { | ||
return Number.parseFloat(String(num)).toExponential(2); | ||
} | ||
const m = Math.pow(10, dp); | ||
return Math.round(num * m) / m; | ||
} | ||
51 changes: 51 additions & 0 deletions
51
x-pack/plugins/apm/common/search_strategies/correlations/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
204 changes: 204 additions & 0 deletions
204
x-pack/plugins/apm/public/components/app/correlations/correlations_chart.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
/* | ||
* 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 { max } from 'd3-array'; | ||
|
||
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, | ||
}, | ||
}; | ||
|
||
export function CorrelationsChart({ | ||
field, | ||
value, | ||
histogram, | ||
markerValue, | ||
markerPercentile, | ||
overallHistogram, | ||
}: CorrelationsChartProps) { | ||
const euiTheme = useTheme(); | ||
|
||
if (!Array.isArray(overallHistogram)) return <div />; | ||
const annotationsDataValues: LineAnnotationDatum[] = [ | ||
{ dataValue: markerValue, details: `${markerPercentile}th percentile` }, | ||
]; | ||
|
||
const xMax = max(overallHistogram.map((d) => d.key)) ?? 0; | ||
qn895 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const durationFormatter = getDurationFormatter(xMax); | ||
|
||
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} | ||
/> | ||
{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> | ||
); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like everywhere numbers are formatted to 3 decimal places. In that case, can this be simplified to:
You can add it to this file:
kibana/x-pack/plugins/apm/common/utils/formatters/formatters.ts
Lines 13 to 19 in e580d5a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated here 31973bb