mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[ML] AIOPs: Fixing log pattern analysis sparklines and chart (#168337)
Fixing two issues with the log pattern analysis charts: Occasionally the count of docs in a category can be slightly greater than the doc count which causes the chart to render negative values when hovering over a category in the table. Broken:  Fixed:  --- The sparkles were incorrectly not subtracting the difference from the doc count. So they always rendered the pattern count on top of the doc count. Broken:  Fixed: 
This commit is contained in:
parent
c2e5ea5502
commit
b5bf4a186c
2 changed files with 19 additions and 9 deletions
|
@ -135,12 +135,18 @@ export const CategoryTable: FC<Props> = ({
|
|||
if (sparkLine === undefined) {
|
||||
return null;
|
||||
}
|
||||
const histogram = eventRate.map((e) => ({
|
||||
doc_count_overall: e.docCount,
|
||||
doc_count_significant_term: sparkLine[e.key],
|
||||
key: e.key,
|
||||
key_as_string: `${e.key}`,
|
||||
}));
|
||||
const histogram = eventRate.map(({ key: catKey, docCount }) => {
|
||||
const term = sparkLine[catKey] ?? 0;
|
||||
const newTerm = term > docCount ? docCount : term;
|
||||
const adjustedDocCount = docCount - newTerm;
|
||||
|
||||
return {
|
||||
doc_count_overall: adjustedDocCount,
|
||||
doc_count_significant_term: newTerm,
|
||||
key: catKey,
|
||||
key_as_string: `${catKey}`,
|
||||
};
|
||||
});
|
||||
|
||||
return (
|
||||
<MiniHistogram
|
||||
|
|
|
@ -49,8 +49,10 @@ export const DocumentCountChart: FC<Props> = ({
|
|||
return eventRate.map(({ key, docCount }) => {
|
||||
let value = docCount;
|
||||
if (category && sparkLines[category.key] && sparkLines[category.key][key]) {
|
||||
value -= sparkLines[category.key][key];
|
||||
const val = sparkLines[category.key][key];
|
||||
value = val > docCount ? 0 : docCount - val;
|
||||
}
|
||||
|
||||
return { time: key, value };
|
||||
});
|
||||
}, [eventRate, pinnedCategory, selectedCategory, sparkLines]);
|
||||
|
@ -58,11 +60,13 @@ export const DocumentCountChart: FC<Props> = ({
|
|||
const chartPointsSplit = useMemo(() => {
|
||||
const category = selectedCategory ?? pinnedCategory ?? null;
|
||||
return category !== null
|
||||
? eventRate.map(({ key }) => {
|
||||
const value =
|
||||
? eventRate.map(({ key, docCount }) => {
|
||||
const val =
|
||||
sparkLines && sparkLines[category.key] && sparkLines[category.key][key]
|
||||
? sparkLines[category.key][key]
|
||||
: 0;
|
||||
const value = val > docCount ? docCount : val;
|
||||
|
||||
return { time: key, value };
|
||||
})
|
||||
: undefined;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue