生成示例数据

本指南介绍了如何使用发布软件包中提供的 bash 脚本生成示例数据。

准备工作

请务必应用默认配置软件包或创建相关的消息类、类型和解析器。

执行脚本以生成示例数据

在部署软件包中的 /testing/send-data-to-mde.sh 文件内找到 bash 脚本。此脚本需要两个实参:

  1. 项目 ID。
  2. 要发送的数据类型。可以是 numericdiscrete

发送数据时,系统会自动注入时间戳,其余值保持不变。如果您想发送其他载荷,请修改该 Bash 脚本。

例如,如需发送 numeric 数据,请使用以下命令:

   ./send-data-to-mde.sh PROJECT_ID numeric

您会看到类似的响应:

   send-data-to-mde.sh: ***** Welcome to the MDE Data Generator *****
                     This script will send numeric data to MDE so that you can
                     validate that the entire pipeline is working
                     PROJECT_ID set to PROJECT_ID
                     You're authenticated as USER_EMAIL
                     Do you want to start sending data [Y/n]? Y

   Sending messages every 5 seconds
   Press [CTRL+C] to stop..
   Sent:
   {
   "tagName": "mde-test-numeric",
   "timestamp": "1695643807000",
   "value": 10
   }
   messageIds:
   - '8840355690320815'

如需发送 discrete 数据,请使用以下命令:

   ./send-data-to-mde.sh PROJECT_ID discrete

您会看到类似的响应:

   send-data-to-mde.sh: ***** Welcome to the MDE Data Generator *****
                     This script will send discrete data to MDE so that you can
                     validate that the entire pipeline is working
                     PROJECT_ID set to PROJECT_ID
                     You're authenticated as USER_EMAIL
                     Do you want to start sending data [Y/n]? Y

   Sending messages every 5 seconds
   Press [CTRL+C] to stop..
   Sent:
   {
   "tagName": "mde-test-discrete",
   "timestamp": "1695643827000",
   "value": {
      "test1": true,
      "test2": "someValue"
   }
   }
   messageIds:
   - '9223124765272389'