Skip to content

Instantly share code, notes, and snippets.

@mikeasick mikeasick/gist:8734117
Last active Aug 29, 2015

Embed
What would you like to do?
ES Aggregates: Metrics on Metrics Example Query
curl -XGET "http://localhost:9200/vitals/vital/_search" -d'
{
"size": 0,
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"and": {
"filters": [
{
"term": {"user_guid": "0ad08904-c1cf-46cf-9a04-e0865c1cced2"}
},
{
"numeric_range": {
"recorded_time": {
"gte": "2013-01-05T04:44:33.396-05:00",
"lte": "2014-01-05T04:44:33.396-05:00"
}
}
}
]
}
}
}
},
"aggs": {
"date_aggregate": {
"date_histogram": {
"field": "recorded_time",
"interval": "5m"
},
"aggs": {
"heartRate_zoneAverageCounts": {
"range" : {
"field" : "heartRate_stats.avg",
"ranges" : [
{ "to" : 50 },
{ "from" : 50, "to" : 100 },
{ "from" : 100 }
]
}
},
"heartRate_zoneCounts": {
"range" : {
"field" : "heartRate",
"ranges" : [
{ "to" : 50 },
{ "from" : 50, "to" : 100 },
{ "from" : 100 }
]
}
},
"heartRate_stats": {
"extended_stats": {
"field": "heartRate"
}
}
}
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.