1

I'm new to Azure and to analytics. I'm trying to understand streaming alert rules engine. I have used some sample data as input and have queries to filter data. However i'm not sure of what rules engine means, is it just queries or is there anything more to it and is there a way we can have all rules in one if yes, how?

Nomad18
  • 111
  • 3
  • 8

1 Answers1

1

The main way to define logic for ASA is to use SQL, which provide a way to define rules with SQL statements (e.g. SELECT DeviceID ... WHERE temperature>50). Multiple conditions can be used in the same query and multiple queries can be defined in the same job. This approach is pretty flexible, however the rules themselves need to be defined before the job start since ASA will compile the job. See here for some common query patterns.

Then, when we talk about rule engine, users often require more dynamicity of the rules. In order to provide this dynamicity, it is possible to dynamically inject rule conditions, or even full rules to a running job (the later one is for advanced users). Below some detailed info:

  • Dynamically configure threshold rules using reference data: ASA can use reference data to get the latest conditions. See more details in this blog post
  • Dynamically inject rules using JavaScript UDF (this is more advanced): users can create a new function using JavaScript Function using code snippets coming from reference data. Such technique is used by Azure Remote Monitoring microservices (see here on GitHub).

Let me know if you have any further question and how we can improve.

Thanks,

JS (Azure Stream Analytics)

Jean-Sébastien
  • 727
  • 3
  • 7
  • Thanks for the reply Jean. I'm trying to develop packaged component with dynamic rules which can be easily deployed. Could you please help me with the same. – Nomad18 Nov 03 '18 at 09:39
  • Hi @jean-sébastien, Can you tell me more about "Dynamically inject rules using JavaScript UDF (this is more advanced): users can create a new function using JavaScript Function using code snippets coming from reference data."? I have a requirement to match multiple condition in same rule. I have tried multiple ways but no luck. You can see my detailed problem here: https://stackoverflow.com/questions/67107631/azure-stream-analytics-threshold-based-rule-with-multiple-conditions – Yash Mochi Apr 15 '21 at 12:04
  • Hi, if you have very specific logic for device, it may be possible to create a JavaScript rule that will be a string in the reference data. Then you can use the JS Eval function to execute it for this device as discussed here https://stackoverflow.com/questions/939326/execute-javascript-code-stored-as-a-string – Jean-Sébastien Apr 23 '21 at 20:42