Splunk Search

Calculate duration between events.

SreeragM
Explorer

Hi,

I have a log file with many events like below

2015-01-16 10:19:12 [APP1;STORE] Activated configuration 'Prod'
2015-01-16 11:29:13 [APP1;STORE] Activated configuration 'Test'
2015-01-16 12:30:51 [APP1;STORE] Activated configuration 'Prod'
2015-01-16 15:50:03 [APP1;STORE] Activated configuration 'No Data'

Each event indicates a configuration activation. so the time difference is the time the previous config was active.

I'm extracting these fields

Configuration: values can be Prod, Test, No Data
Application: values can be APP1,APP2

I want to calculate how long each configuration was active in APP1

-Sreerag

0 Karma

lguinn2
Legend

You could try this:

yoursearchhere
| sort _time
| delta _time as Duration
| table Application Configuration Duration
| eventstats sum(Duration) as AppDuration by Application
| fieldformat Duration=tostring(Duration,"duration")
| fieldformat AppDuration=tostring(AppDuration,"duration")

aljohnson_splun
Splunk Employee
Splunk Employee

Does something like this work for you?

config_value=prod OR config_value=Test OR config_value=No Data
application=APP1 OR application=APP2
| delta _time as tdelta
| stats list(tdelta) by application
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 ...