Splunk Search

How do I look for the existence of one field within another field?

rwmilligan
Explorer

For example, if I have a proxy log, and it shows User=A, then In the URL field we have "http://somesite.com/parameter=A", I want it to be able to pull up those logs.

Tags (1)
0 Karma
1 Solution

elliotproebstel
Champion

You can make that comparison by using where like() in this way:

| where like(URL, "%".user."%")

Here's some sample run-anywhere code. Everything before the where like() line is just making a couple of test events:

| makeresults 
| eval user="Alex", URL="http://somesite.com/parameter=Alex" 
| append 
    [| makeresults 
    | eval user="Beth", URL="http://somesite.com/parameter=Baloney"] 
| where like(URL, "%".user."%")

Note that the % are being appended to the start and end of the user field for the comparison, because these are the wildcards for the like function.

View solution in original post

elliotproebstel
Champion

You can make that comparison by using where like() in this way:

| where like(URL, "%".user."%")

Here's some sample run-anywhere code. Everything before the where like() line is just making a couple of test events:

| makeresults 
| eval user="Alex", URL="http://somesite.com/parameter=Alex" 
| append 
    [| makeresults 
    | eval user="Beth", URL="http://somesite.com/parameter=Baloney"] 
| where like(URL, "%".user."%")

Note that the % are being appended to the start and end of the user field for the comparison, because these are the wildcards for the like function.

richgalloway
SplunkTrust
SplunkTrust

Please share some sample events.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Observability Unlocked: Kubernetes Monitoring with Splunk Observability Cloud

 Ready to master Kubernetes and cloud monitoring like the pros? Join Splunk’s Growth Engineering team for an ...

Update Your SOAR Apps for Python 3.13: What Community Developers Need to Know

To Community SOAR App Developers - we're reaching out with an important update regarding Python 3.9's ...

October Community Champions: A Shoutout to Our Contributors!

As October comes to a close, we want to take a moment to celebrate the people who make the Splunk Community ...