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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...