Skip to content

Commit

Permalink
Add in task type to the message
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisronline committed Jun 23, 2021
1 parent 1bb73c5 commit 4321ec8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
16 changes: 14 additions & 2 deletions x-pack/plugins/task_manager/server/lib/log_health_metrics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ describe('logHealthMetrics', () => {
stats: {
runtime: {
value: {
drift_by_type: {
'taskType:test': {
p99: 60000,
},
},
drift: {
p99: 60000,
},
Expand All @@ -206,7 +211,7 @@ describe('logHealthMetrics', () => {
logHealthMetrics(health, logger, config);

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

const secondMessage = JSON.parse(
Expand Down Expand Up @@ -326,7 +331,14 @@ function getMockMonitoredHealth(overrides = {}): MonitoredHealth {
p95: 2500,
p99: 3000,
},
drift_by_type: {},
drift_by_type: {
'taskType:test': {
p50: 1000,
p90: 2000,
p95: 2500,
p99: 3000,
},
},
load: {
p50: 1000,
p90: 2000,
Expand Down
14 changes: 13 additions & 1 deletion x-pack/plugins/task_manager/server/lib/log_health_metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,20 @@ export function logHealthMetrics(
if (
driftInSeconds >= config.monitored_stats_health_verbose_log.warn_delayed_task_start_in_seconds
) {
const taskType = Object.keys(monitoredHealth.stats.runtime?.value.drift_by_type ?? {}).reduce(
(accum: string, typeName) => {
if (
monitoredHealth.stats.runtime?.value.drift_by_type[typeName].p99 ===
monitoredHealth.stats.runtime?.value.drift.p99
) {
accum = typeName;
}
return accum;
},
'unknown'
);
logger.warn(
`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)`
`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)`
);
logLevel = LogLevel.Warn;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ type ResultFrequencySummary = ResultFrequency & {

export interface SummarizedTaskRunStat extends JsonObject {
drift: AveragedStat;
drift_by_type: {
[alertType: string]: AveragedStat;
};
load: AveragedStat;
execution: {
duration: Record<string, AveragedStat>;
Expand Down

0 comments on commit 4321ec8

Please sign in to comment.