Splunk Search

How to display the time of one search in the final result when we have another subsearch inside of it?

Vignesh5r
New Member

Below is my search.

What I need is to have the time related to that error also saved(Timen) and then shown in the final result which has result of another subsearch.

When I run it, I am getting the value of only FIELDNAME1 and not Timen.

index!=_internal "error" " |eval Timen=strftime(_time,"%m/%d/%y %T")|   accum Timen|                  rex "(?i)text>(?P[^<]+)" | dedup FIELDNAME | map search="search index!=_internal $FIELDNAME$" | search "error1 " |rex "(?i)text1=(?P[^]]+)" | rex "(?i)text2=(?P[^]]+)" |  eval Time=strftime(_time,"%m/%d/%y %T")| table FIELDNAME1  Time Timen 
0 Karma
1 Solution

somesoni2
Revered Legend

Give this a try

index!=_internal "error" |eval Timen=strftime(_time,"%m/%d/%y %T")| rex "(?i)text\>(?P<FIELDNAME>[^\<]+)" | dedup FIELDNAME | table Timen FIELDNAME | map search="search index!=_internal $FIELDNAME$ | eval Timen=\"$Timen$\"" | search "error1 " |rex "(?i)text1=(?P<FIELDNAME1>[^\]]+)" | eval Time=strftime(_time,"%m/%d/%y %T")| table FIELDNAME1 Time Timen

View solution in original post

0 Karma

somesoni2
Revered Legend

Give this a try

index!=_internal "error" |eval Timen=strftime(_time,"%m/%d/%y %T")| rex "(?i)text\>(?P<FIELDNAME>[^\<]+)" | dedup FIELDNAME | table Timen FIELDNAME | map search="search index!=_internal $FIELDNAME$ | eval Timen=\"$Timen$\"" | search "error1 " |rex "(?i)text1=(?P<FIELDNAME1>[^\]]+)" | eval Time=strftime(_time,"%m/%d/%y %T")| table FIELDNAME1 Time Timen
0 Karma

Vignesh5r
New Member

One more question. What if i have to display the FIELDNAME along with Timen?

0 Karma

Vignesh5r
New Member

It doesnt work. It displays $Timen and not the value

0 Karma

somesoni2
Revered Legend

Oops, missed a $ sign there. Try now.

0 Karma

Vignesh5r
New Member

Perfect. It works. Thanks a lot for your kind help on this!!!

0 Karma

Vignesh5r
New Member

Okay i found that this doesnt actually provide the result i am expecting. Let me correct my quetion. I need to know the time of the exact FIELDNAME which matches with the error1 field. (There can be multiple results for that fieldname initially and the timen is showing the latest one for that)

0 Karma

somesoni2
Revered Legend

The field names are stripped off in the question, making is difficult to understand. Apart from correcting that, could you also, describe your requirement here in little more details?

0 Karma

Vignesh5r
New Member
 index!=_internal "error" " |eval Timen=strftime(_time,"%m/%d/%y %T")| rex "(?i)text>(?P[^<]+)" | dedup FIELDNAME | map search="search index!=_internal $FIELDNAME$" | search "error1 " |rex "(?i)text1=(?P[^]]+)" |   eval Time=strftime(_time,"%m/%d/%y %T")| table FIELDNAME1  Time Timen

I want to display the field Timen in my results. Currently it displays only FIELDNAME1 and Time and not Timen

0 Karma
Get Updates on the Splunk Community!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...