Getting Data In

How to substract two fields on epoch

Emp
Explorer

Hi,

I tried to find answers on the forum but I didn't find any working solutions.

 

I had two fields with "hour / minute / second" like:

TReceived > 17:13:10

TSent > 17:12:20

 

I'm trying to substract TSent from TReceived and put it into a table.

I did something like :

| eval start=strptime(TSent, "%H:%M:%S.%N"), end=strptime(TReceived, "%H:%M:%S.%N")

| eval difference=end-start

|table end,start,difference

 

As a result, I correctly have something on the "end" and "star" column but "difference" stays empty.

Am I missing something?

Thanks.

Labels (1)
0 Karma
1 Solution

manjunathmeti
SplunkTrust
SplunkTrust

Your query is working.

| makeresults 
| eval TReceived="17:13:10", TSent="17:12:20" 
| eval start=strptime(TSent, "%H:%M:%S.%N"), end=strptime(TReceived, "%H:%M:%S.%N") 
| eval difference=end-start 
| table end,start,difference

 

View solution in original post

manjunathmeti
SplunkTrust
SplunkTrust

Your query is working.

| makeresults 
| eval TReceived="17:13:10", TSent="17:12:20" 
| eval start=strptime(TSent, "%H:%M:%S.%N"), end=strptime(TReceived, "%H:%M:%S.%N") 
| eval difference=end-start 
| table end,start,difference

 

Emp
Explorer

I didn't know the "makeresults" command. Seems easier to check with this.

 

On my side, my request is a bit more complicated but in the end, my "diff" column was still empty with this exact command |eval difference=end-start.

 

Table_Diff.png

With your confirmation that the request was working correctly, I found the solution and it was a simple mistake...

My "eval" command was before the "table" command and couldn't work.

I changed the order and now it's working perfectly.

 

It wasn't so much but thanks, it helps me a lot to clear my mind 😉

0 Karma

manjunathmeti
SplunkTrust
SplunkTrust

You're welcome! I'm glad it helped🙂

0 Karma
Get Updates on the Splunk Community!

Splunk Forwarders and Forced Time Based Load Balancing

Splunk customers use universal forwarders to collect and send data to Splunk. A universal forwarder can send ...

NEW! Log Views in Splunk Observability Dashboards Gives Context From a Single Page

Today, Splunk Observability releases log views, a new feature for users to add their logs data from Splunk Log ...

Last Chance to Submit Your Paper For BSides Splunk - Deadline is August 12th!

Hello everyone! Don't wait to submit - The deadline is August 12th! We have truly missed the community so ...