Splunk Search

How alert if the same account number is seen with transactions from different State codes and the total transaction amount exceeds $10,000 within one hour?

yogeshv23
New Member

I wanted to know how to write a search that will trigger an alert when it meets the following conditions: During a period of 1 hour, if the same account number is seen in the transaction log with transactions originating from different State codes and the total transaction amount exceeds $10000, then Splunk has to trigger an alert. Can I please get sample search that will do the following?

0 Karma
1 Solution

woodcock
Esteemed Legend

This should do it:

... | rex ",\s*State\s*:\s*(?<State>[^,]+).*?AccountNumber\s*:\s*(?<AccountNumber>\d+).*?Ammount\s*:\s*(?<Amount>\d+)" | bucket _time span=1h | stats sum(Amount) as total values(State) as States dc(State) AS numStates BY _time AccountNumber | where numStates > 1 AND Amount > 10000

View solution in original post

woodcock
Esteemed Legend

This should do it:

... | rex ",\s*State\s*:\s*(?<State>[^,]+).*?AccountNumber\s*:\s*(?<AccountNumber>\d+).*?Ammount\s*:\s*(?<Amount>\d+)" | bucket _time span=1h | stats sum(Amount) as total values(State) as States dc(State) AS numStates BY _time AccountNumber | where numStates > 1 AND Amount > 10000

yogeshv23
New Member

@woodcock,
I have set up a realtime alert using the query provided but am running into a few issues with alerting. I would like to get an alert when the condition is met for a particular account during a rolling window of time.
Example: if accountnumber 12345 has transactions logged within an hour in 3 different states which totals to greater than $10000 then it needs to just alert once (ideally) and then wait for the condition to be met again before triggering another alert.
How should I set up such an alert? Please guide me.

0 Karma

woodcock
Esteemed Legend

Do not use Real-Time; use a reasonable window scheduled at a reasonable period (something like every 10 minutes for the last hour). There are many reasons why and we can discuss them but trust me, this is a bad idea and will not do what you are hoping it will. When you schedule the alert, there are built-in throttling configurations that should meet your need; have you looked at (tried) them? If none will work, then you can output your current conditions with outputlookup and pull them back in for every search with inputlookup and use dynamic-lookup to write your own throttling conditions within your search.

0 Karma

yogeshv23
New Member

Thank you. When i try to schedule the alert, the only options I get are for scheduling every hr, day or week.
I was not able to figure out a way to schedule an alert like you have mentioned.

0 Karma

woodcock
Esteemed Legend

Choose the cron syntax and use:

*/10 * * * *

yogeshv23
New Member

Thank you! Worked fine and saved my time from trying to make the real time alert to work.

0 Karma

yogeshv23
New Member

Thank you! I will give it a try.

0 Karma

yogeshv23
New Member

Thank you so much. It worked!!!

0 Karma

lguinn2
Legend

Try this

yoursearchhere
| stats sum(amount) as total values(state_codes) as states by account_number
| where mvcount(states) > 1 AND total > 10000

Save this search as an alert. You can run this as a scheduled alert, once per hour - or as a real-time alert over the past hour. Set the trigger condition to be "number of results > 1".

yogeshv23
New Member

Thanks for your search query, I have provided a couple of lines of transaction logs above, please take a look and let me know if you have any suggestion or updates

0 Karma

yogeshv23
New Member

Thank you so much, this helped me narrow down my search query!

0 Karma

woodcock
Esteemed Legend

Do you have field extractions done? Show us a sample event.

0 Karma

yogeshv23
New Member

Hi,
Below are a couple of lines of the events. I will be doing the field extractions as well.
Kindly help.

2015-06-14 12:24:45,944 [10] DEBUG transaction.service.Transaction - [Transaction Id : 5e7fe57b-5aff-4575-a189-a6344aac2838, Status Code : Success, Latitude : 37.7845763, Longitude : -122.403748, ZIPCode: 94103, State : CA, Account Details : [ AccountNumber : 1111111310902197, AccountName : John Doe 310902197 , Ammount : 2000, Store : Macys ]]
2015-06-14 12:26:47,949 [10] DEBUG transaction.service.Transaction - [Transaction Id : 5e7fe57b-5aff-4575-a189-a6344aac2838, Status Code : Success, Latitude : 40.7033127, Longitude : -73.979681, ZIPCode: 10003, State : NY, Account Details : [ AccountNumber : 1111111310902197, AccountName : John Doe 310902197 , Ammount : 3000, Store : Nordstrom ]]

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...