How to return day num in Kibana Scripted field

Hi all, Im using ES query in multiple Timelion charts to compare data for multiple dates. So I used new variables e.x: $u1=-32d, $u2=-69d in below es() query. Can anyone guide me how to use this as a scripted field to be reused in multiple charts instead of changing the dates for each chart everytime.

'''
$u1='-32d',$u2='-69d',
.es(index=jobdata-,metric=sum:MIPS,interval=300s,timefield=int_starttime_ts,offset=$u1,q='(jobname.keyword:"xxxxx")').lines(width=1).label(label='U-1'),
.es(index=jobdata-
,metric=sum:MIPS,interval=300s,timefield=int_starttime_ts,offset=$u2,q='(jobname.keyword:"xxxxx")').lines(width=1).label(label='U-2')
'''

@matschaffer , @leandrojmp - Any idea or suggestion you can share on this query

Hi @krishray09 - I've never really used timelion, but it looks like you're trying to display the same time series with two different time offsets.

In current kibana releases, the recommended way to do this is with lens time shifting.

Create visualizations with Lens | Kibana Guide [8.1] | Elastic includes a one week timeshifted example formula you should be able to work from.

For a predefined shift you don't even need to a formula, but 32 and 96 days are not available as predefined choices so you'll need a formula for that.

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