Skip to content
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

TSVB doesn't communicate it's index-patterns to dashboard #82964

Merged
merged 6 commits into from
Nov 16, 2020

Conversation

alexwizp
Copy link
Contributor

@alexwizp alexwizp commented Nov 9, 2020

Closes: #81476

Summary

For dashboard's filter bar to work visualisations communicate its index-patterns.
Some visualisations don't do that (#19408)
But according to (#19408 (comment)) TSVB should.

This is causing bugs and confusions with how filter bar is working on a dashboard when TSVB is used.
Especially filter bar is almost non usable for dashboards that have only TSVB visualisations and use non-default index patterns.

Steps to reproduce:

  1. Create a TSVB with non default index pattern
  2. Create a dashboard with single TSVB lib
  3. Try to use a filter bar and notice that there is no way to use pick a filter for used index pattern

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@alexwizp alexwizp self-assigned this Nov 10, 2020
@alexwizp alexwizp added v7.11 v8.0.0 Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:TSVB TSVB (Time Series Visual Builder) Feature:Visualizations Generic visualization features (in case no more specific feature label is available) release_note:fix labels Nov 10, 2020
@alexwizp alexwizp marked this pull request as ready for review November 10, 2020 08:59
@alexwizp alexwizp requested a review from a team November 10, 2020 08:59
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

Code LGTM and it works fine, now I can create filters even if I use a non default index pattern
Screenshot 2020-11-11 at 11 00 04 AM
I have also tested it with multiple index patterns and all of them are communicated to our filter components and can be used.
I am fine with this approach if the arch team agrees

@alexwizp
Copy link
Contributor Author

@elasticmachine merge upstream

Comment on lines +75 to +79
if (vis.type.getUsedIndexPattern) {
indexPatterns = await vis.type.getUsedIndexPattern(vis.params);
} else if (vis.data.indexPattern) {
indexPatterns = [vis.data.indexPattern];
}
Copy link
Member

Choose a reason for hiding this comment

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

One idea that came to mind:

I'm wondering if, instead of having two sources of truth in a vis for the index pattern (either vis.data.indexPattern OR vis.type.getUsedIndexPattern), it would be cleaner to make a change in vis itself so that vis.data.indexPattern always reads from vis.type.getUsedIndexPattern.

In vis.ts we could do something like:

this.data.indexPattern = await this.type.getIndexPattern(this.data, this.params);

Then on the vis type:

await getIndexPattern(data: VisData, params: VisParams) {
  ...etc
}

Then on the vis type, getIndexPattern is optional, and defaults to the logic that's currently in vis.ts:

if (state.data && state.data.searchSource) {
this.data.searchSource = await getSearch().searchSource.create(state.data.searchSource!);
this.data.indexPattern = this.data.searchSource.getField('index');
}
if (state.data && state.data.savedSearchId) {
this.data.savedSearchId = state.data.savedSearchId;
if (this.data.searchSource) {
this.data.searchSource = await getSearchSource(
this.data.searchSource,
this.data.savedSearchId
);
this.data.indexPattern = this.data.searchSource.getField('index');
}
}

WDYT @alexwizp? Do you think that would work / make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pretty the same idea was implemented in my initial commit(e2e02fe), but after discussing it @ppisljar we decided to don't modify vis.setState method.

Copy link
Member

@lukeelmers lukeelmers left a comment

Choose a reason for hiding this comment

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

Code here LGTM. I still think that it would feel a bit cleaner to modify setState to call this new method from vis.type, but I'll defer to @ppisljar's original feedback on that as I'm sure he had reasons for not doing so.

@alexwizp
Copy link
Contributor Author

@elasticmachine merge upstream

@alexwizp
Copy link
Contributor Author

@ppisljar it wouldn't be right to merge/fix it without your feedback

@spalger spalger added v7.11.0 and removed v7.11 labels Nov 12, 2020
@alexwizp
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
visTypeTimeseries 132.8KB 134.5KB +1.7KB
visualizations 169.7KB 169.9KB +286.0B
total +1.9KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Member

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

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

code LGTM, not putting this on vis.data as that's specific to our 'classic' visualizations and should not try to cover all the custom vis types (like tsvb)

@alexwizp alexwizp merged commit 253495b into elastic:master Nov 16, 2020
alexwizp added a commit to alexwizp/kibana that referenced this pull request Nov 16, 2020
)

* TSVB doesn't communicate it's index-patterns to dashboard

Closes: elastic#81476

* useCustomSearchSource -> getUsedIndexPattern

* fix CI

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
alexwizp added a commit that referenced this pull request Nov 16, 2020
…83395)

