-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Monitoring] Kibana settings api #21100
Merged
chrisronline
merged 7 commits into
elastic:master
from
chrisronline:monitoring/kibana_settings_api
Aug 7, 2018
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
83e66f4
Kibana settings api
chrisronline 5a34929
Use different version of this utility
chrisronline 63d494d
Adding settings api test
chrisronline f04fe04
Fix these tests
chrisronline 62a59b3
Merge remote-tracking branch 'elastic/master' into monitoring/kibana_…
chrisronline 023bb6a
Merge remote-tracking branch 'elastic/master' into monitoring/kibana_…
chrisronline da82a4b
Update test
chrisronline File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
x-pack/plugins/xpack_main/server/routes/api/v1/settings.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import { wrap as wrapError } from 'boom'; | ||
import { KIBANA_SETTINGS_TYPE } from '../../../../../monitoring/common/constants'; | ||
import { getKibanaInfoForStats } from '../../../../../monitoring/server/kibana_monitoring/lib'; | ||
|
||
const getClusterUuid = async callCluster => { | ||
const { cluster_uuid: uuid } = await callCluster('info', { filterPath: 'cluster_uuid', }); | ||
return uuid; | ||
}; | ||
|
||
export function settingsRoute(server, kbnServer) { | ||
server.route({ | ||
path: '/api/settings', | ||
method: 'GET', | ||
async handler(req, reply) { | ||
const { server } = req; | ||
const { callWithRequest } = server.plugins.elasticsearch.getCluster('data'); | ||
const callCluster = (...args) => callWithRequest(req, ...args); // All queries from HTTP API must use authentication headers from the request | ||
|
||
try { | ||
const { collectorSet } = server.usage; | ||
const settingsCollector = collectorSet.getCollectorByType(KIBANA_SETTINGS_TYPE); | ||
|
||
const settings = await settingsCollector.fetch(callCluster); | ||
const uuid = await getClusterUuid(callCluster); | ||
|
||
const kibana = getKibanaInfoForStats(server, kbnServer); | ||
reply({ | ||
cluster_uuid: uuid, | ||
settings: { | ||
...settings, | ||
kibana, | ||
} | ||
}); | ||
} catch(err) { | ||
req.log(['error'], err); // FIXME doesn't seem to log anything useful if ES times out | ||
if (err.isBoom) { | ||
reply(err); | ||
} else { | ||
reply(wrapError(err, err.statusCode, err.message)); | ||
} | ||
} | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
x-pack/test/api_integration/apis/xpack_main/settings/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* 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 ({ loadTestFile }) { | ||
describe('Settings', () => { | ||
loadTestFile(require.resolve('./settings')); | ||
}); | ||
} |
42 changes: 42 additions & 0 deletions
42
x-pack/test/api_integration/apis/xpack_main/settings/settings.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
*/ | ||
|
||
import expect from 'expect.js'; | ||
|
||
export default function ({ getService }) { | ||
const supertest = getService('supertest'); | ||
const esArchiver = getService('esArchiver'); | ||
|
||
describe('/api/settings', () => { | ||
describe('with trial license clusters', () => { | ||
const archive = 'monitoring/multicluster'; | ||
|
||
before('load clusters archive', () => { | ||
return esArchiver.load(archive); | ||
}); | ||
|
||
after('unload clusters archive', () => { | ||
return esArchiver.unload(archive); | ||
}); | ||
|
||
it('should load multiple clusters', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. description should be different :) |
||
const { body } = await supertest | ||
.get('/api/settings') | ||
.set('kbn-xsrf', 'xxx') | ||
.expect(200); | ||
expect(body.cluster_uuid.length > 1).to.eql(true); | ||
expect(body.settings.kibana.uuid.length > 0).to.eql(true); | ||
expect(body.settings.kibana.name.length > 0).to.eql(true); | ||
expect(body.settings.kibana.index.length > 0).to.eql(true); | ||
expect(body.settings.kibana.host.length > 0).to.eql(true); | ||
expect(body.settings.kibana.transport_address.length > 0).to.eql(true); | ||
expect(body.settings.kibana.version.length > 0).to.eql(true); | ||
expect(body.settings.kibana.status.length > 0).to.eql(true); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this
FIXME
for addressing in this PR itself or a follow up PR?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. It's a comment copied over from the other api endpoint. Let's say it will be addressed in a follow up PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect the follow PR would need to address this problem everywhere