[Canvas] How to pass variable as timerange to savedVisualization

I have created a canvas with multiple Kibana visualization and need to dynamically (from url parameter" pass the "from" argument of the visualization. It works until I save/run the expression at which point it changes the value to hard coded,

My url is :
https://test.com/app/canvas?target=60#/workpad/workpad-id/page/1

with expression

savedVisualization id="<visualization-id>" timerange={timerange from={string "now-" {urlparam param="target" default=30} "d/d"} to="now"}
| render

However, when I save/refresh the page the expression automatically changes to

savedVisualization id="<visualization-id>" timerange={timerange from="now-60d/d" to="now"}
| render

and the value now-60d/d becomes hardcoded instead of being picked up from the query string parameter ( funnily enough the first time it does pick it from the query string parameter as 60)

Also, the same issue does not occur in markdown element.

Is there are another way to pass dynamic time range values to visualizations in a canvas ? [ We have mutltiple visualizations on a canvas and don't want to duplicate them just for the sake of different time ranges - also a single time filter at the top of canvas does not work because it works using default timefield which is different to visualizations and there is a custom date format ]

I don't see that as doable right now. But as a workaround for your timefield that is different between visualizations a solution would be field aliases added to make all timefields the same.

Hi Marius,

Thank you for replying and field aliases is a good idea, however it does not solve our particular use case since the timefield is same across all visualisations its just that we need to set it once and use across all visualisations.
We resolved it for now by adding a single timefilter element to the top of canvas but we had to create a new timestamp field with format strict_date_optional_time ( the query for time filter in Canvas does not seem to pass the "format: 'strict_date_optional_time'" property when it constructs the queries for Elastic hence it was failing previously and therefore we had to switch to using a new field that has strict_date_... in its mapping).

Thanks,

Salman

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.