Splunk Search

How do I extract a field from my data in a search?

sim_tcr
Communicator

I want to extract the ip address as field ipaddress in a search.

04-15-2016 05:34:01.228 -0400 ERROR HttpClientRequest - HTTP client error: Connection reset by peer (while accessing http://xx.xx.xx.xx:8089/services/server/info)

Can some one please help?

0 Karma
1 Solution

javiergn
Super Champion

Hi,

Is this what you are trying to achieve?
(You can ignore the first two lines, they are just for me to be able to test this)

| stats count
| fields - count
| eval _raw = "04-15-2016 05:34:01.228 -0400 ERROR HttpClientRequest - HTTP client error: Connection reset by peer (while accessing http://123.45.67.89:8089/services/server/info)";
| rex "(?<ipaddress>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"

Another valid regex could be:

| rex "(?i)http://(?<ipaddress>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"

Or:

| rex "(?i)http://(?<ipaddress>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):"

View solution in original post

0 Karma

javiergn
Super Champion

Hi,

Is this what you are trying to achieve?
(You can ignore the first two lines, they are just for me to be able to test this)

| stats count
| fields - count
| eval _raw = "04-15-2016 05:34:01.228 -0400 ERROR HttpClientRequest - HTTP client error: Connection reset by peer (while accessing http://123.45.67.89:8089/services/server/info)";
| rex "(?<ipaddress>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"

Another valid regex could be:

| rex "(?i)http://(?<ipaddress>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"

Or:

| rex "(?i)http://(?<ipaddress>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):"
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 ...