Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] Hook up discovery service to Task Manager health (elastic#194113)…
… (elastic#194685) # Backport This will backport the following commits from `main` to `8.x`: - [Hook up discovery service to Task Manager health (elastic#194113)](elastic#194113) <!--- 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":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-02T11:19:06Z","message":"Hook up discovery service to Task Manager health (elastic#194113)\n\nResolves https://github.com/elastic/kibana/issues/192568\r\n\r\nIn this PR, I'm solving the issue where the task manager health API is\r\nunable to determine how many Kibana nodes are running. I'm doing so by\r\nleveraging the Kibana discovery service to get a count instead of\r\ncalculating it based on an aggregation on the `.kibana_task_manager`\r\nindex where we count the unique number of `ownerId`, which requires\r\ntasks to be running and a sufficient distribution across the Kibana\r\nnodes to determine the number properly.\r\n\r\nNote: This will only work when mget is the task claim strategy\r\n\r\n## To verify\r\n1. Set `xpack.task_manager.claim_strategy: mget` in kibana.yml\r\n2. Startup the PR locally with Elasticsearch and Kibana running\r\n3. Navigate to the `/api/task_manager/_health` route and confirm\r\n`observed_kibana_instances` is `1`\r\n4. Apply the following code and restart Kibana\r\n```\r\ndiff --git a/x-pack/plugins/task_manager/server/kibana_discovery_service/kibana_discovery_service.ts b/x-pack/plugins/task_manager/server/kibana_discovery_service/kibana_discovery_service.ts\r\nindex 090847032bf..69dfb6d1b36 100644\r\n--- a/x-pack/plugins/task_manager/server/kibana_discovery_service/kibana_discovery_service.ts\r\n+++ b/x-pack/plugins/task_manager/server/kibana_discovery_service/kibana_discovery_service.ts\r\n@@ -59,6 +59,7 @@ export class KibanaDiscoveryService {\r\n const lastSeen = lastSeenDate.toISOString();\r\n try {\r\n await this.upsertCurrentNode({ id: this.currentNode, lastSeen });\r\n+ await this.upsertCurrentNode({ id: `${this.currentNode}-2`, lastSeen });\r\n if (!this.started) {\r\n this.logger.info('Kibana Discovery Service has been started');\r\n this.started = true;\r\n```\r\n5. Navigate to the `/api/task_manager/_health` route and confirm\r\n`observed_kibana_instances` is `2`\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"d0d2032f18a37e4c458a26d92092665453b737b0","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","ci:cloud-deploy","v8.16.0"],"title":"Hook up discovery service to Task Manager health","number":194113,"url":"https://github.com/elastic/kibana/pull/194113","mergeCommit":{"message":"Hook up discovery service to Task Manager health (elastic#194113)\n\nResolves https://github.com/elastic/kibana/issues/192568\r\n\r\nIn this PR, I'm solving the issue where the task manager health API is\r\nunable to determine how many Kibana nodes are running. I'm doing so by\r\nleveraging the Kibana discovery service to get a count instead of\r\ncalculating it based on an aggregation on the `.kibana_task_manager`\r\nindex where we count the unique number of `ownerId`, which requires\r\ntasks to be running and a sufficient distribution across the Kibana\r\nnodes to determine the number properly.\r\n\r\nNote: This will only work when mget is the task claim strategy\r\n\r\n## To verify\r\n1. Set `xpack.task_manager.claim_strategy: mget` in kibana.yml\r\n2. Startup the PR locally with Elasticsearch and Kibana running\r\n3. Navigate to the `/api/task_manager/_health` route and confirm\r\n`observed_kibana_instances` is `1`\r\n4. Apply the following code and restart Kibana\r\n```\r\ndiff --git a/x-pack/plugins/task_manager/server/kibana_discovery_service/kibana_discovery_service.ts b/x-pack/plugins/task_manager/server/kibana_discovery_service/kibana_discovery_service.ts\r\nindex 090847032bf..69dfb6d1b36 100644\r\n--- a/x-pack/plugins/task_manager/server/kibana_discovery_service/kibana_discovery_service.ts\r\n+++ b/x-pack/plugins/task_manager/server/kibana_discovery_service/kibana_discovery_service.ts\r\n@@ -59,6 +59,7 @@ export class KibanaDiscoveryService {\r\n const lastSeen = lastSeenDate.toISOString();\r\n try {\r\n await this.upsertCurrentNode({ id: this.currentNode, lastSeen });\r\n+ await this.upsertCurrentNode({ id: `${this.currentNode}-2`, lastSeen });\r\n if (!this.started) {\r\n this.logger.info('Kibana Discovery Service has been started');\r\n this.started = true;\r\n```\r\n5. Navigate to the `/api/task_manager/_health` route and confirm\r\n`observed_kibana_instances` is `2`\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"d0d2032f18a37e4c458a26d92092665453b737b0"}},"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/194113","number":194113,"mergeCommit":{"message":"Hook up discovery service to Task Manager health (elastic#194113)\n\nResolves https://github.com/elastic/kibana/issues/192568\r\n\r\nIn this PR, I'm solving the issue where the task manager health API is\r\nunable to determine how many Kibana nodes are running. I'm doing so by\r\nleveraging the Kibana discovery service to get a count instead of\r\ncalculating it based on an aggregation on the `.kibana_task_manager`\r\nindex where we count the unique number of `ownerId`, which requires\r\ntasks to be running and a sufficient distribution across the Kibana\r\nnodes to determine the number properly.\r\n\r\nNote: This will only work when mget is the task claim strategy\r\n\r\n## To verify\r\n1. Set `xpack.task_manager.claim_strategy: mget` in kibana.yml\r\n2. Startup the PR locally with Elasticsearch and Kibana running\r\n3. Navigate to the `/api/task_manager/_health` route and confirm\r\n`observed_kibana_instances` is `1`\r\n4. Apply the following code and restart Kibana\r\n```\r\ndiff --git a/x-pack/plugins/task_manager/server/kibana_discovery_service/kibana_discovery_service.ts b/x-pack/plugins/task_manager/server/kibana_discovery_service/kibana_discovery_service.ts\r\nindex 090847032bf..69dfb6d1b36 100644\r\n--- a/x-pack/plugins/task_manager/server/kibana_discovery_service/kibana_discovery_service.ts\r\n+++ b/x-pack/plugins/task_manager/server/kibana_discovery_service/kibana_discovery_service.ts\r\n@@ -59,6 +59,7 @@ export class KibanaDiscoveryService {\r\n const lastSeen = lastSeenDate.toISOString();\r\n try {\r\n await this.upsertCurrentNode({ id: this.currentNode, lastSeen });\r\n+ await this.upsertCurrentNode({ id: `${this.currentNode}-2`, lastSeen });\r\n if (!this.started) {\r\n this.logger.info('Kibana Discovery Service has been started');\r\n this.started = true;\r\n```\r\n5. Navigate to the `/api/task_manager/_health` route and confirm\r\n`observed_kibana_instances` is `2`\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"d0d2032f18a37e4c458a26d92092665453b737b0"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Mike Côté <[email protected]>
- Loading branch information