Open madhurijain97 opened 1 year ago
I can help to solve this issue @madhurijain97
steps to solve this issue 👍
" First step " To achieve running a SQL query at a specific time every day based on different timezones in Siddhi, you can use the "corn" scheduler along with Siddhi's 'window' and 'trigger' extensions. Unfortunately, Siddhi does not directly support executing queries at specific times with time zones out of the box, but we can work around this limitation.
"Second step"
Here's how you can achieve your use case:
Here's an example Siddhi application to illustrate this:
@App:name("MissingEventDetectorApp") @App:description("Detect missing events and trigger an alert at a specific time every day in different timezones")
define stream InputStream (key string); define stream OutputStream (key string);
-- Window to detect missing events for 5 minutes (300 seconds) -- Adjust the duration based on your requirements from every e1 = InputStream[key == "1234"] -> e2 = InputStream[key == "1234"] for 5 min select e1.key as key insert expired events into MissingEventStream;
-- Define your alerting logic here, for simplicity, let's just log the missing event from MissingEventStream select key insert into AlertStream;
-- Trigger to start window processing at 2 PM every day in PST timezone -- Adjust the cron expression and timezone according to your requirement @info(name = 'Trigger') from every cron: 0 0 14 ? * America/Los_Angeles select currentTimeMillis() as triggerTime insert into TriggerStream;
-- Start the processing of the window at the trigger time from TriggerStream#window.time(1 sec) join MissingEventStream select triggerTime, key insert into FinalAlertStream;
note
In this example:
The InputStream stream represents your input data. The MissingEventStream stream captures events where the key "1234" is missing for 5 minutes. The AlertStream stream represents the alerts for missing events. The TriggerStream stream generates a trigger event at 2 PM every day in the PST timezone. The FinalAlertStream stream captures the final alerts triggered by combining the trigger events and missing event detections.
note
Remember to adjust the cron expression, window duration, and timezone according to your specific requirements. Additionally, you may need to implement your own logic for handling alerts based on inactive time.
Description: I have a usecase where we want a sql to run at a certain time everyday depending on different timezones. I see that we have triggers, but they are for injecting events and not for when to run the sql.
For eg. I want to detecting missing events for 5 minutes and want this to be triggered at 2pm PST everyday. Documentation doesn’t have details related to this.
from not inputStream[key == "1234"] for 300 sec select "1234" as key insert into outputStream
Note: I need this to be run at a specific time everyday since this rule sends out alerts only once and we have certain logic in place to filter out the alerts based on inactive time.
Is it possible to have a query that does the following?
from not inputStream[key == "1234"] for 300 sec select "1234" as key insert into outputStream RUN_AT <TIME> TIMEZONE <TIMEZONE>
Affected Siddhi Version:
OS, DB, other environment details and versions:
Steps to reproduce:
Related Issues: