Splunk Search

How to apply eval to fields with complex names?

duesser
Path Finder

I am basically faced with this problem:

 

 

| makeresults count=3
| streamstats count
| eval a.1 = case(count=1, 1, count=2, null(), count=3, "null")
| eval a.2 = case(count=1, "null", count=2, 2, count=3, null())
| eval a3 = case(count=1, null(), count=2, "null", count=3, 3)
| table a*
| foreach mode=multifield * [eval <<FIELD>>=if(<<FIELD>>="null",null(),'<<FIELD>>')]

 

 

I have fields that contain a `.`. This screws up the `foreach` command. Is there a way to work around this? I have tried using `"<<FIELD>>"` but to no avail. 

I think it would work to rename all "bad" names, loop trough them and rename them back, but if possible I would like to avoid doing this.

 

 

 

Labels (2)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Use single quotes around field names when on the right of an assignment

| makeresults count=3
| streamstats count
| eval a.1 = case(count=1, 1, count=2, null(), count=3, "null")
| eval a.2 = case(count=1, "null", count=2, 2, count=3, null())
| eval a3 = case(count=1, null(), count=2, "null", count=3, 3)
| table a*
| foreach mode=multifield * [eval <<FIELD>>=if('<<FIELD>>'="null",null(),'<<FIELD>>')]
0 Karma
Get Updates on the Splunk Community!

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...