Splunk Search

How to Add multiple field values for the matching value of another field

Edwin1471
Path Finder

I want to create a query, that  would combine all the duration values into one by adding them for each Time Date. 

Edwin1471_0-1657620145156.png

The result should look something like this : 

Duration      |    TimeDate

03:59:18      |    2022-07-31

.........                 |    2022-06-30

........                  |    2022-05-30 

and so on

 

Labels (3)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try this

| eval finish_time_epoch = strptime(FINISH_TIME, "%Y-%m-%d %H:%M:%S")
| eval start_time_epoch = strptime(START_TIME, "%Y-%m-%d %H:%M:%S")
| eval duration = finish_time_epoch - start_time_epoch
| stats sum(duration) as duration by finish_time_epoch
| sort - finish_time_epoch
| eval TimeDate=strftime(finish_time_epoch, "%Y-%m-%d %H:%M:%S")
| eval duration=tostring(duration,"duration")
| table duration TimeDate

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Were the durations originally in seconds as this would make it easier

| stats sum(duration_in_seconds) as duration_in_seconds by TimeDate
| fieldformat duration_in_seconds=tostring(duration_in_seconds,"duration")
0 Karma

Edwin1471
Path Finder

No 

The initial query 

| eval finish_time_epoch = strptime(FINISH_TIME, "%Y-%m-%d %H:%M:%S")
| eval start_time_epoch = strptime(START_TIME, "%Y-%m-%d %H:%M:%S")
| eval duration = tostring((finish_time_epoch - start_time_epoch), "duration")
| rex field="duration" mode=sed "s/\..*$//"
| sort -FINISH_TIME
| table duration, timeDate

 

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try this

| eval finish_time_epoch = strptime(FINISH_TIME, "%Y-%m-%d %H:%M:%S")
| eval start_time_epoch = strptime(START_TIME, "%Y-%m-%d %H:%M:%S")
| eval duration = finish_time_epoch - start_time_epoch
| stats sum(duration) as duration by finish_time_epoch
| sort - finish_time_epoch
| eval TimeDate=strftime(finish_time_epoch, "%Y-%m-%d %H:%M:%S")
| eval duration=tostring(duration,"duration")
| table duration TimeDate
Get Updates on the Splunk Community!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...