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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...