Getting Data In

Filtering search results with mvfilter

CaninChristellC
Explorer

I'm creating a dashboard that displays events relating to servers ("host" field in the search). I want to allow the user to specify the hosts to include via a checkbox dashboard input, however I cannot get this to work.

To simplify the development process, I've mocked up the input into a search as so:

eventtype=SomeEventType | eval servers="serverName01;serverName02;serverName03" | makemv delim=";" servers | search mvfilter(host,servers)

(In the dashboard I obviously don't need to "eval servers=" and the "servers" is referenced $servers$, again I only changed this so I could play around with it in the raw search app)

...With my understanding is that it should filter the search results based on those that return "true." The search doesn't error out, but I get no results. However, with the search instead as simply:

eventtype=SomeEventType host="serverName01"

I do get results back.

How do I filter the results, correctly?

0 Karma

knielsen
Contributor

Hi,

You are not even using the mvfilter function, you are searching for it as a string.

What is the goal, do you want to filter for events that have the host in the list of servers, or do you want to change the servers list somehow?

If it is the former question, then you could use the mvfind command, eg:

| makeresults 
| eval host="serverName02", servers="serverName01;serverName02;serverName03" 
| makemv delim=";" servers 
| where isnotnull(mvfind(servers,host))

Is that what you were looking for?

Hth,
Kai.

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...