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!

Automatic Discovery Part 1: What is Automatic Discovery in Splunk Observability Cloud ...

If you’ve ever deployed a new database cluster, spun up a caching layer, or added a load balancer, you know it ...

Real-Time Fraud Detection: How Splunk Dashboards Protect Financial Institutions

Financial fraud isn't slowing down. If anything, it's getting more sophisticated. Account takeovers, credit ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...