Dashboards & Visualizations

Adding "Duration" to a Table of Information

_gkollias
SplunkTrust
SplunkTrust

I have a query that lists a bunch of information, and I'd like to add a Duration field to the table. The query below is trying to create the table, use append to find duration, and finally add it to the overall table, but it's not working that way. Here is the query I'm using:

index=eis_continuous_integration sourcetype=eisci
| table _time, Group, Action, SRCRepo, SRCProject, Name, Type, TGTAlias, host, Status
| eval Date=_time
| convert timeformat="%m/%d/%Y" ctime(Date)
| append [ search index=eis_continuous_integration sourcetype=eisci

| stats min(_time) AS earliest, max(_time) AS latest by Name
| eval Duration = (latest-earliest)
| convert timeformat="%H:%M:%S" ctime(earliest)
| convert timeformat="%H:%M:%S" ctime(latest)
| convert timeformat="%S.%3N" ctime(Duration)]
| table Date, Group, Action, SRCRepo, SRCProject, Name, Type, TGTAlias, host, Status, Duration

The search after append gives me duration in seconds, but it won't add the duration to the overall table. I thought I could use append to find duration and then add it to the table.

Your help would be much appreciated,
Thanks!

Tags (3)
0 Karma
1 Solution

kristian_kolb
Ultra Champion

I think that this might be a case for eventstats;

index=blah sourcetype=bleh
| eventstats min(_time) as mintime max(_time) as maxtime by Name
| eval Duration = maxtime - mintime
| table all your fields + Duration

/k

View solution in original post

kristian_kolb
Ultra Champion

I think that this might be a case for eventstats;

index=blah sourcetype=bleh
| eventstats min(_time) as mintime max(_time) as maxtime by Name
| eval Duration = maxtime - mintime
| table all your fields + Duration

/k

_gkollias
SplunkTrust
SplunkTrust

That did it 🙂 Thanks!

0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...