Painless Script - Access Interval Variable

Using Scripted Fields, I'm trying to do some math and I need to divide the current interval / 1000.

Interval is dynamic as we zoom in and out of graphs, could be per minute, per 5 minutes, for hour, etc.

In TSVB, Bucket Scripts allows to access the internal with the following param: params._interval

How to do it in scripted fields?

AFAIK

Scripted fields compute data on the fly from the data in your Elasticsearch indices. The data is shown on the Discover tab as part of the document data, and you can use scripted fields in your visualizations.

So if the field is not in the index, you cannot access it.

Pretty sure there are special variables you can call, such as the interval variable... We can do it in TSVB, maybe someone from Elastic needs to confirm.

Here's my current code for the scripted field:

if (doc['ifHCInOctets'].size() != 0) { doc['ifHCInOctets'].value * 8 / 60 }

This part of my code: 8 / 60 } needs to be 8 / $interval } just like in TSVB with params._interval

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