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

[Lens] Relax counter field checks for saved visualizations with unsupported operations #163515

Merged
merged 9 commits into from
Aug 11, 2023

Conversation

dej611
Copy link
Contributor

@dej611 dej611 commented Aug 9, 2023

Summary

Fix #163473

This PR relaxes a bit the checks on the Lens side for old/saved visualizations with unsupported operations for the counter field type, while preserving those checks for newer visualizations.

Dashboards with "meaningless" operations will now show a warning message:
Screenshot 2023-08-09 at 18 31 21

When in editor the warning is shown at the top-right corner as well:
Screenshot 2023-08-09 at 18 30 31

New visualizations still prevent the user from using the unsupported operations:
Screenshot 2023-08-09 at 18 30 55
Screenshot 2023-08-09 at 18 31 48

There's theoretically a last case where users in old SOs might create a new metric dimension trying to force to use a unsupported operation for a counter field: in this case the logic for a "new" visualization will kick-in, clean the data in the workspace and show a full error. Cancelling such metric dimension will lead to the previous "relaxed" state.

Messages are grouped by field and by top referencing column (i.e. a formula): this means that if a formula uses the same counter field with two different dimensions (i.e. sum(counter_field) + median(counter_field) as myFormula) will show up as a single column (myFormula).

The wording of the message mimics the same documentation copy provided in the ES documentation. Ref: elastic/elasticsearch#97974

Testing SO:

export.ndjson.txt

Checklist

Delete any items that are not applicable to this PR.

@dej611 dej611 added Team:Visualizations Visualization editors, elastic-charts and infrastructure release_note:skip Skip the PR/issue when compiling release notes Feature:Lens v8.10.0 labels Aug 9, 2023
@dej611 dej611 marked this pull request as ready for review August 10, 2023 14:47
@dej611 dej611 requested a review from a team as a code owner August 10, 2023 14:47
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-visualizations @elastic/kibana-visualizations-external (Team:Visualizations)

@stratoula
Copy link
Contributor

@dej611 am I doing something wrong? I am trying to select average with counter field and I see an error not a warning

image

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #14 / ObservabilityApp Observability Rules page Rules table shows the rules table

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
lens 1.4MB 1.4MB +1.9KB

History

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

@dej611
Copy link
Contributor Author

dej611 commented Aug 11, 2023

@dej611 am I doing something wrong? I am trying to select average with counter field and I see an error not a warning

image

For newer configurations the behaviour should be to still avoid "meaningless" operations, as it won't make sense to let them configure it.
For existing SOs instead the warning should be shown - I've attached a Dashboard SO to test it, or you can replicate by manually edit a SO.

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.

Changes LGTM, I tested it locally in Chrome and works as described.

