mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
# Backport This will backport the following commits from `main` to `8.11`: - [[Fleet] Fix agent metrics aggregation for > 10 agents (#172016)](https://github.com/elastic/kibana/pull/172016) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Nicolas Chaulet","email":"nicolas.chaulet@elastic.co"},"sourceCommit":{"committedDate":"2023-11-27T22:26:51Z","message":"[Fleet] Fix agent metrics aggregation for > 10 agents (#172016)\n\n## Summary\n\nTo compute agent metrics we do a term aggregation there was an error as\nwe were not specifying size it was only fetching 10 items for that\naggregation resolving in incomplete results\n\n## Release note\n\nFix agents metrics retrieval on the agent list page, that was displaying\nN/A for agent with metrics for users with more than 10 agents.\n\n## Example \n### Before \n<img width=\"557\" alt=\"Screenshot 2023-11-27 at 2 20 57 PM\"\nsrc=\"d7928238
-011a-4503-87e7-a39b50a98b50\">\n\n### After\n<img width=\"588\" alt=\"Screenshot 2023-11-27 at 2 21 29 PM\"\nsrc=\"6c9c2101
-9cba-421d-ae13-a9b5ad892798\">\n\n\n## Tests\n\nIt seems adding automated tests for that issue to the existing test is\nnot trivial, not sure if it really add value to test that.\n\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>","sha":"2cfc72240383a909b537677b7a73bebee67eb8b9","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:Fleet","backport:prev-minor","v8.12.0"],"number":172016,"url":"https://github.com/elastic/kibana/pull/172016","mergeCommit":{"message":"[Fleet] Fix agent metrics aggregation for > 10 agents (#172016)\n\n## Summary\n\nTo compute agent metrics we do a term aggregation there was an error as\nwe were not specifying size it was only fetching 10 items for that\naggregation resolving in incomplete results\n\n## Release note\n\nFix agents metrics retrieval on the agent list page, that was displaying\nN/A for agent with metrics for users with more than 10 agents.\n\n## Example \n### Before \n<img width=\"557\" alt=\"Screenshot 2023-11-27 at 2 20 57 PM\"\nsrc=\"d7928238
-011a-4503-87e7-a39b50a98b50\">\n\n### After\n<img width=\"588\" alt=\"Screenshot 2023-11-27 at 2 21 29 PM\"\nsrc=\"6c9c2101
-9cba-421d-ae13-a9b5ad892798\">\n\n\n## Tests\n\nIt seems adding automated tests for that issue to the existing test is\nnot trivial, not sure if it really add value to test that.\n\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>","sha":"2cfc72240383a909b537677b7a73bebee67eb8b9"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/172016","number":172016,"mergeCommit":{"message":"[Fleet] Fix agent metrics aggregation for > 10 agents (#172016)\n\n## Summary\n\nTo compute agent metrics we do a term aggregation there was an error as\nwe were not specifying size it was only fetching 10 items for that\naggregation resolving in incomplete results\n\n## Release note\n\nFix agents metrics retrieval on the agent list page, that was displaying\nN/A for agent with metrics for users with more than 10 agents.\n\n## Example \n### Before \n<img width=\"557\" alt=\"Screenshot 2023-11-27 at 2 20 57 PM\"\nsrc=\"d7928238
-011a-4503-87e7-a39b50a98b50\">\n\n### After\n<img width=\"588\" alt=\"Screenshot 2023-11-27 at 2 21 29 PM\"\nsrc=\"6c9c2101
-9cba-421d-ae13-a9b5ad892798\">\n\n\n## Tests\n\nIt seems adding automated tests for that issue to the existing test is\nnot trivial, not sure if it really add value to test that.\n\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>","sha":"2cfc72240383a909b537677b7a73bebee67eb8b9"}}]}] BACKPORT--> Co-authored-by: Nicolas Chaulet <nicolas.chaulet@elastic.co>
This commit is contained in:
parent
75cdadff54
commit
ae1f93c75e
1 changed files with 4 additions and 0 deletions
|
@ -11,6 +11,8 @@ import type { Agent } from '../../types';
|
|||
import { appContextService } from '../app_context';
|
||||
import { DATA_TIERS } from '../../../common/constants';
|
||||
|
||||
const AGGREGATION_MAX_SIZE = 1000;
|
||||
|
||||
export async function fetchAndAssignAgentMetrics(esClient: ElasticsearchClient, agents: Agent[]) {
|
||||
try {
|
||||
return await _fetchAndAssignAgentMetrics(esClient, agents);
|
||||
|
@ -112,6 +114,7 @@ const aggregationQueryBuilder = (agentIds: string[]) => ({
|
|||
agents: {
|
||||
terms: {
|
||||
field: 'elastic_agent.id',
|
||||
size: AGGREGATION_MAX_SIZE,
|
||||
},
|
||||
aggs: {
|
||||
sum_memory_size: {
|
||||
|
@ -127,6 +130,7 @@ const aggregationQueryBuilder = (agentIds: string[]) => ({
|
|||
processes: {
|
||||
terms: {
|
||||
field: 'elastic_agent.process',
|
||||
size: AGGREGATION_MAX_SIZE,
|
||||
order: {
|
||||
_count: 'desc',
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue