Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.5] [Monitoring] Ensure setup mode work in a ccs environment (#54361) #54381

Merged
merged 1 commit into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import {
INDEX_ALERTS,
} from '../../../common/constants';

export function getIndexPatterns(server, additionalPatterns = {}) {
// wildcard means to search _all_ clusters
const ccs = '*';
export function getIndexPatterns(server, additionalPatterns = {}, ccs = '*') {
const config = server.config();
const esIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_ELASTICSEARCH, ccs);
const kbnIndexPattern = prefixIndexPattern(config, INDEX_PATTERN_KIBANA, ccs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function clusterSetupStatusRoute(server) {
skipLiveData: Joi.boolean().default(false),
}),
payload: Joi.object({
ccs: Joi.string().optional(),
timeRange: Joi.object({
min: Joi.date().required(),
max: Joi.date().required(),
Expand All @@ -49,7 +50,7 @@ export function clusterSetupStatusRoute(server) {
// the monitoring data. `try/catch` makes it a little more explicit.
try {
await verifyMonitoringAuth(req);
const indexPatterns = getIndexPatterns(server);
const indexPatterns = getIndexPatterns(server, {}, req.payload.ccs);
status = await getCollectionStatus(
req,
indexPatterns,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function nodeSetupStatusRoute(server) {
skipLiveData: Joi.boolean().default(false),
}),
payload: Joi.object({
ccs: Joi.string().optional(),
timeRange: Joi.object({
min: Joi.date().required(),
max: Joi.date().required(),
Expand All @@ -49,7 +50,7 @@ export function nodeSetupStatusRoute(server) {
// the monitoring data. `try/catch` makes it a little more explicit.
try {
await verifyMonitoringAuth(req);
const indexPatterns = getIndexPatterns(server);
const indexPatterns = getIndexPatterns(server, {}, req.payload.ccs);
status = await getCollectionStatus(
req,
indexPatterns,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export default function({ getService }) {
const supertest = getService('supertest');
const esArchiver = getService('esArchiver');

describe('ccs', () => {
const archive = 'monitoring/setup/collection/detect_apm';
const timeRange = {
min: '2019-04-16T00:00:00.741Z',
max: '2019-04-16T23:59:59.741Z',
};

before('load archive', () => {
return esArchiver.load(archive);
});

after('unload archive', () => {
return esArchiver.unload(archive);
});

it('should not fail with a ccs parameter for cluster', async () => {
await supertest
.post('/api/monitoring/v1/setup/collection/cluster?skipLiveData=true')
.set('kbn-xsrf', 'xxx')
.send({ timeRange, ccs: '*' })
.expect(200);
});

it('should not fail with a ccs parameter for node', async () => {
await supertest
.post('/api/monitoring/v1/setup/collection/node/123?skipLiveData=true')
.set('kbn-xsrf', 'xxx')
.send({ timeRange, ccs: '*' })
.expect(200);
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export default function({ loadTestFile }) {
loadTestFile(require.resolve('./detect_logstash_management'));
loadTestFile(require.resolve('./detect_apm'));
loadTestFile(require.resolve('./security'));
loadTestFile(require.resolve('./ccs'));
});
}