I'm attempting to extract records of http success/failure data per user using an elasticsearch aggregation.
I'm looking at two fields, "user.name" and "http.response.status_code". My goal is to use a keyed range bucket aggregation for the http response codes to label the 200s as "success" and the 400s as "failure" ignoring all other codes. I then want to aggregate these on a per user basis so that my output would look something like:
"buckets": [
{
"key": [
"user1",
"success"
],
"key_as_string": "user2|success",
"doc_count": 1766
},
{
"key": [
"user1",
"failure"
],
"key_as_string": "user1|failure",
"doc_count": 245
}
]
I've done both separately using a multiterm aggregation and a range bucket aggregation but is there a way to combine two different kinds of aggregations into one?
I can always resort to bucketing the ranges and dropping the excess values with a script, but I'd prefer to do it all within the query if possible.
Thanks in advance,
Alex