Splunk Search

How to create search to filter on a field after rex extraction?

yanisA
Explorer

Hello,

I need to create a search that will display results based on a specific value.

My issue is that the following search does not return any result. In penultimate line, when I replace user_ip by index_field1="1.2.3.4" it works and when I remove both last lines I can see user_ip well contains "1.2.3.4"... But index_field1=user_ip does not match, same for index_field2...

index=...
| eval field1="1.2.3.4:100"
| rex field=src_ip_port "(?<user_ip>.+)\:(?<user_port>.+)"
| table user_ip user_port
| search index_field1=user_ip index_field2=user_port
| table index_field1 index_field2 user_ip user_port

Thanks by advance for your feedback.

Labels (2)
Tags (3)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

The search command cannot accept a field name on both sides of the =.  Use where, instead.

index=...
| eval field1="1.2.3.4:100"
| rex field=src_ip_port "(?<user_ip>.+)\:(?<user_port>.+)"
| table user_ip user_port
| where (index_field1=user_ip AND index_field2=user_port)
| table index_field1 index_field2 user_ip user_port
---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Splunk Observability Cloud’s AI Assistant in Action Series: Analyzing and ...

This is the second post in our Splunk Observability Cloud’s AI Assistant in Action series, in which we look at ...

Elevate Your Organization with Splunk’s Next Platform Evolution

 Thursday, July 10, 2025  |  11AM PDT / 2PM EDT Whether you're managing complex deployments or looking to ...

Splunk Answers Content Calendar, June Edition

Get ready for this week’s post dedicated to Splunk Dashboards! We're celebrating the power of community by ...