Splunk Search

How to select one of two event fields in stats?

user33
Path Finder

Hi, 

I have two event fields with the same name "timestamp". I just want to display (in stats) the "timestamp" field from the "ResponseReceive" logEventType. Not the one from logType "SystemLog". Currently is displays both.  Is there a way to do this? Any assistance is appreciated. Thank you!!

...
| fields timestamp, apiName, apiVersion, ceoCompanyId, entityId, sessionId, transactionDetailsResponse.transactionDetailsList.totalCount, transactionDetailsResponse.transactionDetailsList.transactionDetails{}.acctNumber, transactionDetailsResponse.transactionDetailsList.transactionDetails{}.Amount, transactionDetailsResponse.transactionDetailsList.transactionDetails{}.tranDateTime, transactionDetailsResponse.transactionDetailsList.transactionDetails{}.totalTranCount
| rename transactionDetailsResponse.transactionDetailsList.totalCount AS "TransactionCount", transactionDetailsResponse.transactionDetailsList.transactionDetails{}.acctNumber AS "AcctNum", transactionDetailsResponse.transactionDetailsList.transactionDetails{}.Amount AS "Amount", transactionDetailsResponse.transactionDetailsList.transactionDetails{}.tranDateTime AS "TranDateTime", transactionDetailsResponse.transactionDetailsList.transactionDetails{}.totalTranCount AS "TotalTranCount"
| stats
values(timestamp) AS timestamp,
values(TranDateTime) AS TranDateTime,
values(apiName) AS apiName,
values(apiVersion) AS apiVersion,
values(ceoCompanyId) AS ceoCompanyId,
values(entityId) AS entityId,
values(TotalTranCount) AS TotalTranCount,
values(AcctNum) AS AcctNum,
by sessionId,

 

user33_0-1657300216455.pnguser33_1-1657300249200.png

 

Labels (2)
0 Karma
1 Solution

danielcj
Communicator

Hello @user33 ,

Will the "ResponseReceive" always be received after the "SystemLog", I mean, will the timestamp of the ResponseReceive always be latest than the SystemLog timestamp?

If yes, you could use the "latest" command from stats.

For example:

| stats latest(timestamp) AS timestamp by sessionId

 

View solution in original post

0 Karma

danielcj
Communicator

Hello @user33 ,

Will the "ResponseReceive" always be received after the "SystemLog", I mean, will the timestamp of the ResponseReceive always be latest than the SystemLog timestamp?

If yes, you could use the "latest" command from stats.

For example:

| stats latest(timestamp) AS timestamp by sessionId

 

0 Karma

user33
Path Finder

Yes, it is. That worked perfectly. Thank you!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...