Splunk Search

Calculating weighted concurrency

myandow
Path Finder

I am trying to calculate a weighted concurrency across 3 different event types. Each of these event types has a single log entry that contains the type, the startTime, and EndTime. Each of the event types has a different weight associated with them, so using the straight up concurrency result returned by the concurrency command is not accurate. For instance:

eventA - weight 2
eventB - weight 3
eventC - weight 1

If eventC starts when 2 other eventCs are running then the concurrency is 3 (as returned by the concurrency command). But, if eventC starts when 2 other eventAs are running then the concurrency should be 5. If eventC starts when an EventA and an eventB are running then the concurrency should be 6. Any suggestions on how to calculate these weighted concurrency values?

Tags (1)
0 Karma
1 Solution

myandow
Path Finder

In case anyone else is trying to do this as well, this is what I found worked for me. I assigned the weights to each different event using case() then appended another search where I assigned EndTime to _time and applied the negative weights. Then using accum, kept a running sum of the weights, which then represents the Concurrency.

index=myIndex | eval Weight=case(eventType="eventA", 2, eventType="eventB", 3,eventType="eventC",1,1=1,0) | append [search index=myIndex | eval Weight=case(eventType="eventA", -2, eventType="eventB", -3,eventType="eventC",-1,1=1,0) | eval _time=EndTime | sort _time] | sort _time | accum Weight as Concurrency

View solution in original post

0 Karma

myandow
Path Finder

In case anyone else is trying to do this as well, this is what I found worked for me. I assigned the weights to each different event using case() then appended another search where I assigned EndTime to _time and applied the negative weights. Then using accum, kept a running sum of the weights, which then represents the Concurrency.

index=myIndex | eval Weight=case(eventType="eventA", 2, eventType="eventB", 3,eventType="eventC",1,1=1,0) | append [search index=myIndex | eval Weight=case(eventType="eventA", -2, eventType="eventB", -3,eventType="eventC",-1,1=1,0) | eval _time=EndTime | sort _time] | sort _time | accum Weight as Concurrency
0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...