From d4b1cf6d393ec11f36bf768f3965eb8cceab5d7d Mon Sep 17 00:00:00 2001 From: Quynh Nguyen Date: Thu, 30 Apr 2020 10:05:13 -0500 Subject: [PATCH 1/5] [ML] Add anomaly job timing stats to Counts & JSON --- .../components/job_details/extract_job_details.js | 10 ++++++++++ .../components/job_details/format_values.js | 15 ++++++++++++++- .../components/job_details/job_details.js | 3 ++- .../plugins/ml/server/models/job_service/jobs.ts | 6 ++---- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/extract_job_details.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/extract_job_details.js index f7b0e726ecc53..fa36a0626d632 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/extract_job_details.js +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/extract_job_details.js @@ -165,6 +165,15 @@ export function extractJobDetails(job) { items: filterObjects(job.model_size_stats).map(formatValues), }; + const jobTimingStats = { + id: 'jobTimingStats', + title: i18n.translate('xpack.ml.jobsList.jobDetails.jobTimingStatsTitle', { + defaultMessage: 'Job timing stats', + }), + position: 'left', + items: filterObjects(job.timing_stats).map(formatValues), + }; + const datafeedTimingStats = { id: 'datafeedTimingStats', title: i18n.translate('xpack.ml.jobsList.jobDetails.datafeedTimingStatsTitle', { @@ -192,6 +201,7 @@ export function extractJobDetails(job) { datafeed, counts, modelSizeStats, + jobTimingStats, datafeedTimingStats, }; } diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/format_values.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/format_values.js index 9984f3be299ae..fb86f242d093c 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/format_values.js +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/format_values.js @@ -16,6 +16,10 @@ function formatData(txt) { return numeral(txt).format(DATA_FORMAT); } +function roundTo3DecimalPlace(value) { + return typeof value === 'number' ? roundToDecimalPlace(value, 3).toLocaleString() : value; +} + export function formatValues([key, value]) { // time switch (key) { @@ -63,7 +67,16 @@ export function formatValues([key, value]) { // numbers rounded to 3 decimal places case 'average_search_time_per_bucket_ms': case 'exponential_average_search_time_per_hour_ms': - value = typeof value === 'number' ? roundToDecimalPlace(value, 3).toLocaleString() : value; + value = roundTo3DecimalPlace(value); + break; + case 'total_bucket_processing_time_ms': + value = roundTo3DecimalPlace(value); + break; + case 'average_bucket_processing_time_ms': + value = roundTo3DecimalPlace(value); + break; + case 'exponential_average_bucket_processing_time_ms': + value = roundTo3DecimalPlace(value); break; default: diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/job_details.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/job_details.js index e3f348ad32b0c..0375997b86bb8 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/job_details.js +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/job_details.js @@ -60,6 +60,7 @@ export class JobDetails extends Component { datafeed, counts, modelSizeStats, + jobTimingStats, datafeedTimingStats, } = extractJobDetails(job); @@ -102,7 +103,7 @@ export class JobDetails extends Component { content: ( ), }, diff --git a/x-pack/plugins/ml/server/models/job_service/jobs.ts b/x-pack/plugins/ml/server/models/job_service/jobs.ts index 6024ecf4925e6..225cd43e411a4 100644 --- a/x-pack/plugins/ml/server/models/job_service/jobs.ts +++ b/x-pack/plugins/ml/server/models/job_service/jobs.ts @@ -328,7 +328,7 @@ export function jobsProvider(callAsCurrentUser: APICaller) { // create jobs objects containing job stats, datafeeds, datafeed stats and calendars if (jobResults && jobResults.jobs) { jobResults.jobs.forEach(job => { - const tempJob = job as CombinedJobWithStats; + let tempJob = job as CombinedJobWithStats; const calendars: string[] = [ ...(calendarsByJobId[tempJob.job_id] || []), @@ -341,9 +341,7 @@ export function jobsProvider(callAsCurrentUser: APICaller) { if (jobStatsResults && jobStatsResults.jobs) { const jobStats = jobStatsResults.jobs.find(js => js.job_id === tempJob.job_id); if (jobStats !== undefined) { - tempJob.state = jobStats.state; - tempJob.data_counts = jobStats.data_counts; - tempJob.model_size_stats = jobStats.model_size_stats; + tempJob = { ...tempJob, ...jobStats }; if (jobStats.node) { tempJob.node = jobStats.node; } From 57a8610b58e0797d2b0e241942907f5387b0e2be Mon Sep 17 00:00:00 2001 From: Quynh Nguyen Date: Wed, 6 May 2020 13:19:26 -0500 Subject: [PATCH 2/5] [ML] Remove roundTo3DecimalPlace and clean up --- .../components/job_details/format_values.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/format_values.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/format_values.js index fb86f242d093c..5c3aa4c5a9c3a 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/format_values.js +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/format_values.js @@ -16,10 +16,6 @@ function formatData(txt) { return numeral(txt).format(DATA_FORMAT); } -function roundTo3DecimalPlace(value) { - return typeof value === 'number' ? roundToDecimalPlace(value, 3).toLocaleString() : value; -} - export function formatValues([key, value]) { // time switch (key) { @@ -67,16 +63,12 @@ export function formatValues([key, value]) { // numbers rounded to 3 decimal places case 'average_search_time_per_bucket_ms': case 'exponential_average_search_time_per_hour_ms': - value = roundTo3DecimalPlace(value); - break; case 'total_bucket_processing_time_ms': - value = roundTo3DecimalPlace(value); - break; case 'average_bucket_processing_time_ms': - value = roundTo3DecimalPlace(value); - break; case 'exponential_average_bucket_processing_time_ms': - value = roundTo3DecimalPlace(value); + case 'exponential_average_bucket_processing_time_ms': + case 'exponential_average_bucket_processing_time_per_hour_ms': + return typeof value === 'number' ? roundToDecimalPlace(value, 3).toLocaleString() : value; break; default: From d828877d7f00f56ad7b51683bc026762a1f719c4 Mon Sep 17 00:00:00 2001 From: Quynh Nguyen Date: Thu, 7 May 2020 09:23:23 -0500 Subject: [PATCH 3/5] [ML] Fix format_values to round decimals for time values --- .../jobs/jobs_list/components/job_details/format_values.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/format_values.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/format_values.js index 5c3aa4c5a9c3a..246a476517ace 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/format_values.js +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/format_values.js @@ -64,11 +64,12 @@ export function formatValues([key, value]) { case 'average_search_time_per_bucket_ms': case 'exponential_average_search_time_per_hour_ms': case 'total_bucket_processing_time_ms': + case 'minimum_bucket_processing_time_ms': + case 'maximum_bucket_processing_time_ms': case 'average_bucket_processing_time_ms': case 'exponential_average_bucket_processing_time_ms': - case 'exponential_average_bucket_processing_time_ms': case 'exponential_average_bucket_processing_time_per_hour_ms': - return typeof value === 'number' ? roundToDecimalPlace(value, 3).toLocaleString() : value; + value = typeof value === 'number' ? roundToDecimalPlace(value, 3).toLocaleString() : value; break; default: From 9e97dd9f8bb2c0f3fd3c79849509d6f4289d852b Mon Sep 17 00:00:00 2001 From: Quynh Nguyen Date: Thu, 7 May 2020 11:13:14 -0500 Subject: [PATCH 4/5] [ML] Remove timing_stats and forecast_stats from cloneJob --- .../ml/public/application/jobs/jobs_list/components/utils.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js index 1f2a57f999775..1cf01fbd6a8df 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { each } from 'lodash'; +import { each, omit } from 'lodash'; import { mlMessageBarService } from '../../../components/messagebar'; import rison from 'rison-node'; @@ -173,7 +173,8 @@ function showResults(resp, action) { export async function cloneJob(jobId) { try { - const job = await loadFullJob(jobId); + let job = await loadFullJob(jobId); + job = omit(job, ['timing_stats', 'forecasts_stats']); if (job.custom_settings && job.custom_settings.created_by) { // if the job is from a wizards, i.e. contains a created_by property // use tempJobCloningObjects to temporarily store the job From a65cc4f18c3800fb67ac9c120897d342b994c0a0 Mon Sep 17 00:00:00 2001 From: Quynh Nguyen Date: Thu, 7 May 2020 11:52:45 -0500 Subject: [PATCH 5/5] [ML] Remove timing_stats & forecasts in job_service instead of utils --- .../ml/public/application/jobs/jobs_list/components/utils.js | 5 ++--- x-pack/plugins/ml/public/application/services/job_service.js | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js index 1cf01fbd6a8df..1f2a57f999775 100644 --- a/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js +++ b/x-pack/plugins/ml/public/application/jobs/jobs_list/components/utils.js @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { each, omit } from 'lodash'; +import { each } from 'lodash'; import { mlMessageBarService } from '../../../components/messagebar'; import rison from 'rison-node'; @@ -173,8 +173,7 @@ function showResults(resp, action) { export async function cloneJob(jobId) { try { - let job = await loadFullJob(jobId); - job = omit(job, ['timing_stats', 'forecasts_stats']); + const job = await loadFullJob(jobId); if (job.custom_settings && job.custom_settings.created_by) { // if the job is from a wizards, i.e. contains a created_by property // use tempJobCloningObjects to temporarily store the job diff --git a/x-pack/plugins/ml/public/application/services/job_service.js b/x-pack/plugins/ml/public/application/services/job_service.js index bbfec49ac1388..fb75476c48fa3 100644 --- a/x-pack/plugins/ml/public/application/services/job_service.js +++ b/x-pack/plugins/ml/public/application/services/job_service.js @@ -369,6 +369,8 @@ class JobService { delete tempJob.open_time; delete tempJob.established_model_memory; delete tempJob.calendars; + delete tempJob.timing_stats; + delete tempJob.forecasts_stats; delete tempJob.analysis_config.use_per_partition_normalization;