Fix issue with loading logstash node page under standalone cluster (#93617)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
cceed8ddd6
commit
7d237b8f59
|
@ -6,7 +6,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { handleResponse } from './get_node_info';
|
import { STANDALONE_CLUSTER_CLUSTER_UUID } from '../../../common/constants';
|
||||||
|
import { handleResponse, getNodeInfo } from './get_node_info';
|
||||||
|
import { standaloneClusterFilter } from '../standalone_clusters/standalone_cluster_query_filter';
|
||||||
|
|
||||||
describe('get_logstash_info', () => {
|
describe('get_logstash_info', () => {
|
||||||
// TODO: test was not running before and is not up to date
|
// TODO: test was not running before and is not up to date
|
||||||
|
@ -147,4 +149,29 @@ describe('get_logstash_info', () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('works with standalone cluster', async () => {
|
||||||
|
const callWithRequest = jest.fn().mockReturnValue({
|
||||||
|
then: jest.fn(),
|
||||||
|
});
|
||||||
|
const req = {
|
||||||
|
server: {
|
||||||
|
plugins: {
|
||||||
|
elasticsearch: {
|
||||||
|
getCluster: () => ({
|
||||||
|
callWithRequest,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
await getNodeInfo(req, '.monitoring-logstash-*', {
|
||||||
|
clusterUuid: STANDALONE_CLUSTER_CLUSTER_UUID,
|
||||||
|
});
|
||||||
|
expect(callWithRequest.mock.calls.length).toBe(1);
|
||||||
|
expect(callWithRequest.mock.calls[0].length).toBe(3);
|
||||||
|
expect(callWithRequest.mock.calls[0][2].body.query.bool.filter[0]).toBe(
|
||||||
|
standaloneClusterFilter
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,6 +12,9 @@ import { checkParam } from '../error_missing_required';
|
||||||
import { calculateAvailability } from '../calculate_availability';
|
import { calculateAvailability } from '../calculate_availability';
|
||||||
import { LegacyRequest } from '../../types';
|
import { LegacyRequest } from '../../types';
|
||||||
import { ElasticsearchResponse } from '../../../common/types/es';
|
import { ElasticsearchResponse } from '../../../common/types/es';
|
||||||
|
import { STANDALONE_CLUSTER_CLUSTER_UUID } from '../../../common/constants';
|
||||||
|
// @ts-ignore
|
||||||
|
import { standaloneClusterFilter } from '../standalone_clusters/standalone_cluster_query_filter';
|
||||||
|
|
||||||
export function handleResponse(resp: ElasticsearchResponse) {
|
export function handleResponse(resp: ElasticsearchResponse) {
|
||||||
const source = resp.hits?.hits[0]?._source?.logstash_stats;
|
const source = resp.hits?.hits[0]?._source?.logstash_stats;
|
||||||
|
@ -32,6 +35,11 @@ export function getNodeInfo(
|
||||||
{ clusterUuid, logstashUuid }: { clusterUuid: string; logstashUuid: string }
|
{ clusterUuid, logstashUuid }: { clusterUuid: string; logstashUuid: string }
|
||||||
) {
|
) {
|
||||||
checkParam(lsIndexPattern, 'lsIndexPattern in getNodeInfo');
|
checkParam(lsIndexPattern, 'lsIndexPattern in getNodeInfo');
|
||||||
|
const isStandaloneCluster = clusterUuid === STANDALONE_CLUSTER_CLUSTER_UUID;
|
||||||
|
|
||||||
|
const clusterFilter = isStandaloneCluster
|
||||||
|
? standaloneClusterFilter
|
||||||
|
: { term: { cluster_uuid: clusterUuid } };
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
index: lsIndexPattern,
|
index: lsIndexPattern,
|
||||||
|
@ -48,10 +56,7 @@ export function getNodeInfo(
|
||||||
body: {
|
body: {
|
||||||
query: {
|
query: {
|
||||||
bool: {
|
bool: {
|
||||||
filter: [
|
filter: [clusterFilter, { term: { 'logstash_stats.logstash.uuid': logstashUuid } }],
|
||||||
{ term: { cluster_uuid: clusterUuid } },
|
|
||||||
{ term: { 'logstash_stats.logstash.uuid': logstashUuid } },
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
collapse: { field: 'logstash_stats.logstash.uuid' },
|
collapse: { field: 'logstash_stats.logstash.uuid' },
|
||||||
|
|
Loading…
Reference in a new issue