[Metrics UI] Add timerange and sorting to node detail metadata request (#81033)
This commit is contained in:
parent
ab8bf782c3
commit
2a82bddfe2
|
@ -58,7 +58,14 @@ export const initMetadataRoute = (libs: InfraBackendLibs) => {
|
||||||
nameToFeature('metrics')
|
nameToFeature('metrics')
|
||||||
);
|
);
|
||||||
|
|
||||||
const info = await getNodeInfo(framework, requestContext, configuration, nodeId, nodeType);
|
const info = await getNodeInfo(
|
||||||
|
framework,
|
||||||
|
requestContext,
|
||||||
|
configuration,
|
||||||
|
nodeId,
|
||||||
|
nodeType,
|
||||||
|
timeRange
|
||||||
|
);
|
||||||
const cloudInstanceId = get(info, 'cloud.instance.id');
|
const cloudInstanceId = get(info, 'cloud.instance.id');
|
||||||
|
|
||||||
const cloudMetricsMetadata = cloudInstanceId
|
const cloudMetricsMetadata = cloudInstanceId
|
||||||
|
|
|
@ -20,7 +20,8 @@ export const getNodeInfo = async (
|
||||||
requestContext: RequestHandlerContext,
|
requestContext: RequestHandlerContext,
|
||||||
sourceConfiguration: InfraSourceConfiguration,
|
sourceConfiguration: InfraSourceConfiguration,
|
||||||
nodeId: string,
|
nodeId: string,
|
||||||
nodeType: InventoryItemType
|
nodeType: InventoryItemType,
|
||||||
|
timeRange: { from: number; to: number }
|
||||||
): Promise<InfraMetadataInfo> => {
|
): Promise<InfraMetadataInfo> => {
|
||||||
// If the nodeType is a Kubernetes pod then we need to get the node info
|
// If the nodeType is a Kubernetes pod then we need to get the node info
|
||||||
// from a host record instead of a pod. This is due to the fact that any host
|
// from a host record instead of a pod. This is due to the fact that any host
|
||||||
|
@ -33,7 +34,8 @@ export const getNodeInfo = async (
|
||||||
requestContext,
|
requestContext,
|
||||||
sourceConfiguration,
|
sourceConfiguration,
|
||||||
nodeId,
|
nodeId,
|
||||||
nodeType
|
nodeType,
|
||||||
|
timeRange
|
||||||
);
|
);
|
||||||
if (kubernetesNodeName) {
|
if (kubernetesNodeName) {
|
||||||
return getNodeInfo(
|
return getNodeInfo(
|
||||||
|
@ -41,12 +43,14 @@ export const getNodeInfo = async (
|
||||||
requestContext,
|
requestContext,
|
||||||
sourceConfiguration,
|
sourceConfiguration,
|
||||||
kubernetesNodeName,
|
kubernetesNodeName,
|
||||||
'host'
|
'host',
|
||||||
|
timeRange
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
const fields = findInventoryFields(nodeType, sourceConfiguration.fields);
|
const fields = findInventoryFields(nodeType, sourceConfiguration.fields);
|
||||||
|
const timestampField = sourceConfiguration.fields.timestamp;
|
||||||
const params = {
|
const params = {
|
||||||
allowNoIndices: true,
|
allowNoIndices: true,
|
||||||
ignoreUnavailable: true,
|
ignoreUnavailable: true,
|
||||||
|
@ -55,9 +59,21 @@ export const getNodeInfo = async (
|
||||||
body: {
|
body: {
|
||||||
size: 1,
|
size: 1,
|
||||||
_source: ['host.*', 'cloud.*'],
|
_source: ['host.*', 'cloud.*'],
|
||||||
|
sort: [{ [timestampField]: 'desc' }],
|
||||||
query: {
|
query: {
|
||||||
bool: {
|
bool: {
|
||||||
filter: [{ match: { [fields.id]: nodeId } }],
|
filter: [
|
||||||
|
{ match: { [fields.id]: nodeId } },
|
||||||
|
{
|
||||||
|
range: {
|
||||||
|
[timestampField]: {
|
||||||
|
gte: timeRange.from,
|
||||||
|
lte: timeRange.to,
|
||||||
|
format: 'epoch_millis',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -15,9 +15,11 @@ export const getPodNodeName = async (
|
||||||
requestContext: RequestHandlerContext,
|
requestContext: RequestHandlerContext,
|
||||||
sourceConfiguration: InfraSourceConfiguration,
|
sourceConfiguration: InfraSourceConfiguration,
|
||||||
nodeId: string,
|
nodeId: string,
|
||||||
nodeType: 'host' | 'pod' | 'container'
|
nodeType: 'host' | 'pod' | 'container',
|
||||||
|
timeRange: { from: number; to: number }
|
||||||
): Promise<string | undefined> => {
|
): Promise<string | undefined> => {
|
||||||
const fields = findInventoryFields(nodeType, sourceConfiguration.fields);
|
const fields = findInventoryFields(nodeType, sourceConfiguration.fields);
|
||||||
|
const timestampField = sourceConfiguration.fields.timestamp;
|
||||||
const params = {
|
const params = {
|
||||||
allowNoIndices: true,
|
allowNoIndices: true,
|
||||||
ignoreUnavailable: true,
|
ignoreUnavailable: true,
|
||||||
|
@ -26,11 +28,21 @@ export const getPodNodeName = async (
|
||||||
body: {
|
body: {
|
||||||
size: 1,
|
size: 1,
|
||||||
_source: ['kubernetes.node.name'],
|
_source: ['kubernetes.node.name'],
|
||||||
|
sort: [{ [timestampField]: 'desc' }],
|
||||||
query: {
|
query: {
|
||||||
bool: {
|
bool: {
|
||||||
filter: [
|
filter: [
|
||||||
{ match: { [fields.id]: nodeId } },
|
{ match: { [fields.id]: nodeId } },
|
||||||
{ exists: { field: `kubernetes.node.name` } },
|
{ exists: { field: `kubernetes.node.name` } },
|
||||||
|
{
|
||||||
|
range: {
|
||||||
|
[timestampField]: {
|
||||||
|
gte: timeRange.from,
|
||||||
|
lte: timeRange.to,
|
||||||
|
format: 'epoch_millis',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue