elastic / timelion

Timelion was absorbed into Kibana 5. Don't use this. Time series composer for Elasticsearch and beyond.
Other
347 stars 79 forks source link

Count aggregation on array fields #138

Closed kvc0 closed 8 years ago

kvc0 commented 8 years ago

Currently if you have documents like {"key":2} {"key":[4,4,5]} in Elasticsearch and try to do a .es(q="*",metric="count:key"), Timelion validation passes and I expect a data point with 4 (1 from the first document, 3 from the second) - however, I get 2. Count is unaware of arrays, though it lets you specify fields to count: Count should count values, not keys.

kvc0 commented 8 years ago

Please note that avg:key works as expected, giving 3.75 after considering all values for key.

kvc0 commented 8 years ago

Hilarious (obvious) workaround I've been using in case an intrepid Googler finds this: .es(q="*",metric="sum:key").divide(.es(q="*",metric="avg:key"))

rashidkpc commented 8 years ago

The count agg is a pseudo-agg that counts the number of documents, not the length of an array: Eg "sum:bytes", or just "count"