-
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
[WIP] KQL in TSVB with full QueryBar #36175
[WIP] KQL in TSVB with full QueryBar #36175
Conversation
💔 Build Failed |
💔 Build Failed |
jenkins, test this |
💔 Build Failed |
d0c7454
to
0d72b39
Compare
💔 Build Failed |
0d72b39
to
1a3ef1c
Compare
💔 Build Failed |
💔 Build Failed |
b6a4b7b
to
8724d68
Compare
💔 Build Failed |
💔 Build Failed |
async componentDidMount() { | ||
await this.fetchIndexPatternsForQuery(); | ||
} | ||
fetchIndexPatternsForQuery = async () => { |
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.
Can we reuse this method? I see you duplicated this method 7 times
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.
The index pattern we use to fetch the index pattern from SavedObjects has a different reference in each method and it needs to set state in each component. Each method is slightly different and that is why it is redefined. If you have a recommendation on how to more easily set state in a component with a shared method, please let me know.
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.
@TinaHeiligers I've checked that,
We have similar body for:
src/legacy/core_plugins/metrics/public/components/annotations_editor.js
src/legacy/core_plugins/metrics/public/components/panel_config/gauge.js
src/legacy/core_plugins/metrics/public/components/panel_config/markdown.js
src/legacy/core_plugins/metrics/public/components/panel_config/metric.js
src/legacy/core_plugins/metrics/public/components/panel_config/table.js
src/legacy/core_plugins/metrics/public/components/panel_config/timeseries.js
src/legacy/core_plugins/metrics/public/components/panel_config/top_n.js
src/legacy/core_plugins/metrics/public/components/series.js
and only one different implementation for
src/legacy/core_plugins/metrics/public/components/split.js
I still think that we should somehow to reuse it
} | ||
fetchIndexPatternsForQuery = async () => { | ||
const searchIndexPattern = this.props.model.index_pattern ? | ||
this.props.model.index_pattern : |
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 we can save 2 lines using || operator
const searchIndexPattern = this.props.model.index_pattern || this.props.model.default_index_pattern
|
||
handleSubmit = (model, query) => { | ||
const part = { query_string: query.query }; | ||
collectionActions.handleChange(this.props, _.assign({}, model, part)); |
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.
we are trying to remove all references to _.
in our code and don't add the new one.
what do you think about:
collectionActions.handleChange(this.props, {
...model,
...part
});`
: this.state.uiQueryLanguage, | ||
query: model.query_string.query, | ||
}} | ||
screenTitle={'AnnotationsEditor'} |
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.
Should we localize this value?
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.
The value is localized internally within the QueryBarInputUI component.
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.
Got it, thanks!
this.state = { | ||
selectedTab: 'data', | ||
indexPatternForQuery: {}, | ||
uiQuerylanguage: uiSettingsQueryLanguage, |
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.
Do we have any cases when this value will be changed in the 'state'? If not probably we can remove it from state and do something like
<QueryBar
query={{
language: model.filter.language || uiSettingsQueryLanguage ,
query: model.filter.query,
}}
const { model } = this.props; | ||
if (!model.background_color_rules || (model.background_color_rules && model.background_color_rules.length === 0)) { |
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.
let's try to use isEmpty
method from lodash
here?
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 didn't add that but can change it if preferred.
let indexPatternObject; | ||
const indexPatternsFromSavedObjects = await chrome.getSavedObjectsClient().find({ | ||
type: 'index-pattern', | ||
fields: ['title', 'fields'], |
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 we can exclude'fields'
from this array
constructor(props) { | ||
super(props); | ||
this.state = { | ||
indexPatternForQuery: {}, |
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 see the 'QueryBar'
works with the index pattern object but not sure that we should add one more field for storing index pattern value.
I offer you 2 different ways:
- create a wrapper upper the 'QueryBar' component and move all this logic related to uiQueryLanguage and indexPatternForQuery to this component. It helps you to remove all code duplication
- more complex way. TSVB should work with index pattern object instead of string value of index pattern. But I see a lot of changes here.
search_fields: ['title'], | ||
}); | ||
const exactMatch = indexPatternsFromSavedObjects.savedObjects.find( | ||
indexPattern => indexPattern.attributes.title === indexPatternString |
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.
TSVB allow us to work with wildcards e.g. kibana_*
. Looks like for my example this method always return us false
Should we support this types of indexes?
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.
The QueryBar needs an exact index pattern for autocomplete and suggestions. If we allow a wildcard then we cannot be certain that the index pattern returned from getFromSavedObject is the one that we need.
💔 Build Failed |
onChange={this.handleChange(model, 'query_string')} | ||
value={model.query_string} | ||
fullWidth | ||
<QueryBar |
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.
@TinaHeiligers @Bargs Can we disable the refresh functionality for the QueryBar?
With this one we have 4 components which somehow related to the refresh functionality. Adding one more refresh button can confuse our users.
Also it's not working property with Auto-update. I expect that if user turn on this check-box next filter should be applying without pressing the refresh/update button.
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.
Yep, that's already in progress.
💔 Build Failed |
💔 Build Failed |
51620a4
to
061a01d
Compare
…Bar in TimeSeries
…uest processor for query
💚 Build Succeeded |
@alexwizp @Bargs would you mind if I address your comments in a new PR and close this one? I've had a nightmare time with rebasing all these commits against master. Since there's still a lot of work to be done, I've squash-merged the work to date into a new branch to continue with the work from there. It will make progress much quicker. |
Issue:
|
async componentDidMount() { | ||
await this.fetchIndexPatternsForQuery(); | ||
} | ||
fetchIndexPatternsForQuery = async () => { |
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.
@TinaHeiligers I've checked that,
We have similar body for:
src/legacy/core_plugins/metrics/public/components/annotations_editor.js
src/legacy/core_plugins/metrics/public/components/panel_config/gauge.js
src/legacy/core_plugins/metrics/public/components/panel_config/markdown.js
src/legacy/core_plugins/metrics/public/components/panel_config/metric.js
src/legacy/core_plugins/metrics/public/components/panel_config/table.js
src/legacy/core_plugins/metrics/public/components/panel_config/timeseries.js
src/legacy/core_plugins/metrics/public/components/panel_config/top_n.js
src/legacy/core_plugins/metrics/public/components/series.js
and only one different implementation for
src/legacy/core_plugins/metrics/public/components/split.js
I still think that we should somehow to reuse it
fullWidth | ||
<QueryBar | ||
query={{ | ||
language: model.filter.language ? model.filter.language : 'kuery', |
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 see that you use 'kuery' only here. In other places you use uiSettingsQueryLanguage. Is it correct?
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 will change it.
return <Component {...params} />; | ||
} | ||
return ( | ||
<div> |
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.
Are you sure we need that extra div? I don't see any reason to refactor this this file
@TinaHeiligers @Bargs From my point of view we should continue to work in scope of this PR. |
The work is still in progress and not ready for review yet
Note: #36784 has been opened in favor of this PR.
Summary
References Support KQL in TSVB Filter aggregations
Adds KQL to Visual Builder (TSVB)
Still TODO:
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.For maintainers