# \[Timelion\] How to perform a discrete integration of signal?

**URL:** <https://discuss.elastic.co/t/timelion-how-to-perform-a-discrete-integration-of-signal/127832>\
**Category:** Kibana\
**Tags:** timelion\
**Created:** [April 12, 2018, 1:45pm UTC](https://discuss.elastic.co/t/timelion-how-to-perform-a-discrete-integration-of-signal/127832 "2018-04-12T13:45:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![diogom8](https://avatars.discourse-cdn.com/v4/letter/d/77aa72/32.png) [@diogom8](https://discuss.elastic.co/u/diogom8)\
**Post date:** [April 12, 2018, 1:45pm UTC](https://discuss.elastic.co/t/timelion-how-to-perform-a-discrete-integration-of-signal/127832/1 "2018-04-12T13:45:55Z")

</div>

Hi all

I've recently started to explore the world of Kibana+Timelion and the possibilities seem endless. However, I'm trying to perform some energy analysis, based on a power signal, and couldn't yet find a way to calculate the energy consumption.

For now I've a discrete power signal which is archived in elastic search in a non periodic manner (based on some non-relevant rules). What I've done so far was to plot my power signal points and fit it with .fit(average), resembling a continuous time signal. My final goal is to go from Power to Energy, through some discrete-time integration function.

My idea now would be to discretize this signal, with a defined sampling time, and then apply a discrete integration rule.

Is there a way to do this in Timelion? If not, is there an easy way to create a customized function?

Cheers  
Diogo

---

<div class="post-metadata">

**Author:** ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)\
**Post date:** [April 13, 2018, 4:25pm UTC](https://discuss.elastic.co/t/timelion-how-to-perform-a-discrete-integration-of-signal/127832/2 "2018-04-13T16:25:50Z")

</div>

hi @diogom8,

I don't think you can resample in Timelion, which it looks like you're asking for as a first step. (after .fit).

I'm also pretty sure Timelion can't integrate either. I'm also not sure how exactly you'd want to express this in a time-series Visualization, but that might be more my limited knowledge of the domain. The closest thing we have to integration would be a cumulative sum, which is supported in both Timelion ([https://github.com/elastic/timelion/blob/master/FUNCTIONS.md#cusum](https://github.com/elastic/timelion/blob/master/FUNCTIONS.md#cusum)), and regular Elasticsearch ([https://www.elastic.co/guide/en/elasticsearch/reference/6.2/search-aggregations-pipeline-cumulative-sum-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/search-aggregations-pipeline-cumulative-sum-aggregation.html)).

---

<div class="post-metadata">

**Author:** ![diogom8](https://avatars.discourse-cdn.com/v4/letter/d/77aa72/32.png) [@diogom8](https://discuss.elastic.co/u/diogom8)\
**Post date:** [April 25, 2018, 4:05pm UTC](https://discuss.elastic.co/t/timelion-how-to-perform-a-discrete-integration-of-signal/127832/3 "2018-04-25T16:05:34Z")

</div>

@thomasneirynck , thanks for your reply.

You're right cumulative sum could be close but not exactly integration, so not really useful for the analysis I'm looking for. For instance in graphite, it seems that a bunch of nice functions are provided ([http://graphite.readthedocs.io/en/latest/functions.html](http://graphite.readthedocs.io/en/latest/functions.html)) but I was keen on performing this analysis with ES. Do you know if ES will provide new functions for Timelion soon?

---

<div class="post-metadata">

**Author:** ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)\
**Post date:** [April 25, 2018, 4:20pm UTC](https://discuss.elastic.co/t/timelion-how-to-perform-a-discrete-integration-of-signal/127832/4 "2018-04-25T16:20:18Z")

</div>

@diogom8,

I don't know of any new functions being worked on. It's very unlikely though that new ES-functions would be added to Timelion. In fact, Timelion has its won implementation for these functions, and does not rely on Elasticsearch.

---

<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:** [May 23, 2018, 4:20pm UTC](https://discuss.elastic.co/t/timelion-how-to-perform-a-discrete-integration-of-signal/127832/5 "2018-05-23T16:20:19Z")

</div>

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