-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Timespan user variable #117548
Comments
hi @omegahack0. Can you expand on this request a bit more? I'm not sure I follow and I think a more thorough explanation for the feature will help us triage with the correct team. |
Hey @nickpeihl so what I had in my mind was having a variable that you could call in a tsvb visualization, that would represent the amount of time that the user has selected for their timespan. So within the Math function of the tsvb visualization you could take something like the count of the amount of records you got and then divide that by the variable Im suggesting and that would give you the the average amount of records you got for that time. I hope this helps clear up what I ment |
Pinging @elastic/kibana-vis-editors @elastic/kibana-vis-editors-external (Team:VisEditors) |
This is related to #94605 - there are different ways we could expose functionality to cover this use case. |
With supporting date math into Lens formula this has been possible. We don't have a variable but you can do it quite easy. |
cc @dej611 as we are working on adding time specific variables in Lens formulas |
## Summary Fixes #151827, Fixes #117548 This PR contains constant function features in Lens formula: * direct exposure of the `time_range()` - as suggested in #117548) <img width="297" alt="Screenshot 2023-05-29 at 12 05 43" src="https://github.com/elastic/kibana/assets/924948/8dbd63a6-c5ec-4177-a4a2-cc0770a495bc"> * `interval()` (as intended in #151827) <img width="359" alt="Screenshot 2023-05-29 at 12 04 18" src="https://github.com/elastic/kibana/assets/924948/8c3a4637-bd23-4b4d-8a5f-36853ccbfee3"> * and `now()` (as suggested in [here](#112851 (comment))) functions in the formula input <img width="364" alt="Screenshot 2023-05-25 at 14 30 14" src="https://github.com/elastic/kibana/assets/924948/2137717b-44a0-4531-bcc2-1fbda40368ba"> A visual explanation of what each constant represent: <img width="677" alt="Screenshot 2023-05-29 at 11 56 16" src="https://github.com/elastic/kibana/assets/924948/b7b7e92c-b061-4cce-a77e-e7baeab323a8"> Documentation: <img width="546" alt="Screenshot 2023-05-31 at 12 59 40" src="https://github.com/elastic/kibana/assets/924948/1fea7e88-6e4f-4958-949f-6b71a770cd44"> Some example usage <img width="683" alt="Screenshot 2023-05-25 at 13 33 26" src="https://github.com/elastic/kibana/assets/924948/e03442ab-0062-4999-8a38-c00a66b3b13b"> TSVB => Lens with `params._interval` support: ![tsvb_to_lens_with_interval](https://github.com/elastic/kibana/assets/924948/6ea86bd1-8e71-4928-b2e2-7ad27537b33d) **Notes**: * context values work like static values, with the same limits, therefore it is not possible to build a date histogram with a context value alone (i.e. a formula with only `interval()` or `now()`). It works ok without the `Date Histogram` dimension. * The `interval()` function will report an error if used without a configured `Date Histogram` dimension: <img width="671" alt="Screenshot 2023-05-29 at 12 14 13" src="https://github.com/elastic/kibana/assets/924948/ca67f102-35bb-4e4d-ab16-15d1be4cadcc"> * The `interval()` function does not take into account different bucket interval size (i.e. DST changes, leap years, etc...), rather return the same value to all the buckets. This is the same behaviour as in TSVB, but in Lens it can be a problem due to the usage of `calendar_interval`. * I had to duplicate a couple of function from the helpers to avoid issues with tests. I've tried a different organization of the helpers (between pure vs impure fns) but that took longer than expected, so I would defer this task later in another PR. <details> <summary>General approach with `constant(...)` removed</summary> * a more general approach using `constants(value="...")` <img width="301" alt="Screenshot 2023-05-29 at 12 07 23" src="https://github.com/elastic/kibana/assets/924948/0a800aa4-8db5-4055-996d-344d37adfc01"> </details> A cloud deployment has been created to test both approaches here. Let me know which one do you prefer cc @elastic/kibana-visualizations ### 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: kibanamachine <[email protected]> Co-authored-by: Stratoula Kalafateli <[email protected]>
Describe the feature:
the duration of whatever timespan is selected to be used as a variable
Describe a specific use case for the feature:
With the timespan being a field that can be read from the user side of things such as within a tsvb visualization, the user can more easily use the timespan to make charts for things like utilization that will scale with whatever time span is selected.
The text was updated successfully, but these errors were encountered: