[Infra UI] Remove queries for log-related metadata (#40130)
* Don't query for log metadata as it's not used. * Adjust test case.
This commit is contained in:
parent
c32202a09e
commit
dcec10b03b
4 changed files with 4 additions and 70 deletions
|
@ -20,10 +20,4 @@ export interface InfraMetadataAdapter {
|
|||
nodeId: string,
|
||||
nodeType: string
|
||||
): Promise<InfraMetricsAdapterResponse>;
|
||||
getLogMetadata(
|
||||
req: InfraFrameworkRequest,
|
||||
sourceConfiguration: InfraSourceConfiguration,
|
||||
nodeId: string,
|
||||
nodeType: string
|
||||
): Promise<InfraMetricsAdapterResponse>;
|
||||
}
|
||||
|
|
|
@ -73,60 +73,6 @@ export class ElasticsearchMetadataAdapter implements InfraMetadataAdapter {
|
|||
buckets,
|
||||
};
|
||||
}
|
||||
|
||||
public async getLogMetadata(
|
||||
req: InfraFrameworkRequest,
|
||||
sourceConfiguration: InfraSourceConfiguration,
|
||||
nodeId: string,
|
||||
nodeType: 'host' | 'container' | 'pod'
|
||||
): Promise<InfraMetricsAdapterResponse> {
|
||||
const idFieldName = getIdFieldName(sourceConfiguration, nodeType);
|
||||
const logQuery = {
|
||||
allowNoIndices: true,
|
||||
ignoreUnavailable: true,
|
||||
index: sourceConfiguration.logAlias,
|
||||
body: {
|
||||
query: {
|
||||
bool: {
|
||||
filter: {
|
||||
term: { [idFieldName]: nodeId },
|
||||
},
|
||||
},
|
||||
},
|
||||
size: 0,
|
||||
aggs: {
|
||||
nodeName: {
|
||||
terms: {
|
||||
field: NAME_FIELDS[nodeType],
|
||||
size: 1,
|
||||
},
|
||||
},
|
||||
metrics: {
|
||||
terms: {
|
||||
field: 'event.dataset',
|
||||
size: 1000,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const response = await this.framework.callWithRequest<
|
||||
any,
|
||||
{ metrics?: InfraMetadataAggregationResponse; nodeName?: InfraMetadataAggregationResponse }
|
||||
>(req, 'search', logQuery);
|
||||
|
||||
const buckets =
|
||||
response.aggregations && response.aggregations.metrics
|
||||
? response.aggregations.metrics.buckets
|
||||
: [];
|
||||
|
||||
return {
|
||||
id: nodeId,
|
||||
name: get(response, ['aggregations', 'nodeName', 'buckets', 0, 'key'], nodeId),
|
||||
buckets,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const getIdFieldName = (sourceConfiguration: InfraSourceConfiguration, nodeType: string) => {
|
||||
|
|
|
@ -22,22 +22,16 @@ export class InfraMetadataDomain {
|
|||
) {
|
||||
const { configuration } = await this.libs.sources.getSourceConfiguration(req, sourceId);
|
||||
const metricsPromise = this.adapter.getMetricMetadata(req, configuration, nodeId, nodeType);
|
||||
const logsPromise = this.adapter.getLogMetadata(req, configuration, nodeId, nodeType);
|
||||
|
||||
const metrics = await metricsPromise;
|
||||
const logs = await logsPromise;
|
||||
|
||||
const metricMetadata = pickMetadata(metrics.buckets).map(entry => {
|
||||
return { name: entry, source: 'metrics' };
|
||||
});
|
||||
|
||||
const logMetadata = pickMetadata(logs.buckets).map(entry => {
|
||||
return { name: entry, source: 'logs' };
|
||||
});
|
||||
|
||||
const id = metrics.id || logs.id;
|
||||
const name = metrics.name || logs.name || id;
|
||||
return { id, name, features: metricMetadata.concat(logMetadata) };
|
||||
const id = metrics.id;
|
||||
const name = metrics.name || id;
|
||||
return { id, name, features: metricMetadata };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ const metadataTests: KbnTestProvider = ({ getService }) => {
|
|||
.then(resp => {
|
||||
const metadata = resp.data.source.metadataByNode;
|
||||
if (metadata) {
|
||||
expect(metadata.features.length).to.be(14);
|
||||
expect(metadata.features.length).to.be(12);
|
||||
expect(metadata.name).to.equal('demo-stack-mysql-01');
|
||||
} else {
|
||||
throw new Error('Metadata should never be empty');
|
||||
|
|
Loading…
Reference in a new issue