# Kibana tsvb pipeline aggregation

**URL:** https://discuss.elastic.co/t/kibana-tsvb-pipeline-aggregation/271568
**Category:** Kibana
**Created:** [April 28, 2021, 11:34pm UTC](https://discuss.elastic.co/t/kibana-tsvb-pipeline-aggregation/271568 "2021-04-28T23:34:55Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ivh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivh/32/87876_2.png) [@ivh](https://discuss.elastic.co/u/ivh)
#### Post date: [April 28, 2021, 11:34pm UTC](https://discuss.elastic.co/t/kibana-tsvb-pipeline-aggregation/271568/1 "2021-04-28T23:34:56Z")

</div>

Hello Elastic team!

I have a working pipeline aggregation script based on [this example](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-cumulative-sum-aggregation.html) & I want to graph same in Kibana (7.10.1) TSVB ... and simply cannot understand how to accomplish this. Tried bucket\_script in TSVB, tried scripted fields, no dice.

So my question is: how do I take a script working fine via GET from Postman, and convert it into a functional line graph in TSVB?

Thanks!

**Script...**

```auto
GET /index/_search
{
  "size": 0,
  "aggs": {
    "Daily Purchases": {
      "date_histogram": {
        "field": "coin_bot_datetime",
        "calendar_interval": "day"
      },
      "aggs": {
        "units": {
          "sum": {
            "field": "coin_bot_count"
          }
        },
        "Cumulative Purchases": {
          "cumulative_sum": {
            "buckets_path": "units" 
          }
        }
      }
    }
  }
}

```

**Output...**

````auto
{
    "took": 1,
    "timed_out": false,
    "_shards": {
        "total": 1,
        "successful": 1,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 2,
            "relation": "eq"
        },
        "max_score": null,
        "hits": []
    },
    "aggregations": {
        "Daily Purchases": {
            "buckets": [
                {
                    "key_as_string": "2021-04-02 00:00:00",
                    "key": 1617321600000,
                    "doc_count": 1,
                    "units": {
                        "value": 0.016652539372444153
                    },
                    "Cumulative Purchases": {
                        "value": 0.016652539372444153
                    }
                },
                {
                    "key_as_string": "2021-04-03 00:00:00",
                    "key": 1617408000000,
                    "doc_count": 0,
                    "units": {
                        "value": 0.0
                    },
                    "Cumulative Purchases": {
                        "value": 0.016652539372444153
                    }
                },
                {
                    "key_as_string": "2021-04-04 00:00:00",
                    "key": 1617494400000,
                    "doc_count": 0,
                    "units": {
                        "value": 0.0
                    },
                    "Cumulative Purchases": {
                        "value": 0.016652539372444153
                    }
                },
                {
                    "key_as_string": "2021-04-05 00:00:00",
                    "key": 1617580800000,
                    "doc_count": 0,
                    "units": {
                        "value": 0.0
                    },
                    "Cumulative Purchases": {
                        "value": 0.016652539372444153
                    }
                },
                {
                    "key_as_string": "2021-04-06 00:00:00",
                    "key": 1617667200000,
                    "doc_count": 0,
                    "units": {
                        "value": 0.0
                    },
                    "Cumulative Purchases": {
                        "value": 0.016652539372444153
                    }
                },
                {
                    "key_as_string": "2021-04-07 00:00:00",
                    "key": 1617753600000,
                    "doc_count": 1,
                    "units": {
                        "value": 0.017336610704660416
                    },
                    "Cumulative Purchases": {
                        "value": 0.03398915007710457
                    }
                }
            ]
        }
    }
}```
````

---

<div class="post-metadata">

### Author: ![Stratoula\_Kalafateli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stratoula_kalafateli/32/70923_2.png) [@Stratoula\_Kalafateli](https://discuss.elastic.co/u/Stratoula_Kalafateli)
#### Post date: [April 29, 2021, 10:45am UTC](https://discuss.elastic.co/t/kibana-tsvb-pipeline-aggregation/271568/2 "2021-04-29T10:45:07Z")

</div>

Hello @ivh!

TSVB supports cumulative sum so no need to create a script. Here is my configuration to make it work

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/1/3120f59ede6121fd7c3968f4ede6bc6147f0925a.png)

Is this what you want or have I misunderstood the question?

---

<div class="post-metadata">

### Author: ![ivh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivh/32/87876_2.png) [@ivh](https://discuss.elastic.co/u/ivh)
#### Post date: [April 29, 2021, 5:12pm UTC](https://discuss.elastic.co/t/kibana-tsvb-pipeline-aggregation/271568/3 "2021-04-29T17:12:09Z")

</div>

[[smacks head]]

Hi @Stratoula_Kalafateli -- I could swear I tried that & it didn't work ... but lo & behold it works now perfectly just as you showed in your example. Thanks for that.

I do still wonder how to convert a viable script into a visualization in TSVD ... but for now, the immediate-term fix works great, thanks again.

---

<div class="post-metadata">

### Author: ![ivh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivh/32/87876_2.png) [@ivh](https://discuss.elastic.co/u/ivh)
#### Post date: [May 12, 2021, 7:46pm UTC](https://discuss.elastic.co/t/kibana-tsvb-pipeline-aggregation/271568/4 "2021-05-12T19:46:18Z")

</div>

Additional question if you'll bear with me: I've now noticed that the individual documents that appear in the cumulative sum are those from the selected time bucket ... where really what I'm after is the cumulative sum over **all documents ever** -- regardless of time bucket. I have tried something like this...

`coin_bot_name_short:ETH and @coin_bot_datetime>"2021-04-01"`

...but it doesn't work.

---

<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: [June 9, 2021, 7:46pm UTC](https://discuss.elastic.co/t/kibana-tsvb-pipeline-aggregation/271568/5 "2021-06-09T19:46:42Z")

</div>

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