# Is it possible to create a date histogram from the output of a date histogram?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-create-a-date-histogram-from-the-output-of-a-date-histogram/75080>\
**Category:** Elasticsearch\
**Created:** [February 14, 2017, 5:04pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-a-date-histogram-from-the-output-of-a-date-histogram/75080 "2017-02-14T17:04:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![crickes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/crickes/32/18009_2.png) [@crickes](https://discuss.elastic.co/u/crickes)\
**Post date:** [February 14, 2017, 5:04pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-a-date-histogram-from-the-output-of-a-date-histogram/75080/1 "2017-02-14T17:04:25Z")

</div>

I am trying to create some statistical output based on event data. I have script that will search and count events over a period of time and creates a date histogram, with the bucket size being configurable. the output of which looks like this:

```
"aggregations": {
"per_second_histo": {
  "buckets": [
    {
      "key_as_string": "2017-02-14T00:00:00.000Z",
      "key": 1487030400000,
      "doc_count": 0
    },
    {
      "key_as_string": "2017-02-14T00:00:01.000Z",
      "key": 1487030401000,
      "doc_count": 0
    },
    {
      "key_as_string": "2017-02-14T00:00:02.000Z",
      "key": 1487030402000,
      "doc_count": 0
    },
    {
      "key_as_string": "2017-02-14T00:00:03.000Z",
      "key": 1487030403000,
      "doc_count": 0
    },
    {
      "key_as_string": "2017-02-14T00:00:04.000Z",
      "key": 1487030404000,
      "doc_count": 0
    },

```

What I want to do now is create a second date histogram, with buckets of 5 minute periods containing stats for that period using a stats bucket, but i'm struggling with how to point the stats bucket at a selection of the previous date histogram. I've seen it github that something called a bucket reducer was proposed, and the ticket was closed with the introduction of pipeline aggregations, but I can't figure out how to do it. Can anyone shed some advice on this please?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 14, 2017, 5:05pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-a-date-histogram-from-the-output-of-a-date-histogram/75080/2 "2017-03-14T17:05:43Z")

</div>

Closed on March 14, 2017, 5:05pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
