Metrics Aggregations: custom stats functions, script stats, user-defined metrics, custom metrics

(Jin Huang) #1

Hi people,

Can someone provide some detailed information on how to extend the sets of
currently available metrics in the aggregation framework?

For now, Elasticsearch provides support for the metrics: count, min, max,
avg, sum, sum_of_squares, variance, and std_deviation. How can I define my

I understand that there might some hard constraints on the type of metrics
could be defined. But it would be nice if someone can provide a simple
example of how to write my own.

Here is a couple of suggested examples that I would want to know how to

  1. I want to calculate all the n-th central moments, with n=2,3,4,..10. By
    the way, Elasticsearch already provides the 2nd central moment, i.e. square
    of the standard deviation.
  2. I want to get the second order statics. That is, I want to the second
    smallest number.

In general, I would like to know what kind of custom aggregator is easy to
write? If the above examples require a deep dive into some of the source
codes, please DO! I don't mind if the answer runs 10 pages long as long as
someone can provide me with some pointers on how to get started.


You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
For more options, visit

(system) #2