Create a new metric aggregation in Kibana

I have a data consisting of timestamps and value at each timestamp. The values are both negative and positive. I want to create a line visualization in Kibana with x-axis timestamps and y-axis value with maximum deviation from 0. For example if between 3.00am and 4.00am the values are 12, -13, 3, -14 then I need the metric aggregation value to be -14. Also if the values were 12, -13, 3, 14 then I need output to be 14. The max aggregation will give me 12 in first case and min aggregation will give me -13 in second case both of which are wrong. So I would like to create a metric aggregation method of my own which can do this (language doesn't matter). Is it possible in Kibana? If so how?


you could potentially write custom metrics aggregation. You can have a look at this folder: to see the build in metrics implementations. But be aware, that non of these would be considered public API and could change in every version and you need to update your plugin (or it might even not be compatible at all anymore). Also there is no further guidance we can give except the reference code for this.

Nevertheless you should actually be able to achieve what you want in timelion if that's an option for you. Something like the following expression should work:


That will compare the max value against the absolute value of the min metrics aggregation. If the max one is larger, use it, if not, use the original min (without absolute) instead. This should result in the desired chart.


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