* TSVB doesn't communicate it's index-patterns to dashboard

Closes: #81476

* useCustomSearchSource -> getUsedIndexPattern

* fix CI

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
gmmorris added a commit to gmmorris/kibana that referenced this pull request Nov 16, 2020
* master:
  Migrate `/translations` route to core (elastic#83280)
  [APM] Ensure APM jest script can run (elastic#83398)
  [Uptime] Monitor status alert use url as instance (elastic#81736)
  [ML] Add basic license test run details to ML+Transform READMEs (elastic#83259)
  TSVB doesn't communicate it's index-patterns to dashboard (elastic#82964)
  [Alerting UI] Added ability to assign alert actions to resolved action group in UI (elastic#83139)
  Skips Vega test
  skip flaky suite (elastic#79967)
  [bundle optimization] Update to semver 7.x to get tree-shaking (elastic#83020)
  Added ability to fire actions when an alert instance is resolved (elastic#82799)
  [ML] Adds functional tests for the index data visualizer card contents (elastic#83174)
phillipb added a commit to phillipb/kibana that referenced this pull request Nov 16, 2020
… into add-logs-to-node-details

* 'add-logs-to-node-details' of github.com:phillipb/kibana:
  fix tall vislib charts in visualize (elastic#83340)
  [Lens] Avoid unnecessary data fetching on dimension flyout open (elastic#82957)
  [Security Solution][Case] Change case connector minimum required license to basic (elastic#83401)
  fix logstash central pipeline management test  (elastic#83281)
  [Search] Send to background UI (elastic#81793)
  Migrate `/translations` route to core (elastic#83280)
  [APM] Ensure APM jest script can run (elastic#83398)
  [Uptime] Monitor status alert use url as instance (elastic#81736)
  [ML] Add basic license test run details to ML+Transform READMEs (elastic#83259)
  TSVB doesn't communicate it's index-patterns to dashboard (elastic#82964)
  [Alerting UI] Added ability to assign alert actions to resolved action group in UI (elastic#83139)
  Skips Vega test
  skip flaky suite (elastic#79967)
  [bundle optimization] Update to semver 7.x to get tree-shaking (elastic#83020)
  Added ability to fire actions when an alert instance is resolved (elastic#82799)
@TheRiffRafi
Copy link

Hello Folks,
Does this fix cover Timelion as well? Timelion can especify a particular index in it's expression but that also is not communicated to the dashboard filter it seems, I just tested on 7.10.

@stratoula
Copy link
Contributor

@TheRiffRafi this fix covers Vega and TSVB, not timelion. I have created an issue to track it #86418. It is a little bit more complicated for Timelion but it is doable.

alexwizp added a commit to alexwizp/kibana that referenced this pull request Dec 18, 2020
)

* TSVB doesn't communicate it's index-patterns to dashboard

Closes: elastic#81476

* useCustomSearchSource -> getUsedIndexPattern

* fix CI

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
# Conflicts:
#	src/plugins/vis_type_timeseries/public/metrics_type.ts
#	src/plugins/visualizations/public/embeddable/create_vis_embeddable_from_object.ts
#	src/plugins/visualizations/public/vis_types/base_vis_type.ts
#	src/plugins/visualizations/public/vis_types/types.ts
@alexwizp
Copy link
Contributor Author

@stratoula this PR cover only TSVB related issues. For Vega we have a separate PR #84090. Please let me know if we also want to backport it into 7.10

@stratoula
Copy link
Contributor

@alexwizp yes I meant that we did the fix for TSVB and vega for 7.11. Yes let's also backport the Vega PR ❤️

alexwizp added a commit that referenced this pull request Dec 18, 2020
) (#86448)

* TSVB doesn't communicate it's index-patterns to dashboard (#82964)

* TSVB doesn't communicate it's index-patterns to dashboard

Closes: #81476

* useCustomSearchSource -> getUsedIndexPattern

* fix CI

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
# Conflicts:
#	src/plugins/vis_type_timeseries/public/metrics_type.ts
#	src/plugins/visualizations/public/embeddable/create_vis_embeddable_from_object.ts
#	src/plugins/visualizations/public/vis_types/base_vis_type.ts
#	src/plugins/visualizations/public/vis_types/types.ts

* fix CI
@alexwizp alexwizp deleted the 81476 branch January 16, 2021 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:TSVB TSVB (Time Series Visual Builder) Feature:Visualizations Generic visualization features (in case no more specific feature label is available) release_note:fix Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.11.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TSVB doesn't communicate it's index-patterns to dashboard
8 participants