Splunk Search

how to get time stamps in a search result

marees123
Path Finder

i have a query which is returning the hostname , interface status (up/down). Would like to get time stamps for this occurrences. What query i need to add at the end of the query,. Please help me out

*swt* "changed state to" */*/* | rex "(?i) Interface (?P[^,]+)" | rex "(?i)changed state to (?P.+)" | table host, AnInterface, UpDown
Tags (2)
0 Karma
1 Solution

MuS
SplunkTrust
SplunkTrust

Hi marees123,

almost got it, try something like this:

*swt* "changed state to" */*/* | rex "(?i) Interface (?P[^,]+)" | rex "(?i)changed state to (?P.+)" | table _time, host, AnInterface, UpDown

hope this helps ...

cheers, MuS

View solution in original post

marees123
Path Finder

getting the logs like this... is there any way to filter the recent logs only. please help on this.
swt0001 GigabitEthernet2/0/2 down 2014-12-10 08:30:59
swt0001 GigabitEthernet1/0/2 down 2014-12-10 08:30:59
swt0001 GigabitEthernet2/0/2 down 2014-12-10 08:31:00
swt0001 GigabitEthernet1/0/2 down 2014-12-10 08:31:00
swt0001 GigabitEthernet2/0/2 up 2014-12-10 08:35:17
swt0001 GigabitEthernet1/0/2 up 2014-12-10 08:35:17
swt0001 GigabitEthernet2/0/2 up 2014-12-10 08:35:19
swt0001 GigabitEthernet1/0/2 up 2014-12-10 08:35:19

0 Karma

MuS
SplunkTrust
SplunkTrust

well use the time range picker to apply a time range to your search or use head after your search http://docs.splunk.com/Documentation/Splunk/6.2.0/SearchReference/Head

0 Karma

MuS
SplunkTrust
SplunkTrust

Hi marees123,

almost got it, try something like this:

*swt* "changed state to" */*/* | rex "(?i) Interface (?P[^,]+)" | rex "(?i)changed state to (?P.+)" | table _time, host, AnInterface, UpDown

hope this helps ...

cheers, MuS

marees123
Path Finder

thanks a ton MuS.. It simply worked... thanks again....

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...