Splunk Search

How to get the count of elapsed time?

Choupette72
Engager

Hello, 

I am trying to do the following: I need to add all the times in ELAPSED and give the result in the Total Time Elapsed row. I also am trying to remove the sort_field and Total from my table. I have tried to use the stats, count and addtotal commands, but I am not finding the right way to use them. Can anyone help?

Regards,

Celine

BATCH_NAME ELAPSED STAGE START_TIME sort_field Total _raw _time
MCO/COB.INITIALISE 00:00:00 Application 20:18:34 1 1 20220321,A000,MCO/COB.INITIALISE,COB.EXECUTE.API,20:18:34,20:18:34,00:00:00 2022-03-21T20:18:34.200+0200
MCO/SYSTEM.SECURITIES 00:00:00 System Wide 20:35:46 2 2 20220321,S001,MCO/SYSTEM.SECURITIES,SC.EOD.SUB.ACC.CHG.POST,20:35:46,20:35:46,00:00:00 2022-03-21T20:35:46.200+0200
MCO/DATE.CHANGE 00:00:00 Start of Day 21:30:26 4 4 20220321,D000,MCO/DATE.CHANGE,B.DATE.CHANGE,21:30:26,21:30:26,00:00:00 2022-03-21T21:30:26.200+0200
MCO/RESET.CO.STATUS 00:00:00 Online 21:34:47 5 5 20220321,O000,MCO/RESET.CO.STATUS,RESET.CO.STATUS,21:34:47,21:34:47,00:00:00 2022-03-21T21:34:47.200+0200
MCO/BATCH.DATE.RESET 00:00:00 End of COB 21:35:59 6 6 20220321,O999,MCO/BATCH.DATE.RESET,BATCH.DATE.RESET,21:35:59,21:35:59,00:00:00 2022-03-21T21:35:59.200+0200
Total Time Elapsed  XX:XX:XX     18 18    
Labels (1)
0 Karma

Choupette72
Engager

Thank you so much for this. It is now giving me what I want. 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Convert your elapsed time to seconds

| rex field=ELAPSED "(?<hours>\d+):(?<minutes>\d+):(?<seconds>\d+)"
| eval elapsedseconds=((hours * 60) + minutes) * 60 + seconds

Use addcoltotals

| addcoltotals elapsedseconds labelfield=BATCH_NAME label="Total Time Elapsed"

Remove unwanted fields

| fields - sort_field Total
Get Updates on the Splunk Community!

New in Observability - Improvements to Custom Metrics SLOs, Log Observer Connect & ...

The latest enhancements to the Splunk observability portfolio deliver improved SLO management accuracy, better ...

Improve Data Pipelines Using Splunk Data Management

  Register Now   This Tech Talk will explore the pipeline management offerings Edge Processor and Ingest ...

3-2-1 Go! How Fast Can You Debug Microservices with Observability Cloud?

Register Join this Tech Talk to learn how unique features like Service Centric Views, Tag Spotlight, and ...