[8.x] Fix bug in overdue task metric script (#192863) (#192899)

# Backport

This will backport the following commits from `main` to `8.x`:
- [Fix bug in overdue task metric script
(#192863)](https://github.com/elastic/kibana/pull/192863)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Mike
Côté","email":"mikecote@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-09-13T15:51:47Z","message":"Fix
bug in overdue task metric script (#192863)\n\nFixing a bug from
https://github.com/elastic/kibana/pull/192603 where\r\ntasks in idle
wouldn't show up in overdue metrics.\r\n\r\n## To verify\r\n1. Set
`xpack.task_manager.unsafe.exclude_task_types: ['actions:*']` in\r\nyour
kibana.yml\r\n2. Startup Elasticsearch and Kibana\r\n3. Create an always
firing rule that logs a server log message\r\n4. Observe the metrics
endpoint `/api/task_manager/metrics` and that the\r\noverdue metrics
overall, for actions and for server log increase over\r\ntime because
the task is
skipped","sha":"1854acd557531501ed600204ac766c5670c29f38","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Feature:Task
Manager","Team:ResponseOps","v9.0.0","backport:prev-minor","v8.16.0"],"title":"Fix
bug in overdue task metric
script","number":192863,"url":"https://github.com/elastic/kibana/pull/192863","mergeCommit":{"message":"Fix
bug in overdue task metric script (#192863)\n\nFixing a bug from
https://github.com/elastic/kibana/pull/192603 where\r\ntasks in idle
wouldn't show up in overdue metrics.\r\n\r\n## To verify\r\n1. Set
`xpack.task_manager.unsafe.exclude_task_types: ['actions:*']` in\r\nyour
kibana.yml\r\n2. Startup Elasticsearch and Kibana\r\n3. Create an always
firing rule that logs a server log message\r\n4. Observe the metrics
endpoint `/api/task_manager/metrics` and that the\r\noverdue metrics
overall, for actions and for server log increase over\r\ntime because
the task is
skipped","sha":"1854acd557531501ed600204ac766c5670c29f38"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/192863","number":192863,"mergeCommit":{"message":"Fix
bug in overdue task metric script (#192863)\n\nFixing a bug from
https://github.com/elastic/kibana/pull/192603 where\r\ntasks in idle
wouldn't show up in overdue metrics.\r\n\r\n## To verify\r\n1. Set
`xpack.task_manager.unsafe.exclude_task_types: ['actions:*']` in\r\nyour
kibana.yml\r\n2. Startup Elasticsearch and Kibana\r\n3. Create an always
firing rule that logs a server log message\r\n4. Observe the metrics
endpoint `/api/task_manager/metrics` and that the\r\noverdue metrics
overall, for actions and for server log increase over\r\ntime because
the task is
skipped","sha":"1854acd557531501ed600204ac766c5670c29f38"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Mike Côté <mikecote@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2024-09-14 03:20:42 +10:00 committed by GitHub
parent 25d19b0032
commit d858e7d2b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View file

@ -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'];

View file

@ -110,7 +110,7 @@ export class TaskManagerMetricsCollector implements ITaskEventEmitter<TaskLifecy
return;
}
if(taskStatus == 'idle') {
if(taskStatus.value == 'idle') {
emit((new Date().getTime() - runAt.value.getMillis()) / 1000);
} else {
def retryAt = doc['task.retryAt'];