Splunk Search

How can I compare values from a lookup and alert when there is no mach?

yossefn
Path Finder

Hi, 

I have a lookup tables with user names (ftp_users.csv).

Every day I'm getting one line from a particular system with users with FTP permissions, I want to compare between the lookup file (which contains the allowed FTP users) with the line I'm getting from the system and to alert when there is no match. 

The line form the system looks similar to the below row:

users=user1, user2, user3, user4, user5

I'll appreciate any help with that,

Thank you. 

Labels (1)
0 Karma
1 Solution

to4kawa
Ultra Champion

| where isnull(ALLOWED_USERS)

or 

| search ALLOWED_USERS!=*

View solution in original post

to4kawa
Ultra Champion
index=_internal | head 1 | fields _raw _time | eval _raw="users=user1, user2, user3, user4, user5"
| rex "=(?<users>.*)"
| eval users=trim(split(users,","))
| mvexpand users

and

lookup

0 Karma

yossefn
Path Finder

That's great @to4kawa , now I have two fields ("users" field from the system's output, and "user" from my ftp_allowed lookup).

I ran the below stats and got two lists of users, now I just need to compare and alert when there is an extra user under one of the lists. 

 

| stats values(users) as ftp_users, values(user) as allowed_user

 

0 Karma

yossefn
Path Finder

Trying my luck another time..

I have created the below search:

 

 

<my search here>
| fields users
| eval users=trim(split(users,",")) 
| mvexpand users
| lookup as400_ftp_users.csv user as users OUTPUT user
| rename users as FTP_USERS, user as ALLOWED_USERS
| table FTP_USERS ALLOWED_USERS

 

 

Now I have two lists of users, ordered by user name:

MO***FRMO***FR
NA***ZANA***ZA
O***ASO***AS
R***NIR***NI
R***TL 
R***MKAR***MKA
S**IMS**IM
S***ARAS***ARA

 

I want to print out the extra user on the left side (R***TL) because this user is not in the "allowed users" list. 

Is that possible?

Thank you!

Tags (2)
0 Karma

to4kawa
Ultra Champion

| where isnull(ALLOWED_USERS)

or 

| search ALLOWED_USERS!=*

yossefn
Path Finder

Perfect.

Thank you @to4kawa 

0 Karma
Get Updates on the Splunk Community!

Observability | How to Think About Instrumentation Overhead (White Paper)

Novice observability practitioners are often overly obsessed with performance. They might approach ...

Cloud Platform | Get Resiliency in the Cloud Event (Register Now!)

IDC Report: Enterprises Gain Higher Efficiency and Resiliency With Migration to Cloud  Today many enterprises ...

The Great Resilience Quest: 10th Leaderboard Update

The tenth leaderboard update (11.23-12.05) for The Great Resilience Quest is out &gt;&gt; As our brave ...