-
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
[Lens] Enable new context constants in formula #158452
Conversation
…o feature/151827
Pinging @elastic/kibana-visualizations @elastic/kibana-visualizations-external (Team:Visualizations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love it!! I have some questions:
- Why the timerange() gives me B in the new metric/
- Why this returns no data?
- I am not sure about the kibana context title here. It makes sense to me but does it make sense for the users/
@gchaps @KOTungseth can you help here?
I see you've taken a ~15 days time range, so in ms number values it's about 1.3 billion ms:
That is because it's subject to the same logic as any static value, unfortunately, over a date histogram: same applies if you write
Yes, a contribution on their side would be great here 👍 |
Oh it is a billion not bytes 😆 |
defaultMessage: 'Kibana context', | ||
}), | ||
i18n.translate('xpack.lens.formulaDocumentation.constantsSectionDescription', { | ||
defaultMessage: 'Functions used to retrieve Kibana context variables.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other Formula sections in this window include thoroughly broken down definitions.
How about:
These functions are used to retrieve Kibana context variables, which are... and help you to....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've revisited the copy here. Maybe we could discuss a bit and have a consistent copy for the entire section with a follow up PR here?
label: 'Date histogram interval', | ||
description: i18n.translate('xpack.lens.indexPattern.interval.documentation.markdown', { | ||
defaultMessage: ` | ||
The current date histogram interval bucket expressed in milliseconds (ms). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
The specified minimum interval for the date histogram, in milliseconds (ms).
label: 'Current now', | ||
description: i18n.translate('xpack.lens.indexPattern.now.documentation.markdown', { | ||
defaultMessage: ` | ||
The current now moment used in Kibana expressed in milliseconds (ms). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure what now moment
means?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant the instant value of now
, expressed in ms
label: 'Time range', | ||
description: i18n.translate('xpack.lens.indexPattern.timeRange.documentation.markdown', { | ||
defaultMessage: ` | ||
The current time range expressed in milliseconds (ms). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
The specified time range, in milliseconds (ms).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
Summary
Fixes #151827, Fixes #117548
This PR contains constant function features in Lens formula:
time_range()
- as suggested in Timespan user variable #117548)interval()
(as intended in [Lens] Support bucket interval on formulas #151827)now()
(as suggested in here) functions in the formula inputA visual explanation of what each constant represent:
Documentation:
Some example usage
TSVB => Lens with
params._interval
support:Notes:
interval()
ornow()
). It works ok without theDate Histogram
dimension.interval()
function will report an error if used without a configuredDate Histogram
dimension: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 ofcalendar_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.
General approach with `constant(...)` removed
* a more general approach using `constants(value="...")`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.
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:
For maintainers