-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[XpackMain] Add _xpack/usage API #19232
Conversation
💚 Build Succeeded |
x-pack/test/functional/config.js
Outdated
@@ -162,7 +162,6 @@ export default async function ({ readConfigFile }) { | |||
`--server.uuid=${env.kibana.server.uuid}`, | |||
`--server.port=${servers.kibana.port}`, | |||
`--elasticsearch.url=${formatUrl(servers.elasticsearch)}`, | |||
'--xpack.monitoring.kibana.collection.enabled=false', |
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 had to remove this in order for const { collectorSet } = server.plugins.monitoring
to work in the API handler.
Maybe it'd be better to expose the collectorSet regardless, but check for xpack.monitoring.kibana.collection.enabled
in the bulk fetch method of the collector set ...
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.
On second thought, I don't really like the idea of lazy checking a config setting in the bulk method.
The collectorSet
only gets exposed on the monitoring plugin when xpack.monitoring.kibana.collection.enabled
is true, and I think that's fine.
Maybe when collection is disabled, we can expose a no-op function on the plugin so other plugins don't have to think about it.
💚 Build Succeeded |
@@ -164,7 +164,6 @@ export default async function ({ readConfigFile }) { | |||
`--server.uuid=${env.kibana.server.uuid}`, | |||
`--server.port=${servers.kibana.port}`, | |||
`--elasticsearch.url=${formatUrl(servers.elasticsearch)}`, | |||
'--xpack.monitoring.kibana.collection.enabled=false', |
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.
It wasn't my first choice to remove this, but it is necessary for making the api integration test work. The HTTP endpoint relies collectorSet
being exposed, which is dependent on this setting being true
.
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.
It's kind of unfortunate that all functional tests depend on the same configuration. Given the startup time of Kibana though, I get why that is the best option though.
Didn't we need to add this because it randomly broke other tests though?
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.
Didn't we need to add this because it randomly broke other tests though?
Nope, this was just an optimization to avoid running the internal timer for the functional test server.
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.
Minor comments and a question, then LGTM.
@@ -164,7 +164,6 @@ export default async function ({ readConfigFile }) { | |||
`--server.uuid=${env.kibana.server.uuid}`, | |||
`--server.port=${servers.kibana.port}`, | |||
`--elasticsearch.url=${formatUrl(servers.elasticsearch)}`, | |||
'--xpack.monitoring.kibana.collection.enabled=false', |
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.
It's kind of unfortunate that all functional tests depend on the same configuration. Given the startup time of Kibana though, I get why that is the best option though.
Didn't we need to add this because it randomly broke other tests though?
|
||
export function xpackUsageRoute(server) { | ||
server.route({ | ||
path: '/api/_xpack/usage', |
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 like the usage of _xpack
here because it's consistent with ES X-Pack, but I wonder how others might feel about this.
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.
pretty much every other API in Kibana has a convention of /api/kibana/<featurename>/<sub>/
src/core_plugins/kibana/server/routes/api/export/index.js:7:5: path: '/api/kibana/dashboards/export',
src/core_plugins/kibana/server/routes/api/home/register_tutorials.js:4:5: path: '/api/kibana/home/tutorials',
src/core_plugins/kibana/server/routes/api/scroll_search/index.js:5:5: path: '/api/kibana/legacy_scroll_start',
src/core_plugins/kibana/server/routes/api/search/count/register_count.js:6:5: path: '/api/kibana/{id}/_count',
src/core_plugins/kibana/server/routes/api/scroll_search/index.js:24:5: path: '/api/kibana/legacy_scroll_continue',
src/core_plugins/kibana/server/routes/api/scripts/register_languages.js:3:5: path: '/api/kibana/scripts/languages',
src/core_plugins/kibana/server/routes/api/suggestions/register_value_suggestions.js:6:5: path: '/api/kibana/suggestions/values/{index}',
src/core_plugins/kibana/server/routes/api/management/saved_objects/scroll.js:19:5: path: '/api/kibana/management/saved_objects/scroll/export',
src/core_plugins/kibana/server/routes/api/management/saved_objects/scroll.js:54:5: path: '/api/kibana/management/saved_objects/scroll/counts',
src/core_plugins/kibana/server/routes/api/management/saved_objects/relationships.js:7:5: path: '/api/kibana/management/saved_objects/relationships/{type}/{id}',
The existing status API has a path of /api/status
and the new stats API (6.3.0) has a path of /api/stats
I think it's good to be consistent with ES, as Kibana doesn't have a good foundation for conventions currently.
}); | ||
} catch(err) { | ||
req.log(['error'], err); | ||
if (err.isBoom) { |
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 really dislike how Boom wrap works.
|
||
/* | ||
* @return {Object} data from usage stats collectors registered with Monitoring CollectorSet | ||
*/ |
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.
Probably worth marking that it throws an Error
.
* @throws {Error} if the Monitoring CollectorSet is not ready
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.
LGTM. Agree with the convention point.
💚 Build Succeeded |
* [XpackMain] Add _xpack/usage API * add xpack usage http api integration test * comment * misc test describe fixes * fix integration test * fix reply called twice * enable api test * enable kibana collection for integration test to work * throw error comment
* [XpackMain] Add _xpack/usage API (#19232) * [XpackMain] Add _xpack/usage API * add xpack usage http api integration test * comment * misc test describe fixes * fix integration test * fix reply called twice * enable api test * enable kibana collection for integration test to work * throw error comment * Update config.js remove whitespace change
Pulled from #18894
This adds the
/api/_xpack/usage
HTTP API endpoint, which returns data fetched from Elasticsearch about X-Pack feature usage.It removes the integration test for
stats
, which is a deprecated API, and adds an integration test for the usage API.