Skip to content

Commit

Permalink
only query kibana_stats documents
Browse files Browse the repository at this point in the history
  • Loading branch information
klacabane committed Aug 6, 2022
1 parent c7c9b67 commit 879122d
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions x-pack/plugins/monitoring/server/lib/kibana/get_kibana_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { getNewIndexPatterns } from '../cluster/get_index_patterns';
import { MissingRequiredError } from '../error_missing_required';
import { buildKibanaInfo } from './build_kibana_info';
import { isKibanaStatusStale } from './is_kibana_status_stale';
import { createQuery } from '../create_query';
import { KibanaMetric } from '../metrics';

export function handleResponse(resp: ElasticsearchResponse) {
const hit = resp.hits?.hits[0];
Expand All @@ -36,10 +38,13 @@ export function getKibanaInfo(
{ clusterUuid, kibanaUuid }: { clusterUuid: string; kibanaUuid: string }
) {
const moduleType = 'kibana';
const type = 'kibana_stats';
const dataset = 'stats';
const indexPatterns = getNewIndexPatterns({
config: Globals.app.config,
ccs: req.payload.ccs,
moduleType,
dataset,
});
const params = {
index: indexPatterns,
Expand All @@ -58,14 +63,14 @@ export function getKibanaInfo(
'hits.hits._source.service.version',
],
body: {
query: {
bool: {
filter: [
{ term: { cluster_uuid: clusterUuid } },
{ term: { 'kibana_stats.kibana.uuid': kibanaUuid } },
],
},
},
query: createQuery({
type,
dsDataset: `${moduleType}.${dataset}`,
metricset: dataset,
clusterUuid,
uuid: kibanaUuid,
metric: KibanaMetric.getMetricFields(),
}),
collapse: { field: 'kibana_stats.kibana.uuid' },
sort: [{ timestamp: { order: 'desc', unmapped_type: 'long' } }],
},
Expand Down

0 comments on commit 879122d

Please sign in to comment.