Skip to content

Instantly share code, notes, and snippets.

@inqueue
Created May 8, 2018 15:42
Show Gist options
  • Save inqueue/93425ac43e4941273fd08dfb540b1478 to your computer and use it in GitHub Desktop.
Save inqueue/93425ac43e4941273fd08dfb540b1478 to your computer and use it in GitHub Desktop.
Counting histogram buckets
POST metricbeat/_search
{
"size": 0,
"aggs": {
"date_histo": {
"date_histogram": {
"field": "@timestamp",
"interval": "day"
}
},
"date_histo_stats": {
"stats_bucket": {
"buckets_path": "date_histo._count"
}
}
}
}
{
"took": 251,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 15918724,
"max_score": 0,
"hits": []
},
"aggregations": {
"date_histo": {
"buckets": [
{
"key_as_string": "2018-05-02T00:00:00.000Z",
"key": 1525219200000,
"doc_count": 435323
},
{
"key_as_string": "2018-05-03T00:00:00.000Z",
"key": 1525305600000,
"doc_count": 2792306
},
{
"key_as_string": "2018-05-04T00:00:00.000Z",
"key": 1525392000000,
"doc_count": 2729772
},
{
"key_as_string": "2018-05-05T00:00:00.000Z",
"key": 1525478400000,
"doc_count": 2721635
},
{
"key_as_string": "2018-05-06T00:00:00.000Z",
"key": 1525564800000,
"doc_count": 2721417
},
{
"key_as_string": "2018-05-07T00:00:00.000Z",
"key": 1525651200000,
"doc_count": 2725446
},
{
"key_as_string": "2018-05-08T00:00:00.000Z",
"key": 1525737600000,
"doc_count": 1792825
}
]
},
"date_histo_stats": {
"count": 7,
"min": 435323,
"max": 2792306,
"avg": 2274103.4285714286,
"sum": 15918724
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment