elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.71k stars 8.13k forks source link

[Lens] context formula functions don't update on dashboard #170762

Closed drewdaemon closed 9 months ago

drewdaemon commented 10 months ago

Kibana version: 8.11, maybe earlier

Describe the bug: The result of the time_range, now, and interval formula functions should be updated according to the current time range as well as the current moment in time.

For example, when the time range is changed, so should the result of time_range. This works in Lens, but not in Dashboard (embeddable).

Steps to reproduce:

  1. Create metric visualization
  2. Set primary metric dimension to time_range()
  3. Change time range within editor
  4. Notice that the result changes
  5. Add to dashboard
  6. Change time range in dashboard
  7. Result is frozen

Screenshots (if relevant):

https://github.com/elastic/kibana/assets/315764/75600154-9c0a-499c-b20a-af92bd1f6b5c

elasticmachine commented 10 months ago

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

drewdaemon commented 9 months ago

The time range is built into the (data source) expression when the expression is created.

In the editor, the expression is recreated from scratch every time the time range changes, leading to an updated value for time_range().

However, in the embeddable, we only generate the expression once at load time. Because of this, the original time range value persists no matter what the user does.