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!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...