Skip to content

Commit

Permalink
[ML] Add job timing stats to anomaly jobs (elastic#65696)
Browse files Browse the repository at this point in the history
* [ML] Add anomaly job timing stats to Counts & JSON

* [ML] Remove roundTo3DecimalPlace and clean up

* [ML] Fix format_values to round decimals for time values

* [ML] Remove timing_stats and forecast_stats from cloneJob

* [ML] Remove timing_stats & forecasts in job_service instead of utils
  • Loading branch information
qn895 committed May 8, 2020
1 parent e7bbb7d commit 9a53c32
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down Expand Up @@ -192,6 +201,7 @@ export function extractJobDetails(job) {
datafeed,
counts,
modelSizeStats,
jobTimingStats,
datafeedTimingStats,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +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':
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_per_hour_ms':
value = typeof value === 'number' ? roundToDecimalPlace(value, 3).toLocaleString() : value;
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class JobDetails extends Component {
datafeed,
counts,
modelSizeStats,
jobTimingStats,
datafeedTimingStats,
} = extractJobDetails(job);

Expand Down Expand Up @@ -102,7 +103,7 @@ export class JobDetails extends Component {
content: (
<JobDetailsPane
data-test-subj="mlJobDetails-counts"
sections={[counts, modelSizeStats]}
sections={[counts, modelSizeStats, jobTimingStats]}
/>
),
},
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/ml/public/application/services/job_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 2 additions & 4 deletions x-pack/plugins/ml/server/models/job_service/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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] || []),
Expand All @@ -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;
}
Expand Down

0 comments on commit 9a53c32

Please sign in to comment.