Splunk Search

Grouping logs by tranId, date and time

msarkaus
Path Finder

Hello,

I'm attempting to display a group of logs by the tranId. We log multiple user actions under a single tranId.  I'm attempting to group all of the logs for a single tranId in my dashboard.

I think I figured out how I want to display the logs, but I can't get the datetime format to correctly display.

index blah blah

| eval msgTxt=substr(msgTxt, 1, 141) 
| stats list(_time) as DateTime list(msgTxt) as Message list(polNbr) as QuoteId by tranId
| eval time=strftime(_time," %m-%d-%Y %I:%M:%S %p")
| streamstats count as log by tranId
| eval tranId=if(log=1,tranId,"")
| fields - log

msarkaus_0-1727888678654.png

 

Please help with displaying date and time format.

Thanks 

Labels (1)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @msarkaus ,

after a stats command, you have only the fields in the stats command, so you don't have yet the _time field,

in affirion, if you use the list option in the stats command you probably have too many values, so try values instead list,

try something like this:

index blah blah
| eval msgTxt=substr(msgTxt, 1, 141) 
| stats 
     vaues(_time) as DateTime 
     values(msgTxt) as Message 
     values(polNbr) as QuoteId 
     BY tranId
| eval DateTime=strftime(DateTime , "%m-%d-%Y %I:%M:%S %p")
| streamstats count as log by tranId
| eval tranId=if(log=1,tranId,"")
| fields - log

Ciao.

Giuseppe

 

View solution in original post

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @msarkaus ,

after a stats command, you have only the fields in the stats command, so you don't have yet the _time field,

in affirion, if you use the list option in the stats command you probably have too many values, so try values instead list,

try something like this:

index blah blah
| eval msgTxt=substr(msgTxt, 1, 141) 
| stats 
     vaues(_time) as DateTime 
     values(msgTxt) as Message 
     values(polNbr) as QuoteId 
     BY tranId
| eval DateTime=strftime(DateTime , "%m-%d-%Y %I:%M:%S %p")
| streamstats count as log by tranId
| eval tranId=if(log=1,tranId,"")
| fields - log

Ciao.

Giuseppe

 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @msarkaus ,

good for you, see next time!

Ciao and happy splunking

Giuseppe

P.S.: Karma Points are appreciated 😉

0 Karma
Get Updates on the Splunk Community!

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...

Announcing the Migration of the Splunk Add-on for Microsoft Azure Inputs to ...

Announcing the Migration of the Splunk Add-on for Microsoft Azure Inputs to Officially Supported Splunk ...