diff --git a/docs/content/Post-aggregations.md b/docs/content/Post-aggregations.md index 0bd7b990a30..7fd91d0ea99 100644 --- a/docs/content/Post-aggregations.md +++ b/docs/content/Post-aggregations.md @@ -40,6 +40,31 @@ The constant post-aggregator always returns the specified value. { "type" : "constant", "name" : , "value" : } ``` +### JavaScript post-aggregator + +Applies the provided JavaScript function to the given fields. Fields are passed as arguments to the JavaScript function in the given order. + +```json +postAggregation : { + "type": "javascript", + "name": , + "fieldNames" : [, , ...], + "function": +} +``` + +Example JavaScript aggregator: + +```json +{ + "type": "javascript", + "name": "absPercent", + "fieldNames": ["delta", "total"], + "function": "function(delta, total) { return 100 * Math.abs(delta) / total; }" +} +``` + + ### Example Usage In this example, let’s calculate a simple percentage using post aggregators. Let’s imagine our data set has a metric called "total".