Skip to content

Commit 1196dd1

Browse files
committed
[ML] Add anomaly job timing stats to Counts & JSON
1 parent a32d7b1 commit 1196dd1

4 files changed

Lines changed: 28 additions & 6 deletions

File tree

x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/extract_job_details.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,15 @@ export function extractJobDetails(job) {
165165
items: filterObjects(job.model_size_stats).map(formatValues),
166166
};
167167

168+
const jobTimingStats = {
169+
id: 'jobTimingStats',
170+
title: i18n.translate('xpack.ml.jobsList.jobDetails.jobTimingStatsTitle', {
171+
defaultMessage: 'Job timing stats',
172+
}),
173+
position: 'left',
174+
items: filterObjects(job.timing_stats).map(formatValues),
175+
};
176+
168177
const datafeedTimingStats = {
169178
id: 'datafeedTimingStats',
170179
title: i18n.translate('xpack.ml.jobsList.jobDetails.datafeedTimingStatsTitle', {
@@ -192,6 +201,7 @@ export function extractJobDetails(job) {
192201
datafeed,
193202
counts,
194203
modelSizeStats,
204+
jobTimingStats,
195205
datafeedTimingStats,
196206
};
197207
}

x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/format_values.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ function formatData(txt) {
1616
return numeral(txt).format(DATA_FORMAT);
1717
}
1818

19+
function roundTo3DecimalPlace(value) {
20+
return typeof value === 'number' ? roundToDecimalPlace(value, 3).toLocaleString() : value;
21+
}
22+
1923
export function formatValues([key, value]) {
2024
// time
2125
switch (key) {
@@ -63,7 +67,16 @@ export function formatValues([key, value]) {
6367
// numbers rounded to 3 decimal places
6468
case 'average_search_time_per_bucket_ms':
6569
case 'exponential_average_search_time_per_hour_ms':
66-
value = typeof value === 'number' ? roundToDecimalPlace(value, 3).toLocaleString() : value;
70+
value = roundTo3DecimalPlace(value);
71+
break;
72+
case 'total_bucket_processing_time_ms':
73+
value = roundTo3DecimalPlace(value);
74+
break;
75+
case 'average_bucket_processing_time_ms':
76+
value = roundTo3DecimalPlace(value);
77+
break;
78+
case 'exponential_average_bucket_processing_time_ms':
79+
value = roundTo3DecimalPlace(value);
6780
break;
6881

6982
default:

x-pack/plugins/ml/public/application/jobs/jobs_list/components/job_details/job_details.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export class JobDetails extends Component {
6060
datafeed,
6161
counts,
6262
modelSizeStats,
63+
jobTimingStats,
6364
datafeedTimingStats,
6465
} = extractJobDetails(job);
6566

@@ -102,7 +103,7 @@ export class JobDetails extends Component {
102103
content: (
103104
<JobDetailsPane
104105
data-test-subj="mlJobDetails-counts"
105-
sections={[counts, modelSizeStats]}
106+
sections={[counts, modelSizeStats, jobTimingStats]}
106107
/>
107108
),
108109
},

x-pack/plugins/ml/server/models/job_service/jobs.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ export function jobsProvider(callAsCurrentUser: APICaller) {
328328
// create jobs objects containing job stats, datafeeds, datafeed stats and calendars
329329
if (jobResults && jobResults.jobs) {
330330
jobResults.jobs.forEach(job => {
331-
const tempJob = job as CombinedJobWithStats;
331+
let tempJob = job as CombinedJobWithStats;
332332

333333
const calendars: string[] = [
334334
...(calendarsByJobId[tempJob.job_id] || []),
@@ -341,9 +341,7 @@ export function jobsProvider(callAsCurrentUser: APICaller) {
341341
if (jobStatsResults && jobStatsResults.jobs) {
342342
const jobStats = jobStatsResults.jobs.find(js => js.job_id === tempJob.job_id);
343343
if (jobStats !== undefined) {
344-
tempJob.state = jobStats.state;
345-
tempJob.data_counts = jobStats.data_counts;
346-
tempJob.model_size_stats = jobStats.model_size_stats;
344+
tempJob = { ...tempJob, ...jobStats };
347345
if (jobStats.node) {
348346
tempJob.node = jobStats.node;
349347
}

0 commit comments

Comments
 (0)