Splunk Search

Why comparision not working when field is having value "*"

ma_anand1984
Contributor

fieldA is the extracted field already available
fieldB is eval field

| eval fieldB=*

| where fieldA=fieldB

Here im trying to match all values of fieldA. above command is not working

where as if i give
| eval fieldB=test

| where fieldA=fieldB
then it matches fieldA with value test

Im trying to do something complex , this is the part where i am stuck

Tags (2)
0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

The eval command treats the asterisk character as multiplication.

If your task is complex I recommend regular expressions, for example to match everything:

... | eval fieldB=".*" | where match(fieldA, fieldB)

To match "test":

... | eval fieldB="^test$" | where match(fieldA, fieldB)

View solution in original post

martin_mueller
SplunkTrust
SplunkTrust

The eval command treats the asterisk character as multiplication.

If your task is complex I recommend regular expressions, for example to match everything:

... | eval fieldB=".*" | where match(fieldA, fieldB)

To match "test":

... | eval fieldB="^test$" | where match(fieldA, fieldB)

Ayn
Legend

Just as an FYI, you don't need to call format at the end of a subsearch, because it will be called implicitly anyway.

ma_anand1984
Contributor

I prefer using your way. its faster 🙂

0 Karma

ma_anand1984
Contributor

thank you for the tip. I actually wrote a subsearch to achieve it !!!!

[search |stats count |eval fieldA= if("APP"=="APP","*","test") | fields fieldA| format]

0 Karma
Get Updates on the Splunk Community!

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

 Prepare to elevate your security operations with the powerful upgrade to Splunk Enterprise Security 8.x! This ...

Get Early Access to AI Playbook Authoring: Apply for the Alpha Private Preview ...

Passionate about security automation? Apply now to our AI Playbook Authoring Alpha private preview ...

Reduce and Transform Your Firewall Data with Splunk Data Management

Managing high-volume firewall data has always been a challenge. Noisy events and verbose traffic logs often ...