mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
This commit is contained in:
parent
050b9a4b3d
commit
063c1ec27f
4 changed files with 6 additions and 66 deletions
|
@ -11,7 +11,6 @@ import {
|
|||
getSeverity,
|
||||
getSeverityWithLow,
|
||||
getSeverityColor,
|
||||
labelDuplicateDetectorDescriptions,
|
||||
getEntityFieldName,
|
||||
getEntityFieldValue,
|
||||
showActualForFunction,
|
||||
|
@ -282,24 +281,6 @@ describe('ML - anomaly utils', () => {
|
|||
|
||||
});
|
||||
|
||||
describe('labelDuplicateDetectorDescriptions', () => {
|
||||
const detectorsByJob = {
|
||||
'job1': ['detector1', 'detector2'],
|
||||
'job2': ['detector1', 'detector3']
|
||||
};
|
||||
const result = labelDuplicateDetectorDescriptions(detectorsByJob);
|
||||
|
||||
it('appends the job ID for detectors with identical descriptions to those in other jobs', () => {
|
||||
expect(result.job1[0]).to.be('detector1 (job1)');
|
||||
expect(result.job2[0]).to.be('detector1 (job2)');
|
||||
});
|
||||
|
||||
it('leaves description unchanged for detectors with different descriptions to those in other jobs', () => {
|
||||
expect(result.job1[1]).to.be('detector2');
|
||||
expect(result.job2[1]).to.be('detector3');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getEntityFieldName', () => {
|
||||
it('returns the by field name', () => {
|
||||
expect(getEntityFieldName(byEntityRecord)).to.be('airline');
|
||||
|
|
|
@ -75,30 +75,6 @@ export function getSeverityColor(normalizedScore) {
|
|||
}
|
||||
}
|
||||
|
||||
// Recurses through an object holding the list of detector descriptions against job IDs
|
||||
// checking for duplicate descriptions. For any detectors with duplicate descriptions, the
|
||||
// description is modified by appending the job ID in parentheses.
|
||||
// Only checks for duplicates across jobs; any duplicates within a job are left as-is.
|
||||
export function labelDuplicateDetectorDescriptions(detectorsByJob) {
|
||||
const checkedJobIds = [];
|
||||
_.each(detectorsByJob, function (detectors, jobId) {
|
||||
checkedJobIds.push(jobId);
|
||||
const otherJobs = _.omit(detectorsByJob, checkedJobIds);
|
||||
_.each(detectors, function (description, i) {
|
||||
_.each(otherJobs, function (otherJobDetectors, otherJobId) {
|
||||
_.each(otherJobDetectors, function (otherDescription, j) {
|
||||
if (description === otherDescription) {
|
||||
detectors[i] = description + ' (' + jobId + ')';
|
||||
otherJobDetectors[j] = description + ' (' + otherJobId + ')';
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return detectorsByJob;
|
||||
}
|
||||
|
||||
// Returns the name of the field to use as the entity name from the source record
|
||||
// obtained from Elasticsearch. The function looks first for a by_field, then over_field,
|
||||
// then partition_field, returning undefined if none of these fields are present.
|
||||
|
|
|
@ -37,10 +37,10 @@ export function ExplorerChartsContainer({
|
|||
<div className={`ml-explorer-chart-container col-md-${layoutCellsPerChart}`} key={id}>
|
||||
<div className="explorer-chart-label">
|
||||
<div className="explorer-chart-label-fields">
|
||||
{(entityFields.length > 0) && (
|
||||
{(detectorLabel.length > 0 && entityFields.length > 0) && (
|
||||
<span>{detectorLabel} - </span>
|
||||
)}
|
||||
{(entityFields.length === 0) && (
|
||||
{(detectorLabel.length > 0 && entityFields.length === 0) && (
|
||||
<span>{detectorLabel}</span>
|
||||
)}
|
||||
{entityFields.map((entity, j) => {
|
||||
|
|
|
@ -13,7 +13,6 @@ import moment from 'moment';
|
|||
import { parseInterval } from 'ui/utils/parse_interval';
|
||||
import { ml } from './ml_api_service';
|
||||
|
||||
import { labelDuplicateDetectorDescriptions } from '../../common/util/anomaly_utils';
|
||||
import { mlMessageBarService } from '../components/messagebar/messagebar_service';
|
||||
import { isWebUrl } from '../util/string_utils';
|
||||
import { ML_DATA_PREVIEW_COUNT } from '../../common/util/job_utils';
|
||||
|
@ -1009,12 +1008,11 @@ function checkSaveResponse(resp, origJob) {
|
|||
|
||||
function processBasicJobInfo(localJobService, jobsList) {
|
||||
// Process the list of job data obtained from the jobs endpoint to return
|
||||
// an array of objects containing the basic information (id, description, bucketSpan, detectors
|
||||
// and detectorDescriptions properties, plus a customUrls key if custom URLs
|
||||
// an array of objects containing the basic information (id, description, bucketSpan,
|
||||
// and detectors properties, plus a customUrls key if custom URLs
|
||||
// have been configured for the job) used by various result dashboards in the ml plugin.
|
||||
// The key information is stored in the jobService object for quick access.
|
||||
const processedJobsList = [];
|
||||
let detectorDescriptionsByJob = {};
|
||||
const detectorsByJob = {};
|
||||
const customUrlsByJob = {};
|
||||
|
||||
|
@ -1037,15 +1035,8 @@ function processBasicJobInfo(localJobService, jobsList) {
|
|||
job.description = jobObj.job_id;
|
||||
}
|
||||
|
||||
job.detectorDescriptions = [];
|
||||
job.detectors = [];
|
||||
const detectors = _.get(analysisConfig, 'detectors', []);
|
||||
_.each(detectors, (detector)=> {
|
||||
if (_.has(detector, 'detector_description')) {
|
||||
job.detectorDescriptions.push(detector.detector_description);
|
||||
job.detectors.push(detector);
|
||||
}
|
||||
});
|
||||
job.detectors = _.get(analysisConfig, 'detectors', []);
|
||||
detectorsByJob[job.id] = job.detectors;
|
||||
|
||||
|
||||
if (_.has(jobObj, 'custom_settings.custom_urls')) {
|
||||
|
@ -1063,18 +1054,10 @@ function processBasicJobInfo(localJobService, jobsList) {
|
|||
}
|
||||
|
||||
localJobService.jobDescriptions[job.id] = job.description;
|
||||
detectorDescriptionsByJob[job.id] = job.detectorDescriptions;
|
||||
detectorsByJob[job.id] = job.detectors;
|
||||
localJobService.basicJobs[job.id] = job;
|
||||
processedJobsList.push(job);
|
||||
});
|
||||
|
||||
detectorDescriptionsByJob = labelDuplicateDetectorDescriptions(detectorDescriptionsByJob);
|
||||
_.each(detectorsByJob, (dtrs, jobId) => {
|
||||
_.each(dtrs, (dtr, i) => {
|
||||
dtr.detector_description = detectorDescriptionsByJob[jobId][i];
|
||||
});
|
||||
});
|
||||
localJobService.detectorsByJob = detectorsByJob;
|
||||
localJobService.customUrlsByJob = customUrlsByJob;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue