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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...