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!

New in Observability - Improvements to Custom Metrics SLOs, Log Observer Connect & ...

The latest enhancements to the Splunk observability portfolio deliver improved SLO management accuracy, better ...

Improve Data Pipelines Using Splunk Data Management

  Register Now   This Tech Talk will explore the pipeline management offerings Edge Processor and Ingest ...

3-2-1 Go! How Fast Can You Debug Microservices with Observability Cloud?

Register Join this Tech Talk to learn how unique features like Service Centric Views, Tag Spotlight, and ...