Splunk Dev

Match and Exclude Specific Values in a Dynamic Field

cquinney
Communicator

Greetings Splunkers,

I'm attempting to create a dashboard panel that creates a count of "Roles" by Role_Names, however, I need to exclude specific field values from a dynamic field labeled "Roles" based on the Role_Name.

For example, if I have Role_Name=Security AND Roles=A, B, C, D, I want to exclude all those "Roles" for that specific "Role_Name and return a count value of "0". However, today, the "Roles" for Role_Name=Security can equal A, B, C, & D but next week it might equal A, B, & F, in this case, I'd want to still exclude A & B but count F.

Additionally, Roles can be associated with other Role_Names so I can't just exclude them from the search altogether. I know there's a way to accomplish this I just can't recall it. Any assistance is greatly appreciated.

0 Karma

cquinney
Communicator

I was able to find the answer with the assistance of a colleague. After running a stats command to correlate the data based on specific prerequisites, I did the following:

| mvexpand Roles
| search NOT (Role_Name=Security (Roles=A OR Role=B OR etc))
| stats values(blah) as blah count(Roles) as Role_Count by Role_Name

This provided me with my desired outcome and keeps my "Role_Count" flexible for that particular Role_Name. Hope this helps someone else down the line as well.

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...