How to get postaggregations to output

Hi all,

I am executing this query:

{

“queryType”: “timeseries”,

“dataSource”: “call-duration”,

“intervals”: [ “2015-02-09T10:00:00.000/2015-02-09T11:00:00.000” ],

“granularity”: “all”,

“filter”:{ “type”: “selector”, “dimension”: “tenant-name”, “value”: “Vodafone” },

“aggregations”: [

{“type”: “longSum”, “fieldName”: “count”, “name”: “calls”},

{“type”: “longSum”, “fieldName”: “duration-milliseconds”, “name”: “total-duration-milliseconds”}],

“postaggregations” :

{

“type” : “arithmetic”,

“name” : “avg”,

“fn” : “/”,

“fields” : [

 { "type" : "fieldAccess", "name" : "duration-milliseconds", "fieldName" : "total-duration-milliseconds" },

 { "type" : "fieldAccess", "name" : "count", "fieldName" : "calls" }]

}

}

It returns

[ {

“timestamp” : “2015-02-09T10:00:10.827Z”,

“result” : {

“calls” : 13,

“total-duration-milliseconds” : 7207325

}

} ]

So the aggregations are working fine, but I can’t get it to return the results of the post aggregation.

I am expecting the following result:

[ {

“timestamp” : “2015-02-09T10:00:10.827Z”,

“result” : {

“calls” : 13,

“total-duration-milliseconds” : 7207325,

“avg” : 554409.615384615

}

} ]

I’ve read the documentation, and I can’t see what I’m doing wrong. Btw, sometimes the documentation says to use “postaggregation” and sometimes it says “postaggregations”, but neither seems to work.

Any help appreciated.

Regards,

Mikaere

Hi Mikaere,

I can see typo errors in the query, casing for postAggregations is not correct

s/postaggregations/postAggregations/g

postAggregations should be an array instead of single value.

try this query

{

“queryType”: “timeseries”,

“dataSource”: “call-duration”,

“intervals”: [ “2015-02-09T10:00:00.000/2015-02-09T11:00:00.000” ],

“granularity”: “all”,

“filter”:{ “type”: “selector”, “dimension”: “tenant-name”, “value”: “Vodafone” },

“aggregations”: [

{“type”: “longSum”, “fieldName”: “count”, “name”: “calls”},

{“type”: “longSum”, “fieldName”: “duration-milliseconds”, “name”: “total-duration-milliseconds”}],

“postAggregations” :

[{

"type"   : "arithmetic",

"name"   : "avg",

"fn"     : "/",

"fields" : [

  { "type" : "fieldAccess", "name" : "duration-milliseconds", "fieldName" : "total-duration-milliseconds" },

  { "type" : "fieldAccess", "name" : "count", "fieldName" : "calls" }]

}]

}

Thanks, that fixed it.