- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

iet_ashish
Explorer
04-26-2020
01:52 PM
On running this search,
| makeresults count=20
| streamstats count
| eval "genie.name"="foo", "genie:id"="bar"
| foreach genie*
[eval new_<<MATCHSTR>>=<<FIELD>>+"some string"]
I am expecting that two new fields named new_name
and new_id
would show, but that doesn't happen. Also an error comes up Failed to parse templatized search for field 'genie:id'
I am running on my local Splunk instance.
Thanks.
1 Solution
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
martin_mueller

SplunkTrust
04-26-2020
01:58 PM
It's not foreach that's failing, it's eval interpreting the dot as the concatenation operator. Enclose field names with operators in them in single quotes:
| foreach genie* [ eval new_<<MATCHSTR>> = '<<FIELD>>' + "some string" ]
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
martin_mueller

SplunkTrust
04-26-2020
01:58 PM
It's not foreach that's failing, it's eval interpreting the dot as the concatenation operator. Enclose field names with operators in them in single quotes:
| foreach genie* [ eval new_<<MATCHSTR>> = '<<FIELD>>' + "some string" ]
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

iet_ashish
Explorer
04-26-2020
11:26 PM
Thank you so much. This worked.
