產生範例資料

本指南說明如何使用發布套件中提供的 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'