Azure / azure-iot-remote-monitoring

Azure IoT Remote Monitoring preconfigured solution
Other
249 stars 221 forks source link

about custom rules for iot suite v1 #464

Closed LeonardBae closed 3 years ago

LeonardBae commented 6 years ago

I am currently sending 6 variables from the device to the iot hub. However, there is a problem in the Rule setting section. Each rule must be specified for a total of six variables. So we created a total of six receivers using the select statement as shown in the link below.

https://github.com/Azure/azure-iot-remote-monitoring/blob/master/Tutorials/iot-suite-v1-custom-rule.md

**WITH AlarmsData AS ( SELECT Stream.IoTHub.ConnectionDeviceId AS DeviceId, 'var1' as ReadingType, Stream.var1 as Reading, Ref.var1 as Threshold, Ref.var1RuleOutput as RuleOutput, Stream.EventEnqueuedUtcTime AS [Time] FROM IoTTelemetryStream Stream JOIN DeviceRulesBlob Ref ON Stream.IoTHub.ConnectionDeviceId = Ref.DeviceID WHERE Ref.var1 IS NOT null AND Stream.var1 >= Ref.var1

UNION ALL

SELECT Stream.IoTHub.ConnectionDeviceId AS DeviceId, 'var2' as ReadingType, Stream.var2 as Reading, Ref.var2 as Threshold, Ref.var2RuleOutput as RuleOutput, Stream.EventEnqueuedUtcTime AS [Time] FROM IoTTelemetryStream Stream JOIN DeviceRulesBlob Ref ON Stream.IoTHub.ConnectionDeviceId = Ref.DeviceID WHERE Ref.var2 IS NOT null AND Stream.var2 >= Ref.var2

UNION ALL

SELECT Stream.IoTHub.ConnectionDeviceId AS DeviceId, 'var3' as ReadingType, Stream.var3 as Reading, Ref.var3 as Threshold, Ref.var3RuleOutput as RuleOutput, Stream.EventEnqueuedUtcTime AS [Time] FROM IoTTelemetryStream Stream JOIN DeviceRulesBlob Ref ON Stream.IoTHub.ConnectionDeviceId = Ref.DeviceID WHERE Ref.var3 IS NOT null AND Stream.var3 >= Ref.var3

UNION ALL

SELECT Stream.IoTHub.ConnectionDeviceId AS DeviceId, 'var4' as ReadingType, Stream.var4 as Reading, Ref.var4 as Threshold, Ref.var4RuleOutput as RuleOutput, Stream.EventEnqueuedUtcTime AS [Time] FROM IoTTelemetryStream Stream JOIN DeviceRulesBlob Ref ON Stream.IoTHub.ConnectionDeviceId = Ref.DeviceID WHERE Ref.var4 IS NOT null AND Stream.var4 >= Ref.var4

UNION ALL

SELECT Stream.IoTHub.ConnectionDeviceId AS DeviceId, 'var5' as ReadingType, Stream.var5 as Reading, Ref.var5 as Threshold, Ref.var5RuleOutput as RuleOutput, Stream.EventEnqueuedUtcTime AS [Time] FROM IoTTelemetryStream Stream JOIN DeviceRulesBlob Ref ON Stream.IoTHub.ConnectionDeviceId = Ref.DeviceID WHERE Ref.var5 IS NOT null AND Stream.var5 >= Ref.var5

UNION ALL

SELECT Stream.IoTHub.ConnectionDeviceId AS DeviceId, 'var6' as ReadingType, Stream.var5 as Reading, Ref.var6 as Threshold, Ref.var6RuleOutput as RuleOutput, Stream.EventEnqueuedUtcTime AS [Time] FROM IoTTelemetryStream Stream JOIN DeviceRulesBlob Ref ON Stream.IoTHub.ConnectionDeviceId = Ref.DeviceID WHERE Ref.var6 IS NOT null AND Stream.var6 >= Ref.var6

)

SELECT * INTO DeviceRulesMonitoring FROM AlarmsData

SELECT * INTO DeviceRulesHub FROM AlarmsData**

However, when I created the query like above, the following error occurred. stream analytics job has validation errors job will exceed the maximum amount of event hub receivers

I would appreciate any help in resolving this situation. It seems like we need to add a consumer group on the rule-out event hub, and I want to know the exact workload. Thanks.

ankitscribbles commented 3 years ago

Note: As of December 10th 2020, Remote Monitoring solution accelerator is no longer supported. All supporting repositories have been archived.