Splunk Search

How to detect a newly sessionid with SPL and alert.

umou7
Explorer

I want to do a security log monitoring and using splunk alert feature to send email notifications.

 

The security log and trigger condition is like this:

 

_time, SessionID,  filedA, fieldB

yyyymmdd,11111, xxxx,yyyyy

yyyymmdd,11111,bbbb,ccccc

yyyymmdd,22222,bbbb,ccccc

........

 

as this is a syslog monitoring task ,  I want to trigger an alert whenever a newly SessionID is detected.

It means the same SessionIDwill not be notified twice.

 

My SPL will be like below:

....| stats count by SessionID

 

Regarding to the alert configuration, which condition should I use?
Or is it possible to do this mostly in the base SPL?

 

Regards,

 

 

Tags (3)
0 Karma
1 Solution

Nisha18789
Builder

hi @umou7 , another option would be to write the session ids to summary index (you get this option when you create a report). However lookups are faster and you can use a KV store lookup which is faster than a lookup file. 

logic for alert with lookup will be like :

...| table _time, sessionid, otherfield1

| join type=outer sessionid

     [ search |inputlookup sessionhistory.csv

        |table sessionid | eval found_in_history=1]

| where isnull(found_in_history)

|outputlookup sessionhistory.csv append=true

 

now set alert action as email when result count > 0

 

Remember, first time when you are create the lookup you have to run a query for all time to populate the sessionid in the lookup, after that above alert logic will keep appending. 

View solution in original post

0 Karma

Nisha18789
Builder

hi @umou7 , below can be the approach for this:

1) create an inputlookup with all the sessionid's which are present in the log till now.

2) in the alert logic, join with this lookup you created in step1 and filter out the session id which does not match with the session id in lookup. Append this new session_id in the lookup created in step 1 and use alert action to send email if more than zero records found.

If you need help with the query, please let me know.

Please upvote my response if this answers your question.

 

 

 

0 Karma

umou7
Explorer

Thank you very much @Nisha18789  .

I am also considering of using a lookup table.

But I am worry about that the lookuptable will become larger and larger so that it will give an impact on performance.

Could you give me some advice on this?

It would be appreciated if you could give me an example of the query with bellow approaches you mentioned.

Did you mean that put step 1)  in a scheduled search, and put step 2) only in the alert logic ?

 

 

 

 

0 Karma

Nisha18789
Builder

hi @umou7 , another option would be to write the session ids to summary index (you get this option when you create a report). However lookups are faster and you can use a KV store lookup which is faster than a lookup file. 

logic for alert with lookup will be like :

...| table _time, sessionid, otherfield1

| join type=outer sessionid

     [ search |inputlookup sessionhistory.csv

        |table sessionid | eval found_in_history=1]

| where isnull(found_in_history)

|outputlookup sessionhistory.csv append=true

 

now set alert action as email when result count > 0

 

Remember, first time when you are create the lookup you have to run a query for all time to populate the sessionid in the lookup, after that above alert logic will keep appending. 

0 Karma

umou7
Explorer

Thank so much @Nisha18789 ,

This is what I wanted and it works well as expected.

I will populated the sessionids to a KV store lookup as you suggested.

 

Regards,

Mou

 

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!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...