Getting Data In

Subtracts two time field showing null result

Manasi25
Explorer

Hi,

 

i have my query below, i used query from "Solved" questions on community, however its showing NULL result for me.

Query --

index=victorops sourcetype="splunk:victorops:incidents:json" "PTS"
| dedup incidentNumber
| eval startTimeFormatted=strptime(startTime,"%Y-%m-%dT%H:%M:%SZ") -18000
| eval SplunkStartTime=strftime(startTimeFormatted,"%m/%d/%y %H:%M:%S")


| eval endTimeFormatted=strptime(lastAlertTime,"%Y-%m-%dT%H:%M:%SZ") -18000
| eval SplunkEndTime=strftime(endTimeFormatted,"%m/%d/%y %H:%M:%S")


| eval MTTR = round((SplunkEndTime-SplunkStartTime)/86400)
| table incidentNumber, SplunkStartTime, routingKey, entityDisplayName, SplunkEndTime, currentPhase, MTTR


Above query  showing "NULL" output to "MTTR" field.

 

Please advise !

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| eval MTTR = tostring(endTimeFormatted-startTimeFormatted,"duration")

View solution in original post

0 Karma

scelikok
SplunkTrust
SplunkTrust

Hi @Manasi25,

Since the time fields are string formatted, MTTR calculation is not possible. Please try below options;

in days;
| eval MTTR =round((lastAlertTime-startTime)/86400)

OR formatted as duration; 
| eval MTTR = tostring(lastAlertTime-startTime, "duration")

 

If this reply helps you an upvote and "Accept as Solution" is appreciated.
0 Karma

Manasi25
Explorer

Hello

Thank you ! 
I used this and this shows "00:00:00" result to all time spam. PFA

Please advise further!

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| eval MTTR = tostring(round((endTimeFormatted-startTimeFormatted)/86400),"duration")
0 Karma

Manasi25
Explorer

Hello @ITWhisperer ,

I searched with your query and still getting "00:00:00" result to all rows.

 

PFA. please help !

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| eval MTTR = tostring(endTimeFormatted-startTimeFormatted,"duration")
0 Karma

Manasi25
Explorer

Hi @ITWhisperer 

This helps and result is good. Thank you !

0 Karma

isoutamo
SplunkTrust
SplunkTrust

Hi

you cannot calculate with string fields. You must use those with numeric values. In your case those are startTimeFormatted and endTimeFormatted.

If you would like to see MTTR as human readable convert it with 

eval MTTR = tostring(MTTR, "duration")

after calculation.

r. Ismo 

0 Karma
Get Updates on the Splunk Community!

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...

Cloud Monitoring Console - Unlocking Greater Visibility in SVC Usage Reporting

For Splunk Cloud customers, understanding and optimizing Splunk Virtual Compute (SVC) usage and resource ...

Automatic Discovery Part 3: Practical Use Cases

If you’ve enabled Automatic Discovery in your install of the Splunk Distribution of the OpenTelemetry ...