mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Metrics UI] Add timerange and sorting to node detail metadata request (#81033)
This commit is contained in:
parent
ab8bf782c3
commit
2a82bddfe2
3 changed files with 41 additions and 6 deletions
|
@ -58,7 +58,14 @@ export const initMetadataRoute = (libs: InfraBackendLibs) => {
|
|||
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 cloudMetricsMetadata = cloudInstanceId
|
||||
|
|
|
@ -20,7 +20,8 @@ export const getNodeInfo = async (
|
|||
requestContext: RequestHandlerContext,
|
||||
sourceConfiguration: InfraSourceConfiguration,
|
||||
nodeId: string,
|
||||
nodeType: InventoryItemType
|
||||
nodeType: InventoryItemType,
|
||||
timeRange: { from: number; to: number }
|
||||
): Promise<InfraMetadataInfo> => {
|
||||
// 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
|
||||
|
@ -33,7 +34,8 @@ export const getNodeInfo = async (
|
|||
requestContext,
|
||||
sourceConfiguration,
|
||||
nodeId,
|
||||
nodeType
|
||||
nodeType,
|
||||
timeRange
|
||||
);
|
||||
if (kubernetesNodeName) {
|
||||
return getNodeInfo(
|
||||
|
@ -41,12 +43,14 @@ export const getNodeInfo = async (
|
|||
requestContext,
|
||||
sourceConfiguration,
|
||||
kubernetesNodeName,
|
||||
'host'
|
||||
'host',
|
||||
timeRange
|
||||
);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
const fields = findInventoryFields(nodeType, sourceConfiguration.fields);
|
||||
const timestampField = sourceConfiguration.fields.timestamp;
|
||||
const params = {
|
||||
allowNoIndices: true,
|
||||
ignoreUnavailable: true,
|
||||
|
@ -55,9 +59,21 @@ export const getNodeInfo = async (
|
|||
body: {
|
||||
size: 1,
|
||||
_source: ['host.*', 'cloud.*'],
|
||||
sort: [{ [timestampField]: 'desc' }],
|
||||
query: {
|
||||
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,
|
||||
sourceConfiguration: InfraSourceConfiguration,
|
||||
nodeId: string,
|
||||
nodeType: 'host' | 'pod' | 'container'
|
||||
nodeType: 'host' | 'pod' | 'container',
|
||||
timeRange: { from: number; to: number }
|
||||
): Promise<string | undefined> => {
|
||||
const fields = findInventoryFields(nodeType, sourceConfiguration.fields);
|
||||
const timestampField = sourceConfiguration.fields.timestamp;
|
||||
const params = {
|
||||
allowNoIndices: true,
|
||||
ignoreUnavailable: true,
|
||||
|
@ -26,11 +28,21 @@ export const getPodNodeName = async (
|
|||
body: {
|
||||
size: 1,
|
||||
_source: ['kubernetes.node.name'],
|
||||
sort: [{ [timestampField]: 'desc' }],
|
||||
query: {
|
||||
bool: {
|
||||
filter: [
|
||||
{ match: { [fields.id]: nodeId } },
|
||||
{ exists: { field: `kubernetes.node.name` } },
|
||||
{
|
||||
range: {
|
||||
[timestampField]: {
|
||||
gte: timeRange.from,
|
||||
lte: timeRange.to,
|
||||
format: 'epoch_millis',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue