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] Time shift previous period #104259

Closed
Tracked by #57708
ghudgins opened this issue Jul 2, 2021 · 7 comments · Fixed by #121284 or #149126
Closed
Tracked by #57708

[Lens] Time shift previous period #104259

ghudgins opened this issue Jul 2, 2021 · 7 comments · Fixed by #121284 or #149126
Assignees
Labels
enhancement New value added to drive a business result Feature:Lens Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@ghudgins
Copy link
Contributor

ghudgins commented Jul 2, 2021

Describe the feature:
Allow time shifts involving date histograms to be previous to the overall time period of the report:

If the date histogram is 30 second intervals and the report is "last 15 minutes" than "previous overall period" would be a 15 minute shift. Today "previous" time shifts when used on date histogram appears to shift back one previous date histogram interval (30 seconds in this case) which I don't believe is as useful given the user can see those values anyway (except one previous period on the end of the histogram)

image

Describe a specific use case for the feature:
Shifts involving data that's also visible on the range don't seem as useful as an indentical shift to the overall reporting period. So if I dynamically select "3 hours" it would be nice if there was an option that generated the 3 previous hours automatically.

I believe it works this way if you aren't using a date histogram (previous is the previous overall time period)

@ghudgins ghudgins added discuss Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:Lens labels Jul 2, 2021
@elasticmachine
Copy link
Contributor

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

@ghudgins
Copy link
Contributor Author

ghudgins commented Jul 8, 2021

as discussed today, we can use this issue to track bringing previous back to time shifts (since it's been removed). need to answer:

  • re-define Previous to be this previous overall idea?
  • do we include Previous_bucket to get at the main use case of % growth to previous bucket....could we do this as an option on differences so we don't need this here?

@ghudgins ghudgins changed the title [Lens] Time shift previous *overall* period [Lens] Time shift previous period Jul 8, 2021
@flash1293
Copy link
Contributor

flash1293 commented Jul 8, 2021

There is a small difference between time shift previous bucket and something like differences - time shift previous bucket does its own data fetching which means the very first bucket will also have a "previous" one of the data allows it (the bucket which is not in the overall time range anymore).

If we want this, then I think we need a previous_bucket shift (naming tbd - IMHO previous for previous bucket and previous_range for overall previous would be nice). If we don't need it, we can go with a new function used like this (always pulling the data from the previous bucket leaving the first one empty): previous(count()). The previous function would be almost identical to differences and very easy to build.

@flash1293
Copy link
Contributor

Thinking about it, I like the previous(count()) - it clearly separates separate data fetching from calculations looking at other buckets of the same series. If someone really needs the very first one, they can manually keep the shift interval and date histogram interval in sync but I expect that to be an edge case.

@flash1293 flash1293 added the enhancement New value added to drive a business result label Jul 8, 2021
@ghudgins
Copy link
Contributor Author

this issue #62381 shows why we need a "previous bucket" and the "overall previous" time period as distinct options

@ghudgins
Copy link
Contributor Author

scope this issue for only the "overall previous" or "previous range" concept and created #115776 to account for the bucket-style functionality

@dej611
Copy link
Contributor

dej611 commented Nov 9, 2022

I think it would be possible to add the previous support even when a date histogram is declared with the same trick used for #144564 to compute a round interval shift.

dej611 added a commit that referenced this issue Jan 24, 2023
## Summary

Fixes #104259 

This PR expands the support of the `previous` time shift for
visualisations with a date histogram defined.
On the implementation side, an absolute time shift in the shape of
`endAt( startRange )` is leveraged to make it work the `previous` shift:
anchoring the shift to the beginning of the current range will make sure
to compute the right shift in terms of buckets in order to avoid
misaligned shifts and the main reason why this feature has been disabled
initially.

I've tried to condense an explanation here with this diagram of the
misalignment problem:


![previous_before](https://user-images.githubusercontent.com/924948/213234848-40e3382a-843d-43fa-83d1-769a5f2e7953.png)

With the current approach, there's a small time range overlap between
the two requested interval, but that's the result of the rounding logic
to get both shifts aligned.


![previous_2](https://user-images.githubusercontent.com/924948/213235429-1c99aefb-e18b-450a-b2d7-45b7d74c9e71.png)

The only alternative to avoid the overlap is to get a gap between the
two, but the former seems a better result to me.

### Checklist

Delete any items that are not applicable to this PR.

- [ ] 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)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [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
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.

When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:

| Risk | Probability | Severity | Mitigation/Notes |

|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces—unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes—Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

Co-authored-by: Stratoula Kalafateli <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New value added to drive a business result Feature:Lens Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
None yet
4 participants