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] Register all expression functions to the server #97134

Closed
flash1293 opened this issue Apr 14, 2021 · 7 comments · Fixed by #105455
Closed

[Lens] Register all expression functions to the server #97134

flash1293 opened this issue Apr 14, 2021 · 7 comments · Fixed by #105455
Assignees
Labels
Feature:Lens Team:Visualizations Visualization editors, elastic-charts and infrastructure technical debt Improvement of the software architecture and operational architecture
Projects

Comments

@flash1293
Copy link
Contributor

To make it possible to run Lens expressions on the Kibana server (for features like alerting), all expression functions have to be registered on the server as well as on the client. To do that, they have to be moved to a central common folder in the plugin folder, and imported and registered in the server side plugin as well as the current registration on the client side.

List of functions:

  • lens_time_scale
  • lens_counter_rate
  • lens_rename_columns
  • lens_format_column
  • lens_datatable_column
  • lens_datatable (relies on field formatter service)
  • lens_metric_chart
  • lens_pie
  • lens_xy_legendConfig
  • lens_xy_yConfig
  • lens_xy_tickLabelsConfig
  • lens_xy_gridlinesConfig
  • lens_xy_axisTitlesVisibilityConfig
  • lens_xy_layer
  • lens_xy_chart

We also have to move the suffix formatter to the server because the datatable function depends on field formatters x-pack/plugins/lens/public/indexpattern_datasource/suffix_formatter.ts

@flash1293 flash1293 added technical debt Improvement of the software architecture and operational architecture Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:Lens labels Apr 14, 2021
@flash1293 flash1293 added this to Long-term goals in Lens via automation Apr 14, 2021
@elasticmachine
Copy link
Contributor

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

@flash1293 flash1293 moved this from Long-term goals to 7.14 in Lens Apr 27, 2021
@ghudgins
Copy link

there's a concern coming on this work in the future (not this issue): how does time zone get included as part of the execution context if we are moving things server side. for reporting we include time zone in the saved object. we can do this task (moving logic to server) as long as the client is initiating the request...but as soon as we take on async reporting or csv export we need a way to pass in the time zone in some way. need an issue for this

@wylieconlon
Copy link
Contributor

@ghudgins The approach that reporting has taken for time zones is one that would also work for Lens, I believe this is already a solved problem. If a user doesn't pass the time zone to the reporting task, then it will fall back to the dateFormat:tz setting. If the dateFormat:tz setting is Browser, which is the default, then it will use the Kibana server timezone.

@flash1293
Copy link
Contributor Author

@wylieconlon The "difficult" part here is that we would run an expression for these use cases (alerting/aggregated csv reporting) which is async for each function execution. So basically we would need to pass the current time zone to each expression function which would have to change the global moment timezone to the one of the current execution, then set it back to the server default (otherwise it can interfere with other runs). Maybe the interpreter can do this in a single place so we don't have to make sure each function is handling it.

Right now I think we would have an issue with time shifts and time scaling (both of them using moment, expecting it being set to the right time zone).

@dej611
Copy link
Contributor

dej611 commented Jul 20, 2021

Lens automation moved this from 7.15 to Done Jul 26, 2021
@dej611
Copy link
Contributor

dej611 commented Jul 26, 2021

Next steps:

  1. Register the expression functions in common on server
  • Mind getDatatable requires an async registration for the data formatter plugin
  • Add the timezone info to expression context, when in browser pick it using moment, or fallback to UISettings when not provided
    • Make lens_time_scale function to pick it up from context
  1. Extend render function to log data into the inspector

@dej611 dej611 reopened this Jul 26, 2021
Lens automation moved this from Done to In progress Jul 26, 2021
alexwizp added a commit to alexwizp/kibana that referenced this issue Aug 6, 2021
alexwizp added a commit to alexwizp/kibana that referenced this issue Aug 6, 2021
alexwizp added a commit to alexwizp/kibana that referenced this issue Aug 9, 2021
alexwizp added a commit that referenced this issue Aug 11, 2021
Part of:  #97134

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
alexwizp added a commit to alexwizp/kibana that referenced this issue Aug 11, 2021
Part of:  elastic#97134

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
alexwizp added a commit that referenced this issue Aug 11, 2021
…8175)

Part of:  #97134

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
alexwizp added a commit to alexwizp/kibana that referenced this issue Aug 12, 2021
alexwizp added a commit that referenced this issue Aug 17, 2021
#108366)

Part of: #97134

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
alexwizp added a commit to alexwizp/kibana that referenced this issue Aug 17, 2021
elastic#108366)

Part of: elastic#97134

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@alexwizp
Copy link
Contributor

the goal is achieved, the functions are available on the server, issue can be closed

Lens automation moved this from In progress to Done Aug 17, 2021
alexwizp added a commit that referenced this issue Aug 17, 2021
#108366) (#108892)

Part of: #97134

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Lens Team:Visualizations Visualization editors, elastic-charts and infrastructure technical debt Improvement of the software architecture and operational architecture
Projects
No open projects
Lens
  
Done
Development

Successfully merging a pull request may close this issue.

6 participants