Splunk Search

Cross filter two lookups where field contains other field

RobHoz
Engager

Hello, 
I'm trying to filter one lookup with the values of an other lookup.

This is the situation:

Lookup roles.csv contains the field with the security roles I would like to check for:

Role 
role1
role2
role3
role6


Lookup AssignedRoles.csv contains a field with all the assigned roles 

UserRole
User1role2 role5
User2role6
User3role9 role8
User4role7 role4
User5role1 role2

 

Now I want to return a table with all the users in AssignedRoles.csv that have an assigned Role from Roles.csv

Can anybody help me with an example query, if it is at all possible?

Thanks,
Robin

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

You could use a couple of nested joins

| makeresults count=50
| streamstats count as row
| eval User="User".(row-1)%10
| eval value=random()%100
| table User value


| join User 

    [| makeresults
    | eval _raw="User	Role
User1	role2 role5
User2	role6
User3	role9 role8
User4	role7 role4
User5	role1 role2"
    | multikv forceheader=1 
    | table User Role

    | eval Role=split(Role," ")
    | mvexpand Role
    | join 

        [| makeresults
        | eval _raw="Role 
role1
role2
role3
role6"
        | multikv forceheader=1 
        | table Role]

    ]

The makeresults generate dummy data, and the represent the inputlookups for your csv stores. I have assumed that the role lists are space separated and split them accordingly

View solution in original post

0 Karma

RobHoz
Engager

That approach worked for me, thank you!

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You could use a couple of nested joins

| makeresults count=50
| streamstats count as row
| eval User="User".(row-1)%10
| eval value=random()%100
| table User value


| join User 

    [| makeresults
    | eval _raw="User	Role
User1	role2 role5
User2	role6
User3	role9 role8
User4	role7 role4
User5	role1 role2"
    | multikv forceheader=1 
    | table User Role

    | eval Role=split(Role," ")
    | mvexpand Role
    | join 

        [| makeresults
        | eval _raw="Role 
role1
role2
role3
role6"
        | multikv forceheader=1 
        | table Role]

    ]

The makeresults generate dummy data, and the represent the inputlookups for your csv stores. I have assumed that the role lists are space separated and split them accordingly

0 Karma
Get Updates on the Splunk Community!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...