Splunk Search

How to calculate concurrency using value in event?

pasito
Explorer

Hi all,

I have the following type of data with session information:

starttime=1477419810 endtime=1477419818 count=5 user=abc
starttime=1477419811 endtime=1477419819 count=3 user=def
starttime=1477419813 endtime=1477419818 count=4 user=def
starttime=1477419814 endtime=1477419818 count=2 user=abc

The count field is the actual amount of "sessions started" by the user at "starttime" which ended at "endtime".

Now if I want to calculate the concurrency of each event I can naturally calculate the duration and perform the concurrency command. However the value of "count"

... | eval duration=endtime-starttime | concurrency duration=duration

However I want to sum the value of count as concurrency using the start and end times as the window. So instead of seeing a concurrency of 4 between starttime=1477419814 and endtime=1477419818 I should see 14.

Any help would be appreciated.

0 Karma
1 Solution

somesoni2
Revered Legend

Try like this (run anywhere sample, replace first 4 lines with your base search)

|  gentimes start=-1 | eval starttime=1477419810 | eval endtime=1477419818 | eval count=5 | eval user="abc" | append[
|  gentimes start=-1 | eval  starttime=1477419811| eval  endtime=1477419819 | eval count=3 | eval user="def" ]| append[
|  gentimes start=-1 | eval  starttime=1477419813 | eval endtime=1477419818 | eval count=4 | eval user="def" ]| append[
|  gentimes start=-1 | eval  starttime=1477419814 | eval endtime=1477419818 | eval count=2 | eval user="abc" ] | fields - *human 
| eval temp=mvrange(starttime, endtime+1) | mvexpand temp | rename temp as _time |  bucket span=1s _time | stats sum(count) as newcount by _time

View solution in original post

0 Karma

somesoni2
Revered Legend

Try like this (run anywhere sample, replace first 4 lines with your base search)

|  gentimes start=-1 | eval starttime=1477419810 | eval endtime=1477419818 | eval count=5 | eval user="abc" | append[
|  gentimes start=-1 | eval  starttime=1477419811| eval  endtime=1477419819 | eval count=3 | eval user="def" ]| append[
|  gentimes start=-1 | eval  starttime=1477419813 | eval endtime=1477419818 | eval count=4 | eval user="def" ]| append[
|  gentimes start=-1 | eval  starttime=1477419814 | eval endtime=1477419818 | eval count=2 | eval user="abc" ] | fields - *human 
| eval temp=mvrange(starttime, endtime+1) | mvexpand temp | rename temp as _time |  bucket span=1s _time | stats sum(count) as newcount by _time
0 Karma
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!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...