@dej611 dej611 merged commit 4c812e3 into elastic:main Aug 11, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Aug 11, 2023
jloleysens added a commit to jloleysens/kibana that referenced this pull request Aug 11, 2023
* main: (64 commits)
  [ML] Transforms: Fix privileges check. (elastic#163687)
  [Log Explorer] Add test suite for Dataset Selector (elastic#163079)
  [Security Solution][Endpoint] Add API checks to Endpoint Policy create/update for checking `endpointPolicyProtections` is enabled (elastic#163429)
  [Security Solution] Fix flaky test: x-pack/test/detection_engine_api_integration/security_and_spaces/update_prebuilt_rules_package/update_prebuilt_rules_package·ts - update_prebuilt_rules_package should allow user to install prebuilt rules from scratch, then install new rules and upgrade existing rules from the new package (elastic#163241)
  [Security Solution] expandable flyout - replace feature flag with advanced settings toggle (elastic#161614)
  [DOCS] Adds the release notes for the 8.9.1 release. (elastic#163578)
  [FTR] Implement browser network condition utils (elastic#163633)
  [Security Solution] Unskip rules table auto-refresh Cypress tests (elastic#163451)
  [Security Solution] Re-enable fixed rule snoozing Cypress test (elastic#160037)
  [Flaky Test elastic#111821] Mock `moment` to avoid midnight TZ issues (elastic#163157)
  Document interactive setup (elastic#163619)
  [Lens] Align decoration color with text color for layer actions (elastic#163630)
  [Lens] Relax counter field checks for saved visualizations with unsupported operations (elastic#163515)
  [Security Solution][Endpoint] Removes pMap and uses a for loop instead (elastic#163509)
  [Enterprise Search] Update Workplace Search connectors doclink (elastic#163676)
  Update APM (main) (elastic#163623)
  [Serverless] Partially fix lens/maps/visualize breadcrumbs missing title  (elastic#163476)
  [Flaky elastic#118272] Unskip tests (elastic#163319)
  [APM] Make service group saved objects exportable (elastic#163569)
  [Observability AI Assistant] Action menu item (elastic#163463)
  ...
@drewdaemon drewdaemon added backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) and removed backport:skip This commit does not require backporting labels Aug 14, 2023
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Aug 14, 2023
…ported operations (elastic#163515)

## Summary

Fix elastic#163473

This PR relaxes a bit the checks on the Lens side for old/saved
visualizations with unsupported operations for the `counter` field type,
while preserving those checks for newer visualizations.

Dashboards with "meaningless" operations will now show a warning
message:
<img width="556" alt="Screenshot 2023-08-09 at 18 31 21"
src="https://github.com/elastic/kibana/assets/924948/7c8f3739-4957-4d1d-8aaa-e9457b8a4426">

When in editor the warning is shown at the top-right corner as well:
<img width="845" alt="Screenshot 2023-08-09 at 18 30 31"
src="https://github.com/elastic/kibana/assets/924948/c52a7823-d4b9-4efd-9c5d-ca654f3f03a0">

New visualizations still prevent the user from using the unsupported
operations:
<img width="410" alt="Screenshot 2023-08-09 at 18 30 55"
src="https://github.com/elastic/kibana/assets/924948/d2364a01-0dc3-409a-9c0b-3e3a77cb2566">
<img width="848" alt="Screenshot 2023-08-09 at 18 31 48"
src="https://github.com/elastic/kibana/assets/924948/086a7360-6b1a-40a2-90d9-f4e8c7bf3f3a">

There's theoretically a last case where users in old SOs might create a
new metric dimension trying to force to use a unsupported operation for
a counter field: in this case the logic for a "new" visualization will
kick-in, clean the data in the workspace and show a full error.
Cancelling such metric dimension will lead to the previous "relaxed"
state.

Messages are grouped by field and by top referencing column (i.e. a
formula): this means that if a formula uses the same `counter` field
with two different dimensions (i.e. `sum(counter_field) +
median(counter_field)` as `myFormula`) will show up as a single column
(`myFormula`).

The wording of the message mimics the same documentation copy provided
in the ES documentation. Ref:
elastic/elasticsearch#97974

Testing SO:

[export.ndjson.txt](https://github.com/elastic/kibana/files/12304924/export.ndjson.txt)

### Checklist

Delete any items that are not applicable to this PR.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
(cherry picked from commit 4c812e3)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.9

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

dej611 added a commit to dej611/kibana that referenced this pull request Aug 17, 2023
…ported operations (elastic#163515)

## Summary

Fix elastic#163473

This PR relaxes a bit the checks on the Lens side for old/saved
visualizations with unsupported operations for the `counter` field type,
while preserving those checks for newer visualizations.

Dashboards with "meaningless" operations will now show a warning
message:
<img width="556" alt="Screenshot 2023-08-09 at 18 31 21"
src="https://github.com/elastic/kibana/assets/924948/7c8f3739-4957-4d1d-8aaa-e9457b8a4426">

When in editor the warning is shown at the top-right corner as well:
<img width="845" alt="Screenshot 2023-08-09 at 18 30 31"
src="https://github.com/elastic/kibana/assets/924948/c52a7823-d4b9-4efd-9c5d-ca654f3f03a0">

New visualizations still prevent the user from using the unsupported
operations:
<img width="410" alt="Screenshot 2023-08-09 at 18 30 55"
src="https://github.com/elastic/kibana/assets/924948/d2364a01-0dc3-409a-9c0b-3e3a77cb2566">
<img width="848" alt="Screenshot 2023-08-09 at 18 31 48"
src="https://github.com/elastic/kibana/assets/924948/086a7360-6b1a-40a2-90d9-f4e8c7bf3f3a">

There's theoretically a last case where users in old SOs might create a
new metric dimension trying to force to use a unsupported operation for
a counter field: in this case the logic for a "new" visualization will
kick-in, clean the data in the workspace and show a full error.
Cancelling such metric dimension will lead to the previous "relaxed"
state.

Messages are grouped by field and by top referencing column (i.e. a
formula): this means that if a formula uses the same `counter` field
with two different dimensions (i.e. `sum(counter_field) +
median(counter_field)` as `myFormula`) will show up as a single column
(`myFormula`).

The wording of the message mimics the same documentation copy provided
in the ES documentation. Ref:
elastic/elasticsearch#97974

Testing SO:


[export.ndjson.txt](https://github.com/elastic/kibana/files/12304924/export.ndjson.txt)


### Checklist

Delete any items that are not applicable to this PR.

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
dej611 added a commit that referenced this pull request Aug 21, 2023
… unsupported operations (#163515) - manual backport (#164191)

# Backport

This will backport the following commits from `main` to `8.9`:
- [[Lens] Relax counter field checks for saved visualizations with
unsupported operations
(#163515)](#163515)

This is a manual backport which adds a missing mock function, not
available in the automated backport cherry-pick of the PR.
The extra code is here:
`x-pack/plugins/lens/public/datasources/form_based/mocks.ts`

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Marco
Liberati","email":"dej611@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-08-11T09:52:17Z","message":"[Lens]
Relax counter field checks for saved visualizations with unsupported
operations (#163515)\n\n## Summary\r\n\r\nFix #163473\r\n\r\nThis PR
relaxes a bit the checks on the Lens side for
old/saved\r\nvisualizations with unsupported operations for the
`counter` field type,\r\nwhile preserving those checks for newer
visualizations.\r\n\r\nDashboards with \"meaningless\" operations will
now show a warning\r\nmessage:\r\n<img width=\"556\" alt=\"Screenshot
2023-08-09 at 18 31
21\"\r\nsrc=\"https://github.com/elastic/kibana/assets/924948/7c8f3739-4957-4d1d-8aaa-e9457b8a4426\">\r\n\r\nWhen
in editor the warning is shown at the top-right corner as well:\r\n<img
width=\"845\" alt=\"Screenshot 2023-08-09 at 18 30
31\"\r\nsrc=\"https://github.com/elastic/kibana/assets/924948/c52a7823-d4b9-4efd-9c5d-ca654f3f03a0\">\r\n\r\nNew
visualizations still prevent the user from using the
unsupported\r\noperations:\r\n<img width=\"410\" alt=\"Screenshot
2023-08-09 at 18 30
55\"\r\nsrc=\"https://github.com/elastic/kibana/assets/924948/d2364a01-0dc3-409a-9c0b-3e3a77cb2566\">\r\n<img
width=\"848\" alt=\"Screenshot 2023-08-09 at 18 31
48\"\r\nsrc=\"https://github.com/elastic/kibana/assets/924948/086a7360-6b1a-40a2-90d9-f4e8c7bf3f3a\">\r\n\r\nThere's
theoretically a last case where users in old SOs might create a\r\nnew
metric dimension trying to force to use a unsupported operation for\r\na
counter field: in this case the logic for a \"new\" visualization
will\r\nkick-in, clean the data in the workspace and show a full
error.\r\nCancelling such metric dimension will lead to the previous
\"relaxed\"\r\nstate.\r\n\r\nMessages are grouped by field and by top
referencing column (i.e. a\r\nformula): this means that if a formula
uses the same `counter` field\r\nwith two different dimensions (i.e.
`sum(counter_field) +\r\nmedian(counter_field)` as `myFormula`) will
show up as a single column\r\n(`myFormula`).\r\n\r\nThe wording of the
message mimics the same documentation copy provided\r\nin the ES
documentation.
Ref:\r\nhttps://github.com/elastic/elasticsearch/pull/97974\r\n\r\nTesting
SO:\r\n\r\n\r\n[export.ndjson.txt](https://github.com/elastic/kibana/files/12304924/export.ndjson.txt)\r\n\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [x] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Stratoula Kalafateli
<efstratia.kalafateli@elastic.co>","sha":"4c812e3b6d1a4e477768dae04047e79bbdc940ff","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Visualizations","release_note:skip","Feature:Lens","backport:prev-minor","v8.10.0"],"number":163515,"url":"https://github.com/elastic/kibana/pull/163515","mergeCommit":{"message":"[Lens]
Relax counter field checks for saved visualizations with unsupported
operations (#163515)\n\n## Summary\r\n\r\nFix #163473\r\n\r\nThis PR
relaxes a bit the checks on the Lens side for
old/saved\r\nvisualizations with unsupported operations for the
`counter` field type,\r\nwhile preserving those checks for newer
visualizations.\r\n\r\nDashboards with \"meaningless\" operations will
now show a warning\r\nmessage:\r\n<img width=\"556\" alt=\"Screenshot
2023-08-09 at 18 31
21\"\r\nsrc=\"https://github.com/elastic/kibana/assets/924948/7c8f3739-4957-4d1d-8aaa-e9457b8a4426\">\r\n\r\nWhen
in editor the warning is shown at the top-right corner as well:\r\n<img
width=\"845\" alt=\"Screenshot 2023-08-09 at 18 30
31\"\r\nsrc=\"https://github.com/elastic/kibana/assets/924948/c52a7823-d4b9-4efd-9c5d-ca654f3f03a0\">\r\n\r\nNew
visualizations still prevent the user from using the
unsupported\r\noperations:\r\n<img width=\"410\" alt=\"Screenshot
2023-08-09 at 18 30
55\"\r\nsrc=\"https://github.com/elastic/kibana/assets/924948/d2364a01-0dc3-409a-9c0b-3e3a77cb2566\">\r\n<img
width=\"848\" alt=\"Screenshot 2023-08-09 at 18 31
48\"\r\nsrc=\"https://github.com/elastic/kibana/assets/924948/086a7360-6b1a-40a2-90d9-f4e8c7bf3f3a\">\r\n\r\nThere's
theoretically a last case where users in old SOs might create a\r\nnew
metric dimension trying to force to use a unsupported operation for\r\na
counter field: in this case the logic for a \"new\" visualization
will\r\nkick-in, clean the data in the workspace and show a full
error.\r\nCancelling such metric dimension will lead to the previous
\"relaxed\"\r\nstate.\r\n\r\nMessages are grouped by field and by top
referencing column (i.e. a\r\nformula): this means that if a formula
uses the same `counter` field\r\nwith two different dimensions (i.e.
`sum(counter_field) +\r\nmedian(counter_field)` as `myFormula`) will
show up as a single column\r\n(`myFormula`).\r\n\r\nThe wording of the
message mimics the same documentation copy provided\r\nin the ES
documentation.
Ref:\r\nhttps://github.com/elastic/elasticsearch/pull/97974\r\n\r\nTesting
SO:\r\n\r\n\r\n[export.ndjson.txt](https://github.com/elastic/kibana/files/12304924/export.ndjson.txt)\r\n\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [x] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Stratoula Kalafateli
<efstratia.kalafateli@elastic.co>","sha":"4c812e3b6d1a4e477768dae04047e79bbdc940ff"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/163515","number":163515,"mergeCommit":{"message":"[Lens]
Relax counter field checks for saved visualizations with unsupported
operations (#163515)\n\n## Summary\r\n\r\nFix #163473\r\n\r\nThis PR
relaxes a bit the checks on the Lens side for
old/saved\r\nvisualizations with unsupported operations for the
`counter` field type,\r\nwhile preserving those checks for newer
visualizations.\r\n\r\nDashboards with \"meaningless\" operations will
now show a warning\r\nmessage:\r\n<img width=\"556\" alt=\"Screenshot
2023-08-09 at 18 31
21\"\r\nsrc=\"https://github.com/elastic/kibana/assets/924948/7c8f3739-4957-4d1d-8aaa-e9457b8a4426\">\r\n\r\nWhen
in editor the warning is shown at the top-right corner as well:\r\n<img
width=\"845\" alt=\"Screenshot 2023-08-09 at 18 30
31\"\r\nsrc=\"https://github.com/elastic/kibana/assets/924948/c52a7823-d4b9-4efd-9c5d-ca654f3f03a0\">\r\n\r\nNew
visualizations still prevent the user from using the
unsupported\r\noperations:\r\n<img width=\"410\" alt=\"Screenshot
2023-08-09 at 18 30
55\"\r\nsrc=\"https://github.com/elastic/kibana/assets/924948/d2364a01-0dc3-409a-9c0b-3e3a77cb2566\">\r\n<img
width=\"848\" alt=\"Screenshot 2023-08-09 at 18 31
48\"\r\nsrc=\"https://github.com/elastic/kibana/assets/924948/086a7360-6b1a-40a2-90d9-f4e8c7bf3f3a\">\r\n\r\nThere's
theoretically a last case where users in old SOs might create a\r\nnew
metric dimension trying to force to use a unsupported operation for\r\na
counter field: in this case the logic for a \"new\" visualization
will\r\nkick-in, clean the data in the workspace and show a full
error.\r\nCancelling such metric dimension will lead to the previous
\"relaxed\"\r\nstate.\r\n\r\nMessages are grouped by field and by top
referencing column (i.e. a\r\nformula): this means that if a formula
uses the same `counter` field\r\nwith two different dimensions (i.e.
`sum(counter_field) +\r\nmedian(counter_field)` as `myFormula`) will
show up as a single column\r\n(`myFormula`).\r\n\r\nThe wording of the
message mimics the same documentation copy provided\r\nin the ES
documentation.
Ref:\r\nhttps://github.com/elastic/elasticsearch/pull/97974\r\n\r\nTesting
SO:\r\n\r\n\r\n[export.ndjson.txt](https://github.com/elastic/kibana/files/12304924/export.ndjson.txt)\r\n\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [x] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[x]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [x] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Stratoula Kalafateli
<efstratia.kalafateli@elastic.co>","sha":"4c812e3b6d1a4e477768dae04047e79bbdc940ff"}}]}]
BACKPORT-->

---------

Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) Feature:Lens release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.9.2 v8.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] Relax checks for time_series_metric counter and show warnings on unsupported operations
6 participants