Skip to content

Commit

Permalink
[APM] Filter out service nodes if there are no metrics (#86639) (#86872)
Browse files Browse the repository at this point in the history
* filtering out metrics without service.node.name

* filtering out metrics without service.node.name

* addressing pr comments

* fix TS issue
  • Loading branch information
cauemarcondes authored Dec 23, 2020
1 parent 8b02ce1 commit 1920f6a
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions x-pack/plugins/apm/server/lib/service_nodes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { Setup, SetupTimeRange } from '../helpers/setup_request';
import { getServiceNodesProjection } from '../../projections/service_nodes';
import { mergeProjection } from '../../projections/util/merge_projection';
import { SERVICE_NODE_NAME_MISSING } from '../../../common/service_nodes';
import {
METRIC_PROCESS_CPU_PERCENT,
METRIC_JAVA_THREAD_COUNT,
METRIC_JAVA_HEAP_MEMORY_USED,
METRIC_JAVA_NON_HEAP_MEMORY_USED,
METRIC_JAVA_THREAD_COUNT,
METRIC_PROCESS_CPU_PERCENT,
} from '../../../common/elasticsearch_fieldnames';
import { SERVICE_NODE_NAME_MISSING } from '../../../common/service_nodes';
import { getServiceNodesProjection } from '../../projections/service_nodes';
import { mergeProjection } from '../../projections/util/merge_projection';
import { Setup, SetupTimeRange } from '../helpers/setup_request';

const getServiceNodes = async ({
setup,
Expand Down Expand Up @@ -68,15 +68,21 @@ const getServiceNodes = async ({
return [];
}

return response.aggregations.nodes.buckets.map((bucket) => {
return {
return response.aggregations.nodes.buckets
.map((bucket) => ({
name: bucket.key as string,
cpu: bucket.cpu.value,
heapMemory: bucket.heapMemory.value,
nonHeapMemory: bucket.nonHeapMemory.value,
threadCount: bucket.threadCount.value,
};
});
}))
.filter(
(item) =>
item.cpu !== null ||
item.heapMemory !== null ||
item.nonHeapMemory !== null ||
item.threadCount != null
);
};

export { getServiceNodes };

0 comments on commit 1920f6a

Please sign in to comment.