# How do I post an aggregation to an index?

**URL:** <https://discuss.elastic.co/t/how-do-i-post-an-aggregation-to-an-index/122334>\
**Category:** Elasticsearch\
**Created:** [March 2, 2018, 10:10pm UTC](https://discuss.elastic.co/t/how-do-i-post-an-aggregation-to-an-index/122334 "2018-03-02T22:10:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Motez\_Musa](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@Motez\_Musa](https://discuss.elastic.co/u/Motez_Musa)\
**Post date:** [March 2, 2018, 10:10pm UTC](https://discuss.elastic.co/t/how-do-i-post-an-aggregation-to-an-index/122334/1 "2018-03-02T22:10:55Z")

</div>

I'm fairly new to elasticsearch (v2.4.6), but I'm building some basic visualizations on Kibana (v4.6.4) using some existing indices that log cpu usage data. I can run the following aggregation and get the results via a curl command

```
curl -X GET -u a {https://xyz....2/index1/_search?pretty=true} -d '{
  "size": 0,
  "aggs": {
    "events_by_host": {
      "terms": {
        "field": "cell_host_the_app"
      },
      "aggs": {
        "events_by_date": {
          "date_histogram": {
            "field": "time_stamp",
            "interval": "30m"
          },
          "aggs": {
            "total_cpu": {
              "sum": {
                "field": "cpu_usgae_percentage"
              }
            },
            "max_cpu": {
              "max": {
                "field": "cpu_usgae_percentage"
              }
            }
          }
        },
        "max_aggregated_cpu": {
          "max_bucket": {
            "buckets_path": "events_by_date>total_cpu"
          }
        }
      }
    }
  }
}' -k 

```

However, I can not figure out how to post this aggregation to elasticsearch so I can use the results from this aggregation in a visualization.

---

<div class="post-metadata">

**Author:** ![shanec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shanec/32/4004_2.png) [@shanec](https://discuss.elastic.co/u/shanec)\
**Post date:** [March 2, 2018, 11:15pm UTC](https://discuss.elastic.co/t/how-do-i-post-an-aggregation-to-an-index/122334/2 "2018-03-02T23:15:41Z")

</div>

What you really should look at doing is upgrading your Kibana (and thus also Elasticsearch). Kibana has since added support for pipeline aggregations (the `max_bucket`) thing so you can build a visualization like this:

 ![29%20PM](https://us1.discourse-cdn.com/elastic/original/3X/b/9/b9eae90f856c0af4579ddee3cdcfeb9b5d79045a.png)

---

<div class="post-metadata">

**Author:** ![Motez\_Musa](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@Motez\_Musa](https://discuss.elastic.co/u/Motez_Musa)\
**Post date:** [March 7, 2018, 6:05pm UTC](https://discuss.elastic.co/t/how-do-i-post-an-aggregation-to-an-index/122334/3 "2018-03-07T18:05:40Z")

</div>

Is there any other course of action I can take if upgrading isn't an option?

---

<div class="post-metadata">

**Author:** ![shanec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shanec/32/4004_2.png) [@shanec](https://discuss.elastic.co/u/shanec)\
**Post date:** [March 7, 2018, 6:54pm UTC](https://discuss.elastic.co/t/how-do-i-post-an-aggregation-to-an-index/122334/4 "2018-03-07T18:54:57Z")

</div>

You could potentially try to use the JSON Input feature of Kibana (under the "Advanced" section of the buckets) but I'd strongly recommend upgrading instead.

---

<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:** [April 4, 2018, 6:55pm UTC](https://discuss.elastic.co/t/how-do-i-post-an-aggregation-to-an-index/122334/5 "2018-04-04T18:55:04Z")

</div>

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