Skip to content

Instantly share code, notes, and snippets.

@mikeasick
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeasick/8734117 to your computer and use it in GitHub Desktop.
Save mikeasick/8734117 to your computer and use it in GitHub Desktop.
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