Skip to content

Commit 195508d

Browse files
authored
[Monitoring] Ensure setup mode work in a ccs environment (#54361) (#54381)
* Ensure setup mode work in a ccs environment * Missed this file
1 parent 75f670e commit 195508d

File tree

5 files changed

+48
-5
lines changed

5 files changed

+48
-5
lines changed

x-pack/legacy/plugins/monitoring/server/lib/cluster/get_index_patterns.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ import {
1313
INDEX_ALERTS,
1414
} from '../../../common/constants';
1515

16-
export function getIndexPatterns(server, additionalPatterns = {}) {
17-
// wildcard means to search _all_ clusters
18-
const ccs = '*';
16+
export function getIndexPatterns(server, additionalPatterns = {}, ccs = '*') {
1917
const config = server.config();
2018
const esIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_ELASTICSEARCH, ccs);
2119
const kbnIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_KIBANA, ccs);

x-pack/legacy/plugins/monitoring/server/routes/api/v1/setup/cluster_setup_status.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export function clusterSetupStatusRoute(server) {
3434
skipLiveData: Joi.boolean().default(false),
3535
}),
3636
payload: Joi.object({
37+
ccs: Joi.string().optional(),
3738
timeRange: Joi.object({
3839
min: Joi.date().required(),
3940
max: Joi.date().required(),
@@ -49,7 +50,7 @@ export function clusterSetupStatusRoute(server) {
4950
// the monitoring data. `try/catch` makes it a little more explicit.
5051
try {
5152
await verifyMonitoringAuth(req);
52-
const indexPatterns = getIndexPatterns(server);
53+
const indexPatterns = getIndexPatterns(server, {}, req.payload.ccs);
5354
status = await getCollectionStatus(
5455
req,
5556
indexPatterns,

x-pack/legacy/plugins/monitoring/server/routes/api/v1/setup/node_setup_status.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export function nodeSetupStatusRoute(server) {
3434
skipLiveData: Joi.boolean().default(false),
3535
}),
3636
payload: Joi.object({
37+
ccs: Joi.string().optional(),
3738
timeRange: Joi.object({
3839
min: Joi.date().required(),
3940
max: Joi.date().required(),
@@ -49,7 +50,7 @@ export function nodeSetupStatusRoute(server) {
4950
// the monitoring data. `try/catch` makes it a little more explicit.
5051
try {
5152
await verifyMonitoringAuth(req);
52-
const indexPatterns = getIndexPatterns(server);
53+
const indexPatterns = getIndexPatterns(server, {}, req.payload.ccs);
5354
status = await getCollectionStatus(
5455
req,
5556
indexPatterns,
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
export default function({ getService }) {
8+
const supertest = getService('supertest');
9+
const esArchiver = getService('esArchiver');
10+
11+
describe('ccs', () => {
12+
const archive = 'monitoring/setup/collection/detect_apm';
13+
const timeRange = {
14+
min: '2019-04-16T00:00:00.741Z',
15+
max: '2019-04-16T23:59:59.741Z',
16+
};
17+
18+
before('load archive', () => {
19+
return esArchiver.load(archive);
20+
});
21+
22+
after('unload archive', () => {
23+
return esArchiver.unload(archive);
24+
});
25+
26+
it('should not fail with a ccs parameter for cluster', async () => {
27+
await supertest
28+
.post('/api/monitoring/v1/setup/collection/cluster?skipLiveData=true')
29+
.set('kbn-xsrf', 'xxx')
30+
.send({ timeRange, ccs: '*' })
31+
.expect(200);
32+
});
33+
34+
it('should not fail with a ccs parameter for node', async () => {
35+
await supertest
36+
.post('/api/monitoring/v1/setup/collection/node/123?skipLiveData=true')
37+
.set('kbn-xsrf', 'xxx')
38+
.send({ timeRange, ccs: '*' })
39+
.expect(200);
40+
});
41+
});
42+
}

x-pack/test/api_integration/apis/monitoring/setup/collection/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ export default function({ loadTestFile }) {
1616
loadTestFile(require.resolve('./detect_logstash_management'));
1717
loadTestFile(require.resolve('./detect_apm'));
1818
loadTestFile(require.resolve('./security'));
19+
loadTestFile(require.resolve('./ccs'));
1920
});
2021
}

0 commit comments

Comments
 (0)