Splunk Search

How do you use multi value tags in eval?

Marinus
Communicator

I getting an eval error when I'm trying to use eval on a host tag.
"Error in 'eval' command: The expression is malformed. Expected )"

Most hosts have more than on tag.

* | eval nr_tags=eval(mvcount(tag::host))
Tags (1)

bob_kerns
Explorer

Very belated answer, but helpful for those who may end up here by search...

Instead of "tag::host", try single quote:
* | eval nr_tags=mvcount('tag::host')

Try this and compare the results. Set up more than one tag on at least one host so you can compare:

* | eval foo="tag::host"
   | tags outputfield=bar host
   | eval bar2='tag::host'
   | eval baz=mvcount("tag::host")
   | eval buz=mvcount('tag::host')
0 Karma

bob_kerns
Explorer

Note, however, that this won't work in a computed field, since tagging happens after field extraction (including computed fields).

0 Karma

msenebald
Explorer

Hi I have a similar problem.

the thing is even with

* | eval nr_tags=mvcount("tag::host")

you will always get 1 in nr_tags. it takes this as a string.

I would like to do something like this:

| eval iscool=if("tag::host" == "cool", "yes" , "no")

where host=fridge with tags: cool, fridge, ..

So actually i want to have a field in case a certain tag is applied to this event.
But i strugle to identify this in the tag::host field. mvcount and so always sees "tag::host" as a string, not as the field

Any Ideas?

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Monitoring AI Agents with Splunk Observability Cloud

Let’s say I’m running a travel planning AI app in production. A user asks for three concise hotel options in ...

[Puzzles] Solve, Learn, Repeat: Tiling

This puzzle (first published here) is based on finding groups of tessellated tiles (inspired by floor tiles I ...

SOK it to Me: Top 3 Benefits of Using Splunk Operator on Kubernetes that’ll Make ...

    Thursday, July 9, 2026  |  11:00AM–12:00PM PDT Duration: 1 hour (includes Q&A) Managing can feel like a ...