Splunk Enterprise

How to calculate consumption from the flow attribute

spisiakmi
Contributor

Hi,

the problem is very easy.

I have 2 variables:

  1. timestamp: _time
  2. flow of nitrogen: flow [m^3/h]

On the dashboard the user can use the time picker as he wish. Samples of flow are nonlinear measured. There is no linear discrete time.

Goal: to have a number of consumption [m^3] of the nitrogen in selected time range.

Example:

If the time range is exactly 1h, and the flow=6 only, it can be used the avg fcn and the consumption=6.

If the value of flow varies, and the time range also, I don’t think, the avg fcn can be used. I’m looking for something like integral. Can anybody help, please?

Labels (1)
0 Karma
1 Solution

PickleRick
SplunkTrust
SplunkTrust

You can "integrate" it manually.

Something like this

<your_initial_search>
| reverse ```You can do without reversing but it's gonna get confusing since the results will be offset by one```
| streamstats current=f window=1 values(_time) as prevtime ```copy timestamp of previous event```
| search prevtime=* ```remove the first event because there's no previous timestamp for it```
| eval duration=_time-prevtime ```we now know how much time elapsed since last sample```
| eval totalflow=flow*duration ```so we can count the total transferred amount```

(adjust for units - duration will be in seconds)

View solution in original post

spisiakmi
Contributor

Hi PickleRick, thank you very much. This is the proper way.

PickleRick
SplunkTrust
SplunkTrust

You can "integrate" it manually.

Something like this

<your_initial_search>
| reverse ```You can do without reversing but it's gonna get confusing since the results will be offset by one```
| streamstats current=f window=1 values(_time) as prevtime ```copy timestamp of previous event```
| search prevtime=* ```remove the first event because there's no previous timestamp for it```
| eval duration=_time-prevtime ```we now know how much time elapsed since last sample```
| eval totalflow=flow*duration ```so we can count the total transferred amount```

(adjust for units - duration will be in seconds)

Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...