登錄檔事件 - AWS IoT Core

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

登錄檔事件

該登錄檔可能會在建立、更新或刪除物件、物件類型和物件群組時發佈事件訊息。不過,這些事件預設為無法使用。如需如何開啟這些事件的詳細資訊,請參閱 啟用 的事件 AWS IoT

此登錄檔可以提供下列事件類型:

物件事件

建立/更新/刪除的物件

該登錄檔會在建立、更新或刪除事物時發佈以下事件訊息:

  • $aws/events/thing/thingName/created

  • $aws/events/thing/thingName/updated

  • $aws/events/thing/thingName/deleted

訊息包含的承載範例如下:

{ "eventType" : "THING_EVENT", "eventId" : "f5ae9b94-8b8e-4d8e-8c8f-b3266dd89853", "timestamp" : 1234567890123, "operation" : "CREATED|UPDATED|DELETED", "accountId" : "123456789012", "thingId" : "b604f69c-aa9a-4d4a-829e-c480e958a0b5", "thingName" : "MyThing", "versionNumber" : 1, "thingTypeName" : null, "attributes": { "attribute3": "value3", "attribute1": "value1", "attribute2": "value2" } }

承載包含以下屬性:

eventType

設定為「THING_EVENT」。

eventId

獨特的事件 ID (字串)。

timestamp

事件發生時的 UNIX 時間戳記。

operation

觸發事件的操作。有效的 值如下:

  • CREATED (已建立)

  • UPDATED (已更新)

  • DELETED

accountId

您的 AWS 帳戶 ID。

thingId

建立、更新或刪除的物件之 ID。

thingName

建立、更新或刪除的物件之名稱。

versionNumber

建立、更新或刪除的物件之版本。物件建立時,此值設定為 1。物件更新時,此值會增加 1。

thingTypeName

與物件關聯的物件類型 (若存在)。否則為 null

屬性

與物件關聯的名稱/值對之集合。

物件類型事件

物件類型Created/Updated/Deprecated/Undeprecated/Deleted

當物件類型建立、更新、棄用、取消棄用或刪除時,登錄檔會發佈下列事件訊息:

  • $aws/events/thingType/thingTypeName/created

  • $aws/events/thingType/thingTypeName/updated

  • $aws/events/thingType/thingTypeName/deleted

訊息包含的承載範例如下:

{ "eventType" : "THING_TYPE_EVENT", "eventId" : "8827376c-4b05-49a3-9b3b-733729df7ed5", "timestamp" : 1234567890123, "operation" : "CREATED|UPDATED|DELETED", "accountId" : "123456789012", "thingTypeId" : "c530ae83-32aa-4592-94d3-da29879d1aac", "thingTypeName" : "MyThingType", "isDeprecated" : false|true, "deprecationDate" : null, "searchableAttributes" : [ "attribute1", "attribute2", "attribute3" ], "propagatingAttributes": [ { "userPropertyKey": "key", "thingAttribute": "model" }, { "userPropertyKey": "key", "connectionAttribute": "iot:ClientId" } ], "description" : "My thing type" }

承載包含以下屬性:

eventType

設定為「THING_TYPE_EVENT」。

eventId

獨特的事件 ID (字串)。

timestamp

事件發生時的 UNIX 時間戳記。

operation

觸發事件的操作。有效的 值如下:

  • CREATED (已建立)

  • UPDATED (已更新)

  • DELETED

accountId

您的 AWS 帳戶 ID。

thingTypeId

正在建立、更新、棄用或刪除的物件類型的 ID。

thingTypeName

正在建立、更新、棄用或刪除的物件類型名稱。

isDeprecated

如果指定物件類型已棄用,則為 true。否則為 false

deprecationDate

棄用物件類型的 UNIX 時間戳記。

searchableAttributes

與可用於搜尋的物件類型關聯之名稱/值對集合。

propagatingAttributes

