mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
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
2 changed files with 37 additions and 5 deletions
|
@ -6,7 +6,9 @@
|
|||
*/
|
||||
|
||||
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', () => {
|
||||
// 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 { LegacyRequest } from '../../types';
|
||||
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) {
|
||||
const source = resp.hits?.hits[0]?._source?.logstash_stats;
|
||||
|
@ -32,6 +35,11 @@ export function getNodeInfo(
|
|||
{ clusterUuid, logstashUuid }: { clusterUuid: string; logstashUuid: string }
|
||||
) {
|
||||
checkParam(lsIndexPattern, 'lsIndexPattern in getNodeInfo');
|
||||
const isStandaloneCluster = clusterUuid === STANDALONE_CLUSTER_CLUSTER_UUID;
|
||||
|
||||
const clusterFilter = isStandaloneCluster
|
||||
? standaloneClusterFilter
|
||||
: { term: { cluster_uuid: clusterUuid } };
|
||||
|
||||
const params = {
|
||||
index: lsIndexPattern,
|
||||
|
@ -48,10 +56,7 @@ export function getNodeInfo(
|
|||
body: {
|
||||
query: {
|
||||
bool: {
|
||||
filter: [
|
||||
{ term: { cluster_uuid: clusterUuid } },
|
||||
{ term: { 'logstash_stats.logstash.uuid': logstashUuid } },
|
||||
],
|
||||
filter: [clusterFilter, { term: { 'logstash_stats.logstash.uuid': logstashUuid } }],
|
||||
},
|
||||
},
|
||||
collapse: { field: 'logstash_stats.logstash.uuid' },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue