即将针对新环境进行的 JSON 平展和转义规则更改Upcoming changes to JSON flattening and escaping rules for new environments

重要

这些更改将仅适用于新创建的 Azure 时序见解第 2 代环境。These changes will be applied to newly created Azure Time Series Insights Gen2 environments only. 它们不适用于第 1 代环境。The changes don't apply to Gen1 environments.

Azure 时序见解 Gen2 环境将按照一组特定的命名约定动态创建存储列。Your Azure Time Series Insights Gen2 environment dynamically creates your storage columns, following a particular set of naming conventions. 引入事件时,时序见解将向 JSON 有效负载和属性名称应用一组规则。When an event is ingested, Time Series Insights applies a set of rules to the JSON payload and property names. 2020 年 7 月,已开始在新的 Azure 时序见解第 2 代环境中应用对 JSON 数据的平展和存储方式的更改。Changes to how JSON data is flattened and stored went into effect for new Azure Time Series Insights Gen2 environments in July 2020. 在以下情况下,此更改会对你造成影响:This change impacts you in the following cases:

  • JSON 有效负载包含嵌套对象。Your JSON payload contains nested objects.
  • JSON 有效负载包含数组。Your JSON payload contains arrays.
  • 在 JSON 属性名称中使用下面四个特殊字符中的任意一个:[ \ . 'You use any of the following four special characters in a JSON property name: [ \ . '
  • 嵌套对象内有一个或多个时序 (TS) ID 属性。One or more of your Time Series (TS) ID properties are within a nested object.

如果你创建一个新环境,并且上述一个或多个事例适用于你的事件负载,则数据将以不同方式进行平展和存储。If you create a new environment and one or more of these cases applies to your event payload, your data will be flattened and stored differently. 下表概述了这些更改:The following table summarizes the changes:

当前规则Current rule 新规则New rule 示例 JSONExample JSON 以前的列名Previous column name 新列名New column name
使用下划线作为分割线来平展嵌套的 JSON。Nested JSON is flattened by using an underscore as the delineator. 使用句点作为分割线来平展嵌套的 JSON。Nested JSON is flattened by using a period as the delineator. {"series" : { "value" : 19.338 }} series_value_double series.value_double
不转义特殊字符。Special characters are not escaped. JSON 属性名称包含特殊字符 . [\,并使用 [''] 来转义 'JSON property names that include the special characters . [\ and ' are escaped using [' and ']. [''] 中,额外转义单引号和反斜杠。Within [' and '], there's additional escaping of single quotes and backslashes. 单引号将写为 \',反斜杠将写为 \\A single quote will be written as \' and a backslash as \\. "Foo's Law Value": "17.139999389648" Foo's Law Value_double ['Foo\'s Law Value']_double
基元数组存储为字符串。Arrays of primitives are stored as a string. 基元类型的数组存储为动态类型。Arrays of primitive types are stored as a dynamic type. "values": [154, 149, 147] values_string values_dynamic
始终平展对象数组,这会生成多个事件。Arrays of objects are always flattened, producing multiple events. 如果数组中的对象没有 TS ID 或时间戳属性,则对象数组将整体存储为动态类型。If the objects within an array don't have either the TS ID or timestamp properties, the array of objects is stored whole as a dynamic type. "values": [{"foo" : 140}, {"bar" : 149}] values_foo_long | values_bar_long values_dynamic

如果 TS ID 和/或时间戳属性嵌套在对象中If your TS ID and/or timestamp property is nested within an object

任何新部署都需要匹配新的引入规则。Any new deployments need to match the new ingestion rules. 例如,如果 TS ID 为 telemetry_tagId,则需要更新任何 Azure 资源管理器模板或自动部署脚本,将 telemetry.tagId 配置为环境 TS ID。For example, if your TS ID is telemetry_tagId, you need to update any Azure Resource Manager templates or automated deploy scripts to configure telemetry.tagId as the environment TS ID. 还需要对嵌套的 JSON 中的事件源时间戳进行此更改。You also need this change for event source timestamps in nested JSON.

如果有效负载包含嵌套的 JSON 或特殊字符,并且你可以自动创作时序模型变量表达式If your payload contains nested JSON or special characters and you automate authoring Time Series Model variable expressions

更新执行 TypesBatchPut 的客户端代码,以匹配新的引入规则。Update your client code that executes TypesBatchPut to match the new ingestion rules. 例如,"value": {"tsx": "$event.series_value.Double"} 之前的时序表达式应更新为以下选项之一:For example, you should update a previous Time Series Expression of "value": {"tsx": "$event.series_value.Double"} to one of the following options:

  • "value": {"tsx": "$event.series.value.Double"}
  • "value": {"tsx": "$event['series']['value'].Double"}

后续步骤Next steps