Splunk Search

Multiple Timestamps - How to filter/select?

sarge338
Path Finder

Good day!

I am currently working on a search which provides data from two different event types (connection information and disposition information).  Everything is working well, except both event types have timestamps with the same name.  As a result, my returned data has two timestamps (in the same column) for each record.  

Is there a way to limit the number of timestamps per record to 1?  Or is there a way to somehow designate which event type the timestamp should be pulled from?

Thank you for your help!

Labels (1)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

Thank you for clarifying your question with mock code.


Is there a way to limit the number of timestamps per record to 1?  Or is there a way to somehow designate which event type the timestamp should be pulled from?

First, are teh two values of timestampStr represent the same time?  If yes, the answer is easy.  Just use the value.

If the two strings are different, only YOU can answer the question correctly.  What is the logic of using one vs the other?  Is one "better" than the other?  If it doesn't matter which, you can use first(timestampStr), last(timestampStr), earliest(timestampStr), latest(timestampStr), or any number of stats functions that yields a single value.

However, if you have a preference, you must describe your preference before any volunteer can help here.

0 Karma

sarge338
Path Finder

Hey Giuseppe!  Thanks for the quick response.  Below is my current SPL.

The "guid" field is what ties both event-types together for a single connection.

index="connection_data" 
| stats
values("connections{}.left.facets{}.number") as sourcenumber
values("connections{}.left.facets{}.country") as sourcecountry
values("connections{}.right.facets{}.number") as destinationnumber
values("connections{}.right.facets{}.country") as destinationcountry
values("meta") as direction
values("id") as policyrule
values("disposition.disposition") as disposition
values("resourceId") as router
values("timestampStr") as timestamp
by guid
| eval sourcenumber=mvdedup(sourcenumber)
| eval destinationregion=mvdedup(destinationregion)
| eval destination_rc=mvdedup(destination_rc)
| eval destinationcountry=mvdedup(destinationcountry)
| eval destinationnumber=mvdedup(destinationnumber)
| eval calldisposition=mvdedup(calldisposition)
| where disposition="TERMINATED"

| table timestamp guid sourcenumber sourcecountry destinationnumber destinationcountry direction router disposition

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Most of the eval commands with the mvdedup() functions are superfluous as values() functions in the the prior stats command already dedups the values returned in these fields.

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @sarge338 ,

yes, it's poossible to have one value for each column, but could you share your search?

otherwise it's difficoult to give a correct answer!

in general, you could display only one of the values in the timestamp column ore rename one of the fields, but I need your search to help you.

Ciao.

Giuseppe

0 Karma

sarge338
Path Finder

Hey Giuseppe!  Thanks for the quick response.  Below is my current SPL.

The "guid" field is what ties both event-types together for a single connection.

Seems I responded to myself first...

index="connection_data"
| stats
values("connections{}.left.facets{}.number") as sourcenumber
values("connections{}.left.facets{}.country") as sourcecountry
values("connections{}.right.facets{}.number") as destinationnumber
values("connections{}.right.facets{}.country") as destinationcountry
values("meta") as direction
values("id") as policyrule
values("disposition.disposition") as disposition
values("resourceId") as router
values("timestampStr") as timestamp
by guid
| eval sourcenumber=mvdedup(sourcenumber)
| eval destinationregion=mvdedup(destinationregion)
| eval destination_rc=mvdedup(destination_rc)
| eval destinationcountry=mvdedup(destinationcountry)
| eval destinationnumber=mvdedup(destinationnumber)
| eval calldisposition=mvdedup(calldisposition)
| where disposition="TERMINATED"

| table timestamp guid sourcenumber sourcecountry destinationnumber destinationcountry direction router disposition



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!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...