Skip to content

Extract KQL autocomplete to a plugin#20747

Merged
lukasolson merged 10 commits intoelastic:masterfrom
lukasolson:fix/autocompleteBasic
Jul 24, 2018
Merged

Extract KQL autocomplete to a plugin#20747
lukasolson merged 10 commits intoelastic:masterfrom
lukasolson:fix/autocompleteBasic

Conversation

@lukasolson
Copy link
Contributor

This PR extracts the autocomplete functionality of Kibana's query language into a plugin. We intend to add additional autocomplete providers for other languages, including those provided by a basic license like SQL.

In the new platform we will have plugin contracts, and this also paves the way to accomplishing this.

function escapeSpecialCharacters(string) {
return string.replace(/[\\():<>"*]/g, '\\$&'); // $& means the whole matched string
}
const autocompleteProviders = new Map();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is basically a registry, but I didn't actually want to use a registry because it relies on Private which would make it difficult to include in APM.

@@ -1,41 +0,0 @@
/*
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a rename.

uiExports: {
hacks: ['plugins/kuery_autocomplete/hacks'],
},
init: () => {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason if I don't include this, the plugin doesn't load...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, works for me, plugins without init functions are nothing new: https://github.com/elastic/kibana/blob/master/src/core_plugins/kbn_vislib_vis_types/index.js. Maybe you mean you're not seeing the log line about its status? That's because plugins without an init() function can't actually have a status, since the only way to set it would be with an init() function.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@Bargs Bargs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I tested with OSS, basic, and trial licenses to make sure the right thing happened in each case. Not 100% sure if hacks are the best way to do this, but I don't know of a better way, so I'll leave that to someone more familiar with what's happening with the plugin APIs to comment on.

@lukasolson lukasolson requested a review from epixa July 18, 2018 19:06
@epixa epixa removed their request for review July 18, 2018 21:26
@epixa
Copy link
Contributor

epixa commented Jul 18, 2018

I won't have time to review this before I go on vacation, but I want to make sure it gets merged/backported for 6.4 FF. @lukasolson please ask someone else to take a look at this in my stead.

@lukasolson lukasolson requested a review from spalger July 18, 2018 22:06
Copy link
Contributor

@bmcconaghy bmcconaghy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, follows a similar pattern to how we've handled other xpack/oss interactions in management apps (xpack console autocomplete, rollup support). I made a couple of naming suggestions but they are not blockers.

// See the Keyword rule in kuery.peg
function escapeAndOr(string) {
return string.replace(/(\s+)(and|or)(\s+)/ig, '$1\\$2$3');
export function setAutocompleteProvider(language, provider) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest renaming this to "addAutocompleteProvider" to make it clear that multiple providers can be added.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Agreed, I'll update this


this.suggestions = this.getRecentSearchSuggestions(query);
if (this.localQuery.language !== 'kuery' || !this.getKuerySuggestions) return;
const suggestionsProvider = getAutocompleteProvider(language);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this mismatch b/t suggestionsProvider and autocompleteProvider is weird and possibly confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Agreed, I'll update this

@elasticmachine
Copy link
Contributor

💔 Build Failed

@lukasolson
Copy link
Contributor Author

Jenkins, test this

@elasticmachine
Copy link
Contributor

💔 Build Failed

export const kueryAutocomplete = (kibana) => new kibana.Plugin({
id: 'kuery_autocomplete',
publicDir: resolve(__dirname, 'public'),
require: ['kibana', 'xpack_main'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is unnecessary, this plugin doesn't actually require the kibana or xpack_main plugins AFAICT

id: 'kuery_autocomplete',
publicDir: resolve(__dirname, 'public'),
require: ['kibana', 'xpack_main'],
config: (Joi) => Joi.object({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also unnecessary, these are the defaults.

Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Things seem to work well, I sent lukasolson#15 to switch to a new uiExports type, and I think you could trim down the plugin specification a bit

@JackRyanson
Copy link

guys it appears to me you're removing the Kuery autocomplete from OSS and making it into xpack only is this correct?

@JackRyanson
Copy link

guys it appears to me you're removing the Kuery autocomplete from OSS and making it into xpack only is this correct?

@JackRyanson
Copy link

@Spager @lukasolson sorry to insist but it is a quite important for those that are integrating Kibana in more complex environments where the right to modify the code is key. (basic xpack might be free but there is no right to use a modified code even if one purchases the licence ). Please advice is there a roadmap of features that used to be open source and are going to get locked? if so could you please share for us to plan. thanks in advance

@clintongormley
Copy link
Contributor

Hi @JackRyanson

You are correct - this PR moves Kuery autocomplete from an experimental feature in OSS to Basic. Regarding your question about whether there is a roadmap to move open source features to licensed, no, not at all. We have never moved a supported feature from open source to licensed. In fact, we'd only ever consider moving supported features in the opposite direction. Kuery autocomplete doesn't fall into that box because it was experimental. Usually we'd try to have the licensing decided before we first publish a feature, but we reserve the right to make changes to experimental features.

May I ask what changes you want to make to autocomplete? Are they things that would be generally useful? If so, why not try to get your changes incorporated into the released code so that they can benefit everybody?

@JackRyanson
Copy link

Autocomplete is pretty much the kind of things that benefits from customization in advanced integrations, the DSL might be modified e.g. with specialized functions.

Just to make sure i understand this is THE core autocomplete of kibana , just released as highlight feature in 6.3 - not available anymoe in OSS from 6.4 ? (or is it something else)
https://www.elastic.co/blog/kibana-6-3-0-released .

You talk about contributing but i dont understand : how would i possibly want to contribute to something which has a licence which prevents one from using a modified version or on modified kibana code even after paying for the licence (my current understanding of your licence) .

Just to be clear, you obviously have the right to do what you want here but i do think is in everyones interest to have a clear policy, and i believe Elastic will miss out big time if you lose the ability to flexibly integrate the stack

[uiExports] switch to new autocompleteProviders export type
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@lukasolson lukasolson merged commit ecc0f5e into elastic:master Jul 24, 2018
lukasolson added a commit to lukasolson/kibana that referenced this pull request Jul 24, 2018
* fix: move autocomplete to x-pack basic

* fix: apm support

* fix: renames

* [uiExports] switch to new autocompleteProviders export type

* fix: remove unnecessary stuff from the plugin spec
@lukasolson
Copy link
Contributor Author

6.x (6.4.0): 3bbb9c5

@clintongormley
Copy link
Contributor

You talk about contributing but i dont understand : how would i possibly want to contribute to something which has a licence which prevents one from using a modified version or on modified kibana code even after paying for the licence (my current understanding of your licence) .

By contributing, your changes would be included and you'd be able to use the default distribution, plus you will have helped others.

@JackRyanson
Copy link

@clintongormley the default distribution is useless in advanced integration projects.

as per my previous message - "default distribution" is useless we need to integrate with other components and that goes at code level.

I am not an opensource fanboy : we are using X Pack for security/alerting/support and all, but what you're doing here is extending it to where it blocks and locks Ui capabilities which are general purpose and we need to retain the ability to customize as in "you gotta use our stock or nothing".

You guys - the elastic company i guess - moving in an integration unfriendly way locking stuff away with the excuse of "free" ==== FOSS is very worrisome and at least in our case will force us into alternatives to xpack, which frankly exist. It appears a lose lose for all.

@sorenlouv
Copy link
Member

sorenlouv commented Jul 25, 2018

@lukasolson Kuery Bar in APM no longer works after this change.
getAutocompleteProvider('kuery') returns undefined and thus no suggestions are returned.
Let me know if I should do anything on my end to fix that.

Going forward I think it would be a good idea to notify the teams affected by a change, so they can manually test it.

@lukasolson
Copy link
Contributor Author

@sqren Oh goodness, my fault, I manually tested APM up until that last commit (definitely should have tested there too...)

@lukasolson lukasolson deleted the fix/autocompleteBasic branch October 31, 2018 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants