[Metrics UI] Fix EC2 Query to only include aws.ec2 nodes (#78236)
* [Metrics UI] Fix EC2 Query to only include aws.ec2 nodes * Making the filter more generic so we can apply it easily to any inventory model
This commit is contained in:
parent
8ea5c575eb
commit
ca27ec8385
|
@ -31,4 +31,5 @@ export const awsEC2: InventoryModel = {
|
||||||
},
|
},
|
||||||
requiredMetrics: ['awsEC2CpuUtilization', 'awsEC2NetworkTraffic', 'awsEC2DiskIOBytes'],
|
requiredMetrics: ['awsEC2CpuUtilization', 'awsEC2NetworkTraffic', 'awsEC2DiskIOBytes'],
|
||||||
tooltipMetrics: ['cpu', 'rx', 'tx'],
|
tooltipMetrics: ['cpu', 'rx', 'tx'],
|
||||||
|
nodeFilter: [{ term: { 'event.dataset': 'aws.ec2' } }],
|
||||||
};
|
};
|
||||||
|
|
|
@ -371,4 +371,5 @@ export interface InventoryModel {
|
||||||
metrics: InventoryMetrics;
|
metrics: InventoryMetrics;
|
||||||
requiredMetrics: InventoryMetric[];
|
requiredMetrics: InventoryMetric[];
|
||||||
tooltipMetrics: SnapshotMetricType[];
|
tooltipMetrics: SnapshotMetricType[];
|
||||||
|
nodeFilter?: object[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { findInventoryFields } from '../../../../common/inventory_models';
|
import { findInventoryFields, findInventoryModel } from '../../../../common/inventory_models';
|
||||||
import { MetricsAPIRequest, SnapshotRequest } from '../../../../common/http_api';
|
import { MetricsAPIRequest, SnapshotRequest } from '../../../../common/http_api';
|
||||||
import { ESSearchClient } from '../../../lib/metrics/types';
|
import { ESSearchClient } from '../../../lib/metrics/types';
|
||||||
import { InfraSource } from '../../../lib/sources';
|
import { InfraSource } from '../../../lib/sources';
|
||||||
|
@ -52,6 +52,11 @@ export const transformRequestToMetricsAPIRequest = async (
|
||||||
filters.push({ term: { 'cloud.region': snapshotRequest.region } });
|
filters.push({ term: { 'cloud.region': snapshotRequest.region } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const inventoryModel = findInventoryModel(snapshotRequest.nodeType);
|
||||||
|
if (inventoryModel && inventoryModel.nodeFilter) {
|
||||||
|
inventoryModel.nodeFilter?.forEach((f) => filters.push(f));
|
||||||
|
}
|
||||||
|
|
||||||
const inventoryFields = findInventoryFields(
|
const inventoryFields = findInventoryFields(
|
||||||
snapshotRequest.nodeType,
|
snapshotRequest.nodeType,
|
||||||
source.configuration.fields
|
source.configuration.fields
|
||||||
|
|
Loading…
Reference in a new issue