傳播屬性的清單。傳播屬性可以包含物件屬性、連線屬性和使用者屬性金鑰。如需詳細資訊,請參閱新增訊息擴充的傳播屬性

description

物件類型描述。

關聯事物類型或取消關聯事物

當事物類型與事物關聯或取消關聯時,登錄檔會發佈以下事件訊息。

  • $aws/events/thingTypeAssociation/thing/thingName/thingType/typeName/added

  • $aws/events/thingTypeAssociation/thing/thingName/thingType/typeName/removed

以下是 added 承載的範例。removed 訊息的承載類似。

{ "eventId" : "87f8e095-531c-47b3-aab5-5171364d138d", "eventType" : "THING_TYPE_ASSOCIATION_EVENT", "operation" : "ADDED", "thingId" : "b604f69c-aa9a-4d4a-829e-c480e958a0b5", "thingName": "myThing", "thingTypeName" : "MyThingType", "timestamp" : 1234567890123, }

承載包含以下屬性:

eventId

獨特的事件 ID (字串)。

eventType

設定為 "THING_TYPE_ASSOCIATION_EVENT"。

operation

觸發事件的操作。有效的 值如下:

  • ADDED

  • REMOVED

thingId

類型關聯已變更的物件 ID。

thingName

類型關聯已變更的物件名稱。

thingTypeName

與物件相關聯或不再相關聯的物件類型。

timestamp

事件發生時的 UNIX 時間戳記。

物件群組事件

建立/更新/刪除物件群組

登錄檔會在建立、更新或刪除事物群組時發佈以下事件訊息。

  • $aws/events/thingGroup/groupName/created

  • $aws/events/thingGroup/groupName/updated

  • $aws/events/thingGroup/groupName/deleted

以下是 updated 承載的範例。createddeleted 訊息的承載類似。

{ "eventType": "THING_GROUP_EVENT", "eventId": "8b9ea8626aeaa1e42100f3f32b975899", "timestamp": 1603995417409, "operation": "UPDATED", "accountId": "571EXAMPLE833", "thingGroupId": "8757eec8-bb37-4cca-a6fa-403b003d139f", "thingGroupName": "Tg_level5", "versionNumber": 3, "parentGroupName": "Tg_level4", "parentGroupId": "5fce366a-7875-4c0e-870b-79d8d1dce119", "description": "New description for Tg_level5", "rootToParentThingGroups": [ { "groupArn": "arn:aws:iot:us-west-2:571EXAMPLE833:thinggroup/TgTopLevel", "groupId": "36aa0482-f80d-4e13-9bff-1c0a75c055f6" }, { "groupArn": "arn:aws:iot:us-west-2:571EXAMPLE833:thinggroup/Tg_level1", "groupId": "bc1643e1-5a85-4eac-b45a-92509cbe2a77" }, { "groupArn": "arn:aws:iot:us-west-2:571EXAMPLE833:thinggroup/Tg_level2", "groupId": "0476f3d2-9beb-48bb-ae2c-ea8bd6458158" }, { "groupArn": "arn:aws:iot:us-west-2:571EXAMPLE833:thinggroup/Tg_level3", "groupId": "1d9d4ffe-a6b0-48d6-9de6-2e54d1eae78f" }, { "groupArn": "arn:aws:iot:us-west-2:571EXAMPLE833:thinggroup/Tg_level4", "groupId": "5fce366a-7875-4c0e-870b-79d8d1dce119" } ], "attributes": { "attribute1": "value1", "attribute3": "value3", "attribute2": "value2" }, "dynamicGroupMappingId": null }

承載包含以下屬性:

eventType

設定為「THING_GROUP_EVENT」。

eventId

獨特的事件 ID (字串)。

timestamp

事件發生時的 UNIX 時間戳記。

operation

觸發事件的操作。有效的 值如下:

  • CREATED (已建立)

  • UPDATED (已更新)

  • DELETED

accountId

您的 AWS 帳戶 ID。

thingGroupId

建立、更新或刪除的物件群組之 ID。

thingGroupName

建立、更新或刪除的物件群組之名稱。

versionNumber

物件群組版本。物件群組建立時,此值設定為 1。物件群組更新時,此值會增加 1。

parentGroupName

父事物群組名稱 (若有的話)。

parentGroupId

父事物群組 ID (若有的話)。

description

物件群組描述。

rootToParentThingGroups

關於父物件群組的一系列資訊。每個父物件群組都有一個元素,從根物件群組開始,一直到物件群組的父項。每個項目都包含物件群組的 groupArngroupId

屬性

與物件群組關聯的名稱/值對之集合。

從事物群組新增或移除的事物

該登錄檔會在事物新增至事物群組,或從事物群組移除時發佈以下事件訊息。

  • $aws/events/thingGroupMembership/thingGroup/thingGroupName/thing/thingName/added

  • $aws/events/thingGroupMembership/thingGroup/thingGroupName/thing/thingName/removed

訊息包含的承載範例如下:

{ "eventType" : "THING_GROUP_MEMBERSHIP_EVENT", "eventId" : "d684bd5f-6f6e-48e1-950c-766ac7f02fd1", "timestamp" : 1234567890123, "operation" : "ADDED|REMOVED", "accountId" : "123456789012", "groupArn" : "arn:aws:iot:ap-northeast-2:123456789012:thinggroup/MyChildThingGroup", "groupId" : "06838589-373f-4312-b1f2-53f2192291c4", "thingArn" : "arn:aws:iot:ap-northeast-2:123456789012:thing/MyThing", "thingId" : "b604f69c-aa9a-4d4a-829e-c480e958a0b5", "membershipId" : "8505ebf8-4d32-4286-80e9-c23a4a16bbd8" }

承載包含以下屬性:

eventType

設定為「THING_GROUP_MEMBERSHIP_EVENT」。

eventId

事件 ID。

timestamp

事件發生時的 UNIX 時間戳記。

operation

當物件新增到物件群組時,ADDED。當物件從物件群組移除時,REMOVED

accountId

您的 AWS 帳戶 ID。

groupArn

物件群組的 ARN。

groupId

群組的 ID。

thingArn

物件群組新增或移除之物件的 ARN。

thingId

物件群組新增或移除之物件的 ID。

membershipId

代表物件和物件群組之間關係的 ID。當您在物件群組新增物件,就會產生此值。

從事物群組新增或移除的事物群組

當一個事物群組新增至另一個事物群組,或從另一個事物群組中移除事物群組時,登錄檔都會發佈以下事件訊息。

  • $aws/events/thingGroupHierarchy/thingGroup/parentThingGroupName/childThingGroup/childThingGroupName/added

  • $aws/events/thingGroupHierarchy/thingGroup/parentThingGroupName/childThingGroup/childThingGroupName/removed

訊息包含的承載範例如下:

{ "eventType" : "THING_GROUP_HIERARCHY_EVENT", "eventId" : "264192c7-b573-46ef-ab7b-489fcd47da41", "timestamp" : 1234567890123, "operation" : "ADDED|REMOVED", "accountId" : "123456789012", "thingGroupId" : "8f82a106-6b1d-4331-8984-a84db5f6f8cb", "thingGroupName" : "MyRootThingGroup", "childGroupId" : "06838589-373f-4312-b1f2-53f2192291c4", "childGroupName" : "MyChildThingGroup" }

承載包含以下屬性:

eventType

設定為「THING_GROUP_HIERARCHY_EVENT」。

eventId

事件 ID。

timestamp

事件發生時的 UNIX 時間戳記。

operation

當物件新增到物件群組時,ADDED。當物件從物件群組移除時,REMOVED

accountId

您的 AWS 帳戶 ID。

thingGroupId

父物件群組的 ID。

thingGroupName

父物件群組的名稱。

childGroupId

子物件群組的 ID。

childGroupName

子物件群組的名稱。