Alerting

How to create time based alert?

kvm
Explorer

Hello,

I'd ask for a help on how to write a query where I need to get an alert "when there's a user added to a specific group and then removed from the group within 1 Hour time."

I'm new to Splunk, any help appreciated.

Labels (1)
Tags (2)
0 Karma

kvm
Explorer

I have Microsoft Teams data.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Can you share some sample events (anonymised)?

0 Karma

kvm
Explorer

Here it is,

 

{"AADGroupId": "3100c98b-8326-454458-003423", "CommunicationType": "Team", "CreationTime": "2022-03-17T08:11:51", "ExtraProperties": [], "Id": "9a706da1-cf0-c66248e", "ItemName": "xxxxxxx", "Members": [{"DisplayName": "def, abc", "Role": 1, "UPN": "[email protected]"}], "Operation": "MemberAdded", "OrganizationId": "e092a8e1", "RecordType": 25, "TeamGuid": "19:[email protected]", "TeamName": "xxxxxxx", "UserId": "[email protected]", "UserKey": "0b6cedcb-2a3386", "UserType": 0, "Version": 1, "Workload": "MicrosoftTeams"}

{"AADGroupId": "0158b60c-34ba9b", "CommunicationType": "Team", "CreationTime": "2022-03-17T08:39:08", "ExtraProperties": [], "Id": "24214374ab6", "ItemName": "yyyyyyyyyy", "Members": [{"DisplayName": "def, abc", "Role": 3, "UPN": "[email protected]"}], "Operation": "MemberRemoved", "OrganizationId": "e092ae38-85aa8", "RecordType": 25, "TeamGuid": "19:[email protected]", "TeamName": "yyyyyyyyyy", "UserId": "[email protected]", "UserKey": "5f4381bd-7ed505", "UserType": 0, "Version": 1, "Workload": "MicrosoftTeams"}

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Assuming you have _time as the timestamp for the events, you can run a scheduled report over the last hour, say every 5 minutes and alert if you get any results

... your index
| spath Operation
| spath UserId
| eval timeadded=if(Operation="MemberAdded",_time,null())
| eval timeremoved=if(Operation="MemberRemoved",_time,null())
| stats values(timeadded) as timeadded values(timeremoved) as timeremoved by UserId
| where isnotnull(timeadded) AND isnotnull(timeremoved) and timeadded <= timeremoved
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Start with the data. What events do you have ingested into splunk?

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Laser Bananas and Edge Hubs: Exploring Operational Technology (OT) Data Through a ...

  OT is a different environment to traditional IT and can have interesting challenges when interfacing the ...

Event Series: Mastering AI Tokenomics and Splunk Agent Observability

Beyond the Black Box: Correlating AI Performance and Tokenomics with Splunk Agent Observability   As ...

span_metrics: The OpenTelemetry-Idiomatic Way to See Inside Your Services

You open a trace in Splunk Observability Cloud and everything looks fine. One root span, order-pipeline, with ...