Skip to content

Commit 4321ec8

Browse files
committed
Add in task type to the message
1 parent 1bb73c5 commit 4321ec8

3 files changed

Lines changed: 30 additions & 3 deletions

File tree

x-pack/plugins/task_manager/server/lib/log_health_metrics.test.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ describe('logHealthMetrics', () => {
195195
stats: {
196196
runtime: {
197197
value: {
198+
drift_by_type: {
199+
'taskType:test': {
200+
p99: 60000,
201+
},
202+
},
198203
drift: {
199204
p99: 60000,
200205
},
@@ -206,7 +211,7 @@ describe('logHealthMetrics', () => {
206211
logHealthMetrics(health, logger, config);
207212

208213
expect((logger as jest.Mocked<Logger>).warn.mock.calls[0][0] as string).toBe(
209-
`Detected delay task start of 60s (which exceeds configured value of 60s)`
214+
`Detected delay task start of 60s for task \"taskType:test\" (which exceeds configured value of 60s)`
210215
);
211216

212217
const secondMessage = JSON.parse(
@@ -326,7 +331,14 @@ function getMockMonitoredHealth(overrides = {}): MonitoredHealth {
326331
p95: 2500,
327332
p99: 3000,
328333
},
329-
drift_by_type: {},
334+
drift_by_type: {
335+
'taskType:test': {
336+
p50: 1000,
337+
p90: 2000,
338+
p95: 2500,
339+
p99: 3000,
340+
},
341+
},
330342
load: {
331343
p50: 1000,
332344
p90: 2000,

x-pack/plugins/task_manager/server/lib/log_health_metrics.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,20 @@ export function logHealthMetrics(
4949
if (
5050
driftInSeconds >= config.monitored_stats_health_verbose_log.warn_delayed_task_start_in_seconds
5151
) {
52+
const taskType = Object.keys(monitoredHealth.stats.runtime?.value.drift_by_type ?? {}).reduce(
53+
(accum: string, typeName) => {
54+
if (
55+
monitoredHealth.stats.runtime?.value.drift_by_type[typeName].p99 ===
56+
monitoredHealth.stats.runtime?.value.drift.p99
57+
) {
58+
accum = typeName;
59+
}
60+
return accum;
61+
},
62+
'unknown'
63+
);
5264
logger.warn(
53-
`Detected delay task start of ${driftInSeconds}s (which exceeds configured value of ${config.monitored_stats_health_verbose_log.warn_delayed_task_start_in_seconds}s)`
65+
`Detected delay task start of ${driftInSeconds}s for task "${taskType}" (which exceeds configured value of ${config.monitored_stats_health_verbose_log.warn_delayed_task_start_in_seconds}s)`
5466
);
5567
logLevel = LogLevel.Warn;
5668
}

x-pack/plugins/task_manager/server/monitoring/task_run_statistics.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ type ResultFrequencySummary = ResultFrequency & {
103103

104104
export interface SummarizedTaskRunStat extends JsonObject {
105105
drift: AveragedStat;
106+
drift_by_type: {
107+
[alertType: string]: AveragedStat;
108+
};
106109
load: AveragedStat;
107110
execution: {
108111
duration: Record<string, AveragedStat>;

0 commit comments

Comments
 (0)