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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...