Splunk Search

Issue with foreach in multivalue <<ITEM>> not recognized

Finn
Explorer

I have encountered an issue with the foreach command on mv-fields.

When I execute my search, Splunk says: "Error in 'eval' command: The expression is malformed. An unexpected character is reached at '<<ITEM>>'. "

SPL to reproduce:

 

 

| makeresults 
| eval mvfield=mvappend("1", "2", "3"), total=0 
| foreach mode=multivalue mvfield 
     [eval total = total + <<ITEM>>] 
| table mvfield, total

 

 

Note: this query is directly pulled from the examples for the foreach command.

Note2: the argument "mode" is not syntax-highlighted (would expect green)

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Are using Splunk 9.0 or later?  The mode option was not introduced until then.

FWIW, your query works as expected (including syntax highlighting) on my 9.0.0.1 system.

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Are using Splunk 9.0 or later?  The mode option was not introduced until then.

FWIW, your query works as expected (including syntax highlighting) on my 9.0.0.1 system.

---
If this reply helps you, Karma would be appreciated.

Finn
Explorer

No, I am not. Thank you for your reply.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...