How can we calculate day of year using Math Aggregation in Kibana 6.5?

I want the output of final metric to be displayed under Kibana Metric Visual Builder. I am stucked in calculating dayOfYear() using Math Aggregation in Kibana. Please let me know how can we use expressions like dayOfYear() in Visual Builder Math Aggregation. If not possible, then what are the other options?

I am attaching the snip of my calculation. Thanks in Advance!

@Sonam_Verma do you just wanna get the current day of the year? Maybe we can try something like Calendar.getInstance().get(Calendar.DAY_OF_YEAR)?

@tiagocosta The Expression field under Math Aggregation is not taking any function and throwing error.

@Sonam_Verma what about creating a scripting field with that expression?

@tiagocosta OK so u mean that I should create a script field first. Got it.. but how can I access that scripted field here?? Can you please elaborate with an example?

@Sonam_Verma I have checked this question with the respective team and I'm afraid we would not be able to do it with a Math aggregation. The math aggregation computes everything on client side and you can only use the tinymath functions. You have an interesting parameter that is params._timestamp that represent the UTC in millis but you don’t have any date library to handle that unfortunately. Bucket script on the other hands let’s you use the full painless script capabilities but I’m not sure if you can use that for what you want to achieve.

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