Splunk Search

Field Extraction

jeck11
Path Finder

This has been asked a million times. I've been digging through the various postings but haven't figured out what I'm doing wrong. 

I'm able to do a search time extraction using the rex command to get a field exactly the way I want it. But then when I try to add it to the field extractors, it's including too much information. I need to extract the LINK_TARGET value from the event below but the USER details are also being included in the field extractor setup. 

Hopefully my redactions don't make this impossible for gurus to assist.

Search command: 

 

index="index" search_term | rex field=_raw "LINK_TARGET\s:\s(?<link_target>.*)\n"

 

 

Data:

 

2021-11-10 16:03:14.631 INFO  [blah] [Country=US] [User=user] [ip] [DefaultLynxMetricsLogger] [blah] [blah]  Metrics logging start: key blah_SEARCH_ORIGIN 
LINK_TARGET : https://www.blah.com/en_US/blah?utm_source=copy&utm_medium=blah&utm_campaign=blah
USER : 9999999
Metrics logging end

 

 

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try this:

| rex field=_raw "LINK_TARGET\s:\s(?<link_target>\S*)"

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Try this:

| rex field=_raw "LINK_TARGET\s:\s(?<link_target>\S*)"

jeck11
Path Finder

The rex command is already working in the search time extraction. I'm trying to define it as a field extraction and that is where it's pulling back too much. Thanks though.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

What extraction do you currently have?

0 Karma

jeck11
Path Finder

I just updated the original post with screenshot. Do they help clarify the issue?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

So have you tried the different suggestions for the regex string?

0 Karma

jeck11
Path Finder

I'm a moron. I just copied yours over and it worked. Thanks for sticking with me. I'll mark it as the answer.

0 Karma

rafadvega
Path Finder

Hi!

You can use this command:

index="index" search_term | rex field=_raw "LINK_TARGET\s:\s(?<link_target>[^\n]*)\n"

Tags (2)
0 Karma

jeck11
Path Finder

The search syntax that I included is working fine. I'm trying to define it as a field extraction and that's where it's pulling in too much. Thanks though.

0 Karma
Get Updates on the Splunk Community!

The Splunk Success Framework: Your Guide to Successful Splunk Implementations

Splunk Lantern is a customer success center that provides advice from Splunk experts on valuable data ...

Splunk Training for All: Meet Aspiring Cybersecurity Analyst, Marc Alicea

Splunk Education believes in the value of training and certification in today’s rapidly-changing data-driven ...

Investigate Security and Threat Detection with VirusTotal and Splunk Integration

As security threats and their complexities surge, security analysts deal with increased challenges and ...