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] Runs the migration correctly for the drop last bucket #121734

Merged
merged 3 commits into from
Dec 23, 2021

Conversation

stratoula
Copy link
Contributor

@stratoula stratoula commented Dec 21, 2021

Summary

Fixes #121684

The problem

On 7.14 we changed the default behavior of the Drop last bucket setting from Yes to No. We also created another PR that adds a migration script (for < 7.14.0 SOs) #110782. What this migration does:

  • Checks if the global drop_last_bucket setting is set. If no, it adds the property with 1 (Drop last bucket ? Yes)
  • Checks if the chart uses the override dataview setting, and changes the series_drop_last_bucket to 1

This works fine for all charts / dashboards that migrate from a version prior to 7.14.0 (and for the metricbeats new installations)

In 7.15, beats changed their visualizations SOs (for example here https://github.com/elastic/beats/blob/master/metricbeat/module/system/_meta/kibana/7/visualization/83e12df0-1b91-11e7-bec4-a5e9ec5cab8b-ecs.json) and the new migration version became v7.14.0. This means that the above migration doesn't run for the newly created metricbeats dashboards (7.15++)

The fix

I created another migration (7.17). This is not the same migration that runs for 7.14.0 because we can't use it unfortunately if the override index pattern setting is used. This migration checks if the global drop_last_bucket setting is set. If no, it adds the property with 1 (Drop last bucket ? Yes)

This is safe as the drop_last_bucket is saved with the SO regardless the value from 7.14++. This means:

  • For a prior to 7.14 viz, the first migration will run and add the value if it doesn't exist.
  • For viz created for 7.14 and above, this value is saved in the SO and the second migration will run but won't affect the SO as the property exists.

Unfortunately this is not safe for the visualizations that are using the override index pattern setting and have been created for 7.14 +. The reason is that the if the default value of series_drop_last_bucket (default is No), this is not saved in the SO. What it means if I run the migration:

  • For a prior to 7.14 viz, the first migration will run and add the value if it doesn't exist. Then the second migration will run but the property has already be set so nothing will change to the SO. Everything good so far.
  • BUT for a viz that was created on 7.14++ that uses the override index pattern and uses the default value (drop last bucket No), if I run the migration that created on 7.14.0, it will set this value to Yes but this is not what the user wants. The user used the default value which is No.
    The above cases can't be solved by us unfortunately. I think that they should be changed on the beats side. As far as I can see they are 4 beats charts that use the 'override_index_pattern : 1' property https://github.com/elastic/beats/search?p=1&q=override_index_pattern. I think that we should update them with adding series_drop_last_bucket : 1

In order this to never happen again, this PR except from adding the migration, also adds the default values for the override_index_pattern and series_drop_last_bucket for a newly created TSVB chart. With this change, the default values will always be stored in the SO.

How to test

  1. Install the metricbeat dashboards and check the gauges visualizations. The drop_last_bucket setting should be set to Yes
    v8.1 newly installed metricbeat dashboard
    image

and the dashboard
image

  1. Create a prior to 7.14 viz with different values of the drop last bucket and migrate it locally. Check the viz that they are working as expected. Test by value and by ref charts.
  2. Do the same for a 7.14++ viz. Test by value and by ref charts.

Checklist

@stratoula
Copy link
Contributor Author

stratoula commented Dec 21, 2021

@flash1293 as I describe on the PR, I can partially fix it. The migration can run safely for the global option
image

but not for the series option (when the override data view is set to true)
image

I think that this should be fixed on the beats side. https://github.com/elastic/beats/search?p=2&q=override_index_pattern There are only 4 visualizations as far as I can see on the repo that need to be updated. Wdyt?
(From the results above, I have excluded the charts that have the override_index_pattern set to 0 and the ones that set the series_drop_last_bucket .

@stratoula stratoula added Feature:TSVB TSVB (Time Series Visual Builder) release_note:fix v7.17.0 v8.0.0 v8.1.0 Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Dec 21, 2021
@stratoula stratoula marked this pull request as ready for review December 21, 2021 18:04
@stratoula stratoula requested a review from a team as a code owner December 21, 2021 18:04
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-vis-editors @elastic/kibana-vis-editors-external (Team:VisEditors)

Copy link
Contributor

@alexwizp alexwizp left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@dej611 dej611 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 with Metricbeat dashboard and importing SOs.

Comment on lines +48 to +51
params: {
...visState.params,
drop_last_bucket: visState.params.drop_last_bucket ?? 1,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think that if you invert the result is the same:

Suggested change
params: {
...visState.params,
drop_last_bucket: visState.params.drop_last_bucket ?? 1,
},
params: {
drop_last_bucket: 1,
...visState.params
},

@stratoula stratoula added the auto-backport Deprecated - use backport:version if exact versions are needed label Dec 23, 2021
@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
visTypeTimeseries 447.6KB 447.6KB +51.0B

Page load bundle

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

id before after diff
visTypeTimeseries 14.6KB 14.7KB +51.0B

History

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

@stratoula stratoula merged commit b4c2d2c into elastic:main Dec 23, 2021
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Dec 23, 2021
…#121734)

* [TSVB] Runs the migration correctly for the drop last bucket

* [TSVB] Run the migration for drop_last_bucket

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

💔 Backport failed

Status Branch Result
8.0
7.17 Commit could not be cherrypicked due to conflicts

Successful backport PRs will be merged automatically after passing CI.

To backport manually run:
node scripts/backport --pr 121734

stratoula added a commit to stratoula/kibana that referenced this pull request Dec 23, 2021
…#121734)

* [TSVB] Runs the migration correctly for the drop last bucket

* [TSVB] Run the migration for drop_last_bucket

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
# Conflicts:
#	src/plugins/visualizations/server/embeddable/visualize_embeddable_factory.ts
#	src/plugins/visualizations/server/migrations/visualization_saved_object_migrations.test.ts
#	src/plugins/visualizations/server/migrations/visualization_saved_object_migrations.ts
kibanamachine added a commit that referenced this pull request Dec 23, 2021
#121939)

* [TSVB] Runs the migration correctly for the drop last bucket

* [TSVB] Run the migration for drop_last_bucket

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

Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Dec 27, 2021
@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

1 similar comment
@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Dec 29, 2021
stratoula added a commit that referenced this pull request Dec 29, 2021
…121734) (#121940)

* [TSVB] Runs the migration correctly for the drop last bucket (#121734)

* [TSVB] Runs the migration correctly for the drop last bucket

* [TSVB] Run the migration for drop_last_bucket

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
# Conflicts:
#	src/plugins/visualizations/server/embeddable/visualize_embeddable_factory.ts
#	src/plugins/visualizations/server/migrations/visualization_saved_object_migrations.test.ts
#	src/plugins/visualizations/server/migrations/visualization_saved_object_migrations.ts

* Commit test

* Fix test

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed Feature:TSVB TSVB (Time Series Visual Builder) release_note:fix Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.17.0 v8.0.0 v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Metrics] [Dashboards] Several viz on [Metricbeat System] Host overview ECS dashboard are broken
6 participants