Splunk Search

Extract Hostname, Date and time from the log

paullt12345
Explorer

Hi all

I want to extract Hostname, date and time from the log, Kindly help

sample log:
Mar 12 09:13:46 hostname1 <118>1 2019-03-12T09:13:46.743+00:00 ip.address

Hostname Date Time
hostname1 2019-03-12 09:13:46

0 Karma
1 Solution

vnravikumar
Champion

Hi @paullt12345

Try like

| makeresults 
| eval log="Mar 12 09:13:46 hostname1  <118>1 2019-03-12T09:13:46.743+00:00 ip.address" 
| rex field=log ":\d{2}\s+(?P<Hostname>.+)\s+<.*(?P<Date>\d{4}\-\d{2}\-\d{2})T(?P<Time>\d{2}\:\d{2}\:\d{2})"

View solution in original post

vnravikumar
Champion

Hi @paullt12345

Try like

| makeresults 
| eval log="Mar 12 09:13:46 hostname1  <118>1 2019-03-12T09:13:46.743+00:00 ip.address" 
| rex field=log ":\d{2}\s+(?P<Hostname>.+)\s+<.*(?P<Date>\d{4}\-\d{2}\-\d{2})T(?P<Time>\d{2}\:\d{2}\:\d{2})"

paullt12345
Explorer

it works.. thanks..

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 ...