Azure / azure-iot-pcs-remote-monitoring-dotnet

Azure IoT .NET solution for Remote Monitoring
MIT License
162 stars 95 forks source link

How can I deploy Remote Monitoring without using Times Series Insight? #140

Closed iotblackbelt closed 5 years ago

iotblackbelt commented 5 years ago

How can I deploy Remote Monitoring without using Times Series Insight, in other regions then China? My goal is to deploy RM without the use of TSI, as the customer doesn't want to use TSI. Is that possible?

iotblackbelt commented 5 years ago

changes the env-vars file to represent: export PCS_TELEMETRY_STORAGE_TYPE="cosmosdb" and restarted Now telemetry is reading from cosmosdb, but no messages end up in cosmosdb. All messages are still send to TSI. What do I need to change to ensure the telemetry is also send to cosmosdb?

iotblackbelt commented 5 years ago

Found it. Adjust the ASA query by adding: -- Output origin telemetry messages SELECT CONCAT(T.IoTHub.ConnectionDeviceId, ';', CAST(DATEDIFF(millisecond, '1970-01-01T00:00:00Z', T.EventEnqueuedUtcTime) AS nvarchar(max))) as id, 1 as [doc.schemaVersion], 'd2cmessage' as [doc.schema], T.IoTHub.ConnectionDeviceId as [device.id], 'device-sensors;v1' as [device.msg.schema], 'StreamingJobs' as [data.schema], DATEDIFF(millisecond, '1970-01-01T00:00:00Z', System.Timestamp) as [device.msg.created], DATEDIFF(millisecond, '1970-01-01T00:00:00Z', T.EventEnqueuedUtcTime) as [device.msg.received], udf.removeUnusedProperties(T) as Data INTO Messages FROM DeviceTelemetry T PARTITION BY PartitionId TIMESTAMP BY T.EventEnqueuedUtcTime

and adjust the ASA Messages output to send messages to the right CosmosDB database (messages instead of alerts).

Krummelz commented 5 years ago

Found it. Adjust the ASA query by adding: -- Output origin telemetry messages SELECT CONCAT(T.IoTHub.ConnectionDeviceId, ';', CAST(DATEDIFF(millisecond, '1970-01-01T00:00:00Z', T.EventEnqueuedUtcTime) AS nvarchar(max))) as id, 1 as [doc.schemaVersion], 'd2cmessage' as [doc.schema], T.IoTHub.ConnectionDeviceId as [device.id], 'device-sensors;v1' as [device.msg.schema], 'StreamingJobs' as [data.schema], DATEDIFF(millisecond, '1970-01-01T00:00:00Z', System.Timestamp) as [device.msg.created], DATEDIFF(millisecond, '1970-01-01T00:00:00Z', T.EventEnqueuedUtcTime) as [device.msg.received], udf.removeUnusedProperties(T) as Data INTO Messages FROM DeviceTelemetry T PARTITION BY PartitionId TIMESTAMP BY T.EventEnqueuedUtcTime

and adjust the ASA Messages output to send messages to the right CosmosDB database (messages instead of alerts).

Where did you find this information?