diff --git a/x-pack/plugins/ml/common/util/job_utils.ts b/x-pack/plugins/ml/common/util/job_utils.ts index 39aee735d4ba2..d20ad4a368948 100644 --- a/x-pack/plugins/ml/common/util/job_utils.ts +++ b/x-pack/plugins/ml/common/util/job_utils.ts @@ -78,6 +78,18 @@ export function isTimeSeriesViewDetector(job: CombinedJob, detectorIndex: number ); } +// Returns a flag to indicate whether the specified job is suitable for embedded map viewing. +export function isMappableJob(job: CombinedJob, detectorIndex: number): boolean { + let isMappable = false; + const { detectors } = job.analysis_config; + if (detectorIndex >= 0 && detectorIndex < detectors.length) { + const dtr = detectors[detectorIndex]; + const functionName = dtr.function; + isMappable = functionName === ML_JOB_AGGREGATION.LAT_LONG; + } + return isMappable; +} + // Returns a flag to indicate whether the source data can be plotted in a time // series chart for the specified detector. export function isSourceDataChartableForDetector(job: CombinedJob, detectorIndex: number): boolean { @@ -93,8 +105,7 @@ export function isSourceDataChartableForDetector(job: CombinedJob, detectorIndex // Note that the 'function' field in a record contains what the user entered e.g. 'high_count', // whereas the 'function_description' field holds an ML-built display hint for function e.g. 'count'. isSourceDataChartable = - (mlFunctionToESAggregation(functionName) !== null || - functionName === ML_JOB_AGGREGATION.LAT_LONG) && + mlFunctionToESAggregation(functionName) !== null && dtr.by_field_name !== MLCATEGORY && dtr.partition_field_name !== MLCATEGORY && dtr.over_field_name !== MLCATEGORY; diff --git a/x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_charts_container_service.js b/x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_charts_container_service.js index f9d8fa6726d72..077e60db4760a 100644 --- a/x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_charts_container_service.js +++ b/x-pack/plugins/ml/public/application/explorer/explorer_charts/explorer_charts_container_service.js @@ -22,6 +22,7 @@ import { isSourceDataChartableForDetector, isModelPlotChartableForDetector, isModelPlotEnabled, + isMappableJob, } from '../../../../common/util/job_utils'; import { mlResultsService } from '../../services/results_service'; import { mlJobService } from '../../services/job_service'; @@ -498,7 +499,10 @@ function processRecordsForDisplay(anomalyRecords) { return; } - let isChartable = isSourceDataChartableForDetector(job, record.detector_index); + let isChartable = + isSourceDataChartableForDetector(job, record.detector_index) || + isMappableJob(job, record.detector_index); + if (isChartable === false) { if (isModelPlotChartableForDetector(job, record.detector_index)) { // Check if model plot is enabled for this job. diff --git a/x-pack/plugins/ml/public/application/explorer/explorer_charts/map_config.ts b/x-pack/plugins/ml/public/application/explorer/explorer_charts/map_config.ts index a9ca873d84a56..451fa602315d7 100644 --- a/x-pack/plugins/ml/public/application/explorer/explorer_charts/map_config.ts +++ b/x-pack/plugins/ml/public/application/explorer/explorer_charts/map_config.ts @@ -5,25 +5,26 @@ */ import { FIELD_ORIGIN, STYLE_TYPE } from '../../../../../maps/common/constants'; +import { ANOMALY_THRESHOLD, SEVERITY_COLORS } from '../../../../common'; const FEATURE = 'Feature'; const POINT = 'Point'; const SEVERITY_COLOR_RAMP = [ { - stop: 0, - color: '#8BC8FB', + stop: ANOMALY_THRESHOLD.LOW, + color: SEVERITY_COLORS.WARNING, }, { - stop: 25, - color: '#FDEC25', + stop: ANOMALY_THRESHOLD.MINOR, + color: SEVERITY_COLORS.MINOR, }, { - stop: 50, - color: '#FBA740', + stop: ANOMALY_THRESHOLD.MAJOR, + color: SEVERITY_COLORS.MAJOR, }, { - stop: 75, - color: '#FE5050', + stop: ANOMALY_THRESHOLD.CRITICAL, + color: SEVERITY_COLORS.CRITICAL, }, ]; @@ -102,7 +103,6 @@ export const getMLAnomaliesTypicalLayer = (anomalies: any) => { }; }; -// GEOJSON_FILE type layer does not support source-type to inject custom data for styling export const getMLAnomaliesActualLayer = (anomalies: any) => { return { id: 'anomalies_actual_layer', diff --git a/x-pack/plugins/ml/public/application/explorer/explorer_utils.js b/x-pack/plugins/ml/public/application/explorer/explorer_utils.js index e5d400599036d..4ba9d4ea14f10 100644 --- a/x-pack/plugins/ml/public/application/explorer/explorer_utils.js +++ b/x-pack/plugins/ml/public/application/explorer/explorer_utils.js @@ -17,7 +17,6 @@ import { } from '../../../common/constants/search'; import { getEntityFieldList } from '../../../common/util/anomaly_utils'; import { extractErrorMessage } from '../../../common/util/errors'; -import { ML_JOB_AGGREGATION } from '../../../common/constants/aggregation_types'; import { isSourceDataChartableForDetector, isModelPlotChartableForDetector, @@ -513,8 +512,7 @@ export async function loadAnomaliesTableData( isChartable = isModelPlotEnabled(job, anomaly.detectorIndex, entityFields); } - anomaly.isTimeSeriesViewRecord = - isChartable && anomaly.source?.function !== ML_JOB_AGGREGATION.LAT_LONG; + anomaly.isTimeSeriesViewRecord = isChartable; if (mlJobService.customUrlsByJob[jobId] !== undefined) { anomaly.customUrls = mlJobService.customUrlsByJob[jobId];