Alerting

Suggestions to write an alert if event B occurs without event A?

sarahnazzar
Explorer

Hello Splunkers!

I have an event A from source A and event B from source B.

I need an alert when event B occurs without event A... Is this feasible? Could you please help me or post some suggestions?

Thanks in Advance!

Labels (1)
0 Karma

to4kawa
Ultra Champion
(index=A source=A event=A) OR (index=B source=B event=B)
| eval common=coalesce(eventA,eventB)
| stats count(eval(source="A")) as A count(eval(source="B")) as B by common
| where B > 0 AND A = 0
0 Karma

sarahnazzar
Explorer

Thanks for the response @to4kawa !

In my case, event A and event B are the raw events, I don't have any fields extracted over there..

0 Karma

to4kawa
Ultra Champion

well, why don't you provide sample logs?

0 Karma

sarahnazzar
Explorer

PFB sample logs ,

EventA : Thu May 13 2020 00:15:05 mailsv1 sshd[4351]: Failed password for invalid user guest from 86.212.199.60 port 3771 ssh2

Event B : Thu May 13 2020 01:16:05 mailsv1 sshd[46748]: Received disconnect from 86.212.199.60: disconnected by user

0 Karma

to4kawa
Ultra Champion

two events have same ip address.
Let's extract and collect them.

0 Karma

sarahnazzar
Explorer

Hi.. in some cases the IPs are not same.. we need to filter using the string "Failed password" and "Received disconnect" and frame the query..

Thanks for your response @to4kawa!

0 Karma

to4kawa
Ultra Champion
...
| rex "(?<status>Failed password|Received disconnect)"
| reverse
| streamstats dc(status) as status_count
| where status_count =1 AND status="Received disconnect"

when event count > 0 , fire alert.

0 Karma

sarahnazzar
Explorer

Thanks for the response @to4kawa
I tried the using the query but its fetching event 2 even if event 1 occurred.

0 Karma

Yulworm
Engager

Hi @sarahnazzar , did you manage to get this working? Your comment implies that it does not work and I have not been able to adapt it to my, very similar, context

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

@Yulworm Please can you open a new providing more detail on your usecase?

0 Karma

to4kawa
Ultra Champion

If you are correct, then the event_count should be 2.

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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...