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 is retaining results even after indexpattern is removed from opt… #32003

Merged
merged 7 commits into from
Mar 1, 2019

Conversation

alexwizp
Copy link
Contributor

Fix: #31951

Checklist

For maintainers

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@alexwizp
Copy link
Contributor Author

alexwizp commented Feb 27, 2019

Current behavior:

  • when creating a new tsvb viz value for index pattern we take from the configuration (defaultIndex value);
  • when opening an existing tsvb viz with empty indexpattern value for index pattern we take from the configuration (defaultIndex value) like in previous case;
  • clearing the index-pattern field we set empty string as a value for index pattern (it's equivalent of * - all available indexes)

My main concern in points 2 and 3. I do not understand why, if the user clears the index pattern field, we show him data for all available indexes, but after saving and reopening saved visualization, we replace this index with the default index pattern? It's confusing and I think we should replace index pattern only for one case: it's a creating a new tsvb viz.

How to fix it: in the file src/legacy/core_plugins/metrics/public/components/vis_editor.js we should do:

image

Any ideas?
@AlonaNadler @bhavyarm @timroes @markov00

@timroes
Copy link
Contributor

timroes commented Feb 28, 2019

After syncing with @markov00 about that, we think we should use the behavior that you suggested, where we use undefined by default and replace an undefined (but not an empty string) to the default index pattern in the editor (in such a way, that the index pattern name will actually be stored when saving - which this PR does as far as I tested).

There is still some weird behavior around that empty string index pattern and what the user sees in the editor. So we came up with the following suggestion:

  • If the saved object has an empty string in there, we're treating that as the "default index" pattern for querying.
  • We will also NOT replace the "empty string" in the editor by the name of the default index pattern (since that is one of the large confusions around that feature). Instead we will just show the empty index pattern box.
  • We'll add a placeholder to the index pattern box that has the name of the default index pattern in it.
  • When the field is empty, we'll show a warning (below or some icon with a tooltip behind the box), that tells "If no index pattern is defined the default index pattern is used. To query all indexes use *."

That way we should be very explicit and not break any existing functionality. New visualizations will have the default index pattern shown in the editor (via the undefined check) and also saved in the saved object. Old existing visualizations (with empty index pattern) will still search for the default index pattern. And we're making that behavior clear to the user via placeholder and hints.

If we would e.g. start querying all indexes in case it's an empty string, the old saved TSVB visualizations will behave weird, because for the user it looked like the default index in the editor (since we're replacing it there), but then on dashboard it will load all indexes (the weird bug in the past). So we should stay with loading the default index pattern for all empty string index patterns. We also can't easily migrate those empty strings, since during the saved object migration phase Kibana isn't started completely, meaning we're not having access to the configuration and could see what the default index pattern is.

@alexwizp
Copy link
Contributor Author

@timroes @bhavyarm Please review
31590_22

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@markov00
Copy link
Member

markov00 commented Mar 1, 2019

@alexwizp With these changes I don't see the timestamp field populated with the right values for the default index pattern. The field I'm currently seeing seems to be related to the * pattern.
Can you please verify that and check also with @sulemanof that he is currently working on these fields?

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Member

@markov00 markov00 left a comment

Choose a reason for hiding this comment

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

Tested locally LGTM

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

Tested and works, LGTM 👍 I added one small nitpick about a typo

@@ -62,11 +63,16 @@ export const IndexPattern = props => {
id="tsvb.indexPatternLabel"
defaultMessage="Index pattern"
/>)}
helpText={(model.default_index_pattern && !model[indexPatternName] && <FormattedMessage
id="tsvb.indexPattern.searchByDefaultIndex"
defaultMessage="Default index pattern is used. To query all indexes use *"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it should use indices as plural of index - but I wasn't sure and searched for it in the Kibana codebase - 2800 vs 141 in favor of indices, so I think we should go with it :)

Copy link
Contributor

@bhavyarm bhavyarm left a comment

Choose a reason for hiding this comment

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

LGTM. Please backport to 6.7.0

Copy link
Contributor

@sulemanof sulemanof left a comment

Choose a reason for hiding this comment

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

LGTM

@alexwizp alexwizp merged commit f733308 into elastic:master Mar 1, 2019
alexwizp added a commit to alexwizp/kibana that referenced this pull request Mar 1, 2019
elastic#32003)

# Conflicts:
#	src/legacy/core_plugins/metrics/server/lib/get_fields.js
alexwizp added a commit to alexwizp/kibana that referenced this pull request Mar 1, 2019
elastic#32003)

# Conflicts:
#	src/legacy/core_plugins/metrics/server/lib/get_fields.js
alexwizp added a commit that referenced this pull request Mar 4, 2019
#32003) (#32320)

# Conflicts:
#	src/legacy/core_plugins/metrics/server/lib/get_fields.js
alexwizp added a commit that referenced this pull request Mar 4, 2019
#32003) (#32319)

# Conflicts:
#	src/legacy/core_plugins/metrics/server/lib/get_fields.js
@alexwizp alexwizp deleted the 31951 branch January 4, 2020 08:12
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.

7 participants