Security

how to get string differences between 2 columns

shihabno
New Member

My query1 returns stats list and query2 is a subsearch that's retun another stats list. i added it with appendcols.
I want to have another 2 columns, col3:not in col1 but in col2, col4:not in col2 but in col1.
all columns are strings or alphanumeric.

| rest /services/admin/LDAP-groups splunk_server=abc
| mvexpand roles
| search roles=admin_user
| stats values(roles) as roles list(users) as admin_users1
| appendcols
[| rest /services/admin/LDAP-groups splunk_server=xyz
| mvexpand roles
| search roles=admin_user
| stats list(users) as admin_users2]

Result i looking(last 2 columns is what i am looking)

admin_users1 admin_users2 admin(users1-users2) admin(users2-users1)
A |A |B |C
B |C |D |F
D |E
E |F

0 Karma

somesoni2
Revered Legend

Give this a try

| rest /services/admin/LDAP-groups splunk_server=abc
| mvexpand roles
| search roles=admin_user
| stats count by users | table users| eval from="admin_users1"
| append
[| rest /services/admin/LDAP-groups splunk_server=xyz
| mvexpand roles
| search roles=admin_user
| stats count by users | table users | from="admin_users2"]
| stats values(from) as from_combined by users
| eval type=case(mvcount(from_combined)=2,"admin_users1 admin_users2", from_combined="admin_users1","In user1 only", true(), "In user2 only")
| makemv type | mvexpand type 
| eval temp=1 
| table temp type users
| chart values(users) over temp by type
0 Karma

jpolvino
Builder

Also, an image of the current output, and the additional columns you want to see. Annotate them to help us answer your question.

0 Karma

diogofgm
SplunkTrust
SplunkTrust

Can you give an example of the expected output?

------------
Hope I was able to help you. If so, some karma would be appreciated.
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...