Skip to content

Instantly share code, notes, and snippets.

@chanakaudaya
Last active December 15, 2022 09:41
Show Gist options
  • Save chanakaudaya/e5b767fb063bbfe97311a792be62a990 to your computer and use it in GitHub Desktop.
Save chanakaudaya/e5b767fb063bbfe97311a792be62a990 to your computer and use it in GitHub Desktop.
@App:name("AlertsAndThresholds")
@App:description('Simulate a single event and receive alerts as e-mail when a predefined threshold value is exceeded')
define stream TransactionStream(creditCardNo string, country string, item string, transaction double);
@sink(type='email',
username ='siddhi.sample',
address ='<sending_email>',
password= '<email_password>',
subject='Alert for large value transaction: cardNo:{{creditCardNo}}',
to='<receiving_email>',
port = '465',
host = 'smtp.gmail.com',
ssl.enable = 'true',
auth = 'true',
@map(type='text'))
define stream AlertStream(creditCardNo string, country string, item string, lastTransaction double);
@info(name='query1')
partition with(creditCardNo of TransactionStream)
begin
from TransactionStream#window.time(10 minute)[sum(transaction) > 100000]
select creditCardNo, country, item, transaction as lastTransaction
insert into AlertStream;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment