mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
# Backport This will backport the following commits from `main` to `8.11`: - [[ML] Fix anomaly charts when partition field contains an empty string (#168102)](https://github.com/elastic/kibana/pull/168102) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Dima Arnautov","email":"dmitrii.arnautov@elastic.co"},"sourceCommit":{"committedDate":"2023-10-06T07:49:25Z","message":"[ML] Fix anomaly charts when partition field contains an empty string (#168102)\n\n## Summary\r\n\r\nFixes #168067.\r\n\r\nFixes anomaly charts fetching by replacing logical OR operator with\r\nnullish coalescing.\r\n\r\n\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"efa4e76203a1c20977994559b0e57c09d7751310","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix",":ml","Feature:Anomaly Detection","Team:ML","v8.11.0","v8.12.0"],"number":168102,"url":"https://github.com/elastic/kibana/pull/168102","mergeCommit":{"message":"[ML] Fix anomaly charts when partition field contains an empty string (#168102)\n\n## Summary\r\n\r\nFixes #168067.\r\n\r\nFixes anomaly charts fetching by replacing logical OR operator with\r\nnullish coalescing.\r\n\r\n\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"efa4e76203a1c20977994559b0e57c09d7751310"}},"sourceBranch":"main","suggestedTargetBranches":["8.11"],"targetPullRequestStates":[{"branch":"8.11","label":"v8.11.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/168102","number":168102,"mergeCommit":{"message":"[ML] Fix anomaly charts when partition field contains an empty string (#168102)\n\n## Summary\r\n\r\nFixes #168067.\r\n\r\nFixes anomaly charts fetching by replacing logical OR operator with\r\nnullish coalescing.\r\n\r\n\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [ ] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"efa4e76203a1c20977994559b0e57c09d7751310"}}]}] BACKPORT--> Co-authored-by: Dima Arnautov <dmitrii.arnautov@elastic.co>
This commit is contained in:
parent
2c27c623f4
commit
948f0082e6
1 changed files with 7 additions and 7 deletions
|
@ -526,9 +526,9 @@ export function anomalyChartsDataProvider(mlClient: MlClient, client: IScopedClu
|
|||
|
||||
// TODO - work out how best to display results from detectors with just an over field.
|
||||
const firstFieldName =
|
||||
record.partition_field_name || record.by_field_name || record.over_field_name;
|
||||
record.partition_field_name ?? record.by_field_name ?? record.over_field_name;
|
||||
const firstFieldValue =
|
||||
record.partition_field_value || record.by_field_value || record.over_field_value;
|
||||
record.partition_field_value ?? record.by_field_value ?? record.over_field_value;
|
||||
if (firstFieldName !== undefined && firstFieldValue !== undefined) {
|
||||
const groupsForDetector = detectorsForJob[detectorIndex];
|
||||
|
||||
|
@ -544,7 +544,7 @@ export function anomalyChartsDataProvider(mlClient: MlClient, client: IScopedClu
|
|||
|
||||
let isSecondSplit = false;
|
||||
if (record.partition_field_name !== undefined) {
|
||||
const splitFieldName = record.over_field_name || record.by_field_name;
|
||||
const splitFieldName = record.over_field_name ?? record.by_field_name;
|
||||
if (splitFieldName !== undefined) {
|
||||
isSecondSplit = true;
|
||||
}
|
||||
|
@ -562,8 +562,8 @@ export function anomalyChartsDataProvider(mlClient: MlClient, client: IScopedClu
|
|||
}
|
||||
} else {
|
||||
// Aggregate another level for the over or by field.
|
||||
const secondFieldName = record.over_field_name || record.by_field_name;
|
||||
const secondFieldValue = record.over_field_value || record.by_field_value;
|
||||
const secondFieldName = record.over_field_name ?? record.by_field_name;
|
||||
const secondFieldValue = record.over_field_value ?? record.by_field_value;
|
||||
|
||||
if (secondFieldName !== undefined && secondFieldValue !== undefined) {
|
||||
if (dataForGroupValue[secondFieldName] === undefined) {
|
||||
|
@ -1044,7 +1044,7 @@ export function anomalyChartsDataProvider(mlClient: MlClient, client: IScopedClu
|
|||
let chartData: ChartPoint[] = [];
|
||||
if (metricData !== undefined) {
|
||||
if (records.length > 0) {
|
||||
const filterField = records[0].by_field_value || records[0].over_field_value;
|
||||
const filterField = records[0].by_field_value ?? records[0].over_field_value;
|
||||
if (eventDistribution && eventDistribution.length > 0) {
|
||||
chartData = eventDistribution.filter((d: { entity: any }) => d.entity !== filterField);
|
||||
}
|
||||
|
@ -1143,7 +1143,7 @@ export function anomalyChartsDataProvider(mlClient: MlClient, client: IScopedClu
|
|||
chartType === CHART_TYPE.POPULATION_DISTRIBUTION
|
||||
) {
|
||||
return chartData.filter((d) => {
|
||||
return d.entity === (record && (record.by_field_value || record.over_field_value));
|
||||
return d.entity === (record && (record.by_field_value ?? record.over_field_value));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue