Variable addition

I want to add up a number and show it in a kibana timeline chart.
I've got a datastream which has a connect and disconnect entry. I've written a scripted field in kibana index which adds 1 when its connected to and substracts 1 when it's disconnected. So, I want a timeline chart to show how many connections there are over time by adding up the 1 and -1 e.g. it will be 0, 1, 2, 3, 2, 3, 2, 1, 0 as connections come and go. I can't figure out how toshow this though in a chart. I've looked timelion as well which has the concept of cusum which seems close but can't get that to work either. what I need is some kind of variable that gets stored over calls to the scripted field - but that doesn't look supported.
any ideas?


Hi @John_H,
I think your description is a case for a cumulative sum, could you check that option?
For example, for vertical bar chart: On Y axis you need to create a cumulative sum of a number field you want to track, and on x axis you create date histogram. Let me know if you need further guidance.