-
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
Changes from 1 commit
83e66f4
5a34929
63d494d
f04fe04
62a59b3
023bb6a
da82a4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* 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 { getKibanaInfoForStats } from '../../../../../../../src/server/status/lib'; | ||
import { KIBANA_SETTINGS_TYPE } from '../../../../../monitoring/common/constants'; | ||
|
||
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); | ||
|
||
console.log('uuid', uuid); | ||
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. Debugging statement. |
||
|
||
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 | ||
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. Was this 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. 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 commentThe reason will be displayed to describe this comment to others. Learn more. I suspect the follow PR would need to address this problem everywhere |
||
if (err.isBoom) { | ||
reply(err); | ||
} else { | ||
reply(wrapError(err, err.statusCode, err.message)); | ||
} | ||
} | ||
} | ||
}); | ||
} |
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.
Looks like CI is failing on this line: