Azure上的時序看法,Time series insights

5G來了,廣鏈接(mmTC)能夠實現每平方公里100萬的鏈接數(理論值),是4G的10倍,5G網絡出現,配合其餘技術,空間將在數據意義上劇烈壓縮,車聯網、智能家居、智能安防、智慧工廠、智慧能源均可能帶來質的變化。那麼隨之而來的物聯設備的數據也會幾何級增加,大量的模擬量數據,開關量數據的存儲,查詢,可視化將會帶來新的挑戰。html

 

基於時間序列的時序數據庫幾乎是專爲這樣的場景設計的,經過對時間的索引,能夠加快查詢,那麼Azure上是否有相似的產品呢?答案是Azure Time Series Insights。python

時序數據庫的基本概念,視頻地址:git

https://v.qq.com/x/page/m30210x07k3.htmlgithub

2.實戰Azure Time Series Insights數據庫

建立IoT Hub;網絡

建立時序看法app

 

從IoT Hub接收據;dom

在UI上查詢數據;ide

視頻地址:https://v.qq.com/x/page/t3021c6fmn0.htmlui

經過API調用時序數據:https://v.qq.com/x/page/r3021vuj1ct.html

視頻中的示例代碼:

案例中用到的Python模擬器代碼:

可參考官網教程:https://docs.azure.cn/zh-cn/iot-hub/quickstart-send-telemetry-python

 

import random
import time

# Using the Python Device SDK for IoT Hub:
#   https://github.com/Azure/azure-iot-sdk-python
# The sample connects to a device-specific MQTT endpoint on your IoT Hub.
from azure.iot.device import IoTHubDeviceClient, Message

# The device connection string to authenticate the device with your IoT hub.
# Using the Azure CLI:
# az iot hub device-identity show-connection-string --hub-name {YourIoTHubName} --device-id MyNodeDevice --output table
CONNECTION_STRING = "your device conn string"

# Define the JSON message to send to IoT Hub.
TEMPERATURE = 120.0
HUMIDITY = 160
MSG_TXT = '{{"temperature": {temperature},"humidity": {humidity}}}'

def iothub_client_init():
    # Create an IoT Hub client
    client = IoTHubDeviceClient.create_from_connection_string(CONNECTION_STRING)
    return client

def iothub_client_telemetry_sample_run():

    try:
        client = iothub_client_init()
        print ( "IoT Hub device sending periodic messages, press Ctrl-C to exit" )

        while True:
            # Build the message with simulated telemetry values.
            temperature = TEMPERATURE + (random.random() * 15)
            humidity = HUMIDITY + (random.random() * 20)
            msg_txt_formatted = MSG_TXT.format(temperature=temperature, humidity=humidity)
            message = Message(msg_txt_formatted)

            # Add a custom application property to the message.
            # An IoT hub can filter on these properties without access to the message body.
            if temperature > 30:
              message.custom_properties["temperatureAlert"] = "true"
            else:
              message.custom_properties["temperatureAlert"] = "false"

            # Send the message.
            print( "Sending message: {}".format(message) )
            client.send_message(message)
            print ( "Message successfully sent" )
            time.sleep(1)

    except KeyboardInterrupt:
        print ( "IoTHubClient sample stopped" )

if __name__ == '__main__':
    print ( "IoT Hub Quickstart #1 - Simulated device" )
    print ( "Press Ctrl-C to exit" )
    iothub_client_telemetry_sample_run()

相關產品的連接:

IoT Hub:https://docs.azure.cn/zh-cn/iot-hub/

時序看法:https://www.azure.cn/zh-cn/home/features/time-series-insights/

 

相關文章
相關標籤/搜索