All Apps and Add-ons

How to write a search query to monitor account for specific duration?

nnimbe
Path Finder

Hello All,

I need to monitor newly created user account for next 15 days.

I need a query where it will look for windows event code 4720, then extract the account name and put it for monitoring for next 15 days. Any activity from that account should logged. After 15 days, that account will be removed from monitoring. Same will repeat for all newly created user accounts.

Thank you.

0 Karma

adonio
Ultra Champion

hello there,
not sure i understand in full, what do you mean by "monitoring the account names for 15 days"? if you collect these logs anyways you have that data.
one approach can be to use a lookup table, something of this sort:

earliest= -15d@d latest=now index = Yourindex sourcetype=YourSourcetpye EventCode=4720 | table _time user | outputlookup new_accounts.csv

save this search to run daily so the lookup updates and you always have a list of 15 days worth of new users
now you can search leveraging the lookup command against your new lookup:
http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Lookup
hope it helps

0 Karma

woodcock
Esteemed Legend

I would have a search that runs daily like this:

earliest=-25h@h index=YourIndexHere sourcetype=YourSourcetypeHere EventCode=4720 
| dedup Account_Name 
| eval Account_Name = mvindex(Account_Name, 1) 
| table _time Account_Name
| rename _time AS Birthday
| appendpipe [|inputlookup NewUsersLastFifteenDays]
| dedup Account_Name
| where Birthday >= relative_time(now, "-15d@d")
| fieldformat Birthday = strftime(Birthday, "%m/%d/%Y %H:%M:%S")
| outputlookup NewUsersLastFifteenDays

Now you have a lookup that tells you whether the user is under monitoring that you can use at any time in any search like this:

index=YourIndexHere sourcetype=YourSourcetypeHere | lookup NewUsersLastFifteenDays | search Birthday="*"

Or like this:

index=YourIndexHere sourcetype=YourSourcetypeHere [|inputlookup NewUsersLastFifteenDays | fields Account_Name]
0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...