From f9d9481924bacfd6c76250ec96e3842f84cf8e37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20C=C3=B4t=C3=A9?= Date: Fri, 13 Sep 2024 11:51:47 -0400 Subject: [PATCH] Fix bug in overdue task metric script (#192863) Fixing a bug from https://github.com/elastic/kibana/pull/192603 where tasks in idle wouldn't show up in overdue metrics. ## To verify 1. Set `xpack.task_manager.unsafe.exclude_task_types: ['actions:*']` in your kibana.yml 2. Startup Elasticsearch and Kibana 3. Create an always firing rule that logs a server log message 4. Observe the metrics endpoint `/api/task_manager/metrics` and that the overdue metrics overall, for actions and for server log increase over time because the task is skipped (cherry picked from commit 1854acd557531501ed600204ac766c5670c29f38) --- .../task_manager/server/metrics/task_metrics_collector.test.ts | 2 +- .../task_manager/server/metrics/task_metrics_collector.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/task_manager/server/metrics/task_metrics_collector.test.ts b/x-pack/plugins/task_manager/server/metrics/task_metrics_collector.test.ts index 07ab063b7c980..699cbc8a2d83a 100644 --- a/x-pack/plugins/task_manager/server/metrics/task_metrics_collector.test.ts +++ b/x-pack/plugins/task_manager/server/metrics/task_metrics_collector.test.ts @@ -151,7 +151,7 @@ describe('TaskManagerMetricsCollector', () => { return; } - if(taskStatus == 'idle') { + if(taskStatus.value == 'idle') { emit((new Date().getTime() - runAt.value.getMillis()) / 1000); } else { def retryAt = doc['task.retryAt']; diff --git a/x-pack/plugins/task_manager/server/metrics/task_metrics_collector.ts b/x-pack/plugins/task_manager/server/metrics/task_metrics_collector.ts index a35bb5ddf5a72..75b8a8beec5e8 100644 --- a/x-pack/plugins/task_manager/server/metrics/task_metrics_collector.ts +++ b/x-pack/plugins/task_manager/server/metrics/task_metrics_collector.ts @@ -110,7 +110,7 @@ export class TaskManagerMetricsCollector implements ITaskEventEmitter