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

这些更改将仅适用于新创建的 Azure 时序见解 Gen2 环境。这些更改不适用于 Gen1 环境。These changes will be applied to newly created Azure Time Series Insights Gen2 environments only. These changes do not 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, a set of rules is applied to the JSON payload and property names. 2020 年 7 月,已开始在新的 Azure 时序见解 Gen2 环境中应用对 JSON 数据的平展和存储方式的更改。Changes to how JSON data is flattened and stored will go into effect for new Azure Time Series Insights Gen2 environments in July 2020. 在以下情况下,此更改会对你造成影响:This change impacts you in the following cases:

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

如果你创建一个新环境,并且上述一个或多个事例适用于你的事件负载,你将看到数据以不同方式平展和存储。If you create a new environment and one or more of the cases above applies to your event payload, you'll see your data flattened and stored differently. 更改的摘要如下:Below is a summary of the changes:

当前规则Current Rule 新建规则New Rule 示例 JSONExample JSON 旧列名Previous Column Name 新列名New Column Name
使用下划线作为分割线来平展嵌套的 JSONNested JSON is flattened using an underscore as the delineator 使用句点作为分割线来平展嵌套的 JSONNested JSON is flattened 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 will be written 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 propert(ies), 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 will need to match the new ingestion rules. 例如,如果 TS ID 为 telemetry_tagId,则需要更新任何 Azure 资源管理器(ARM 模板)或自动部署脚本,将 telemetry.tagId 配置为环境 TS ID。For example, if your TS ID is telemetry_tagId you'll need to update any Azure Resource Manager (ARM) templates or automated deploy scripts to configure telemetry.tagId as the environment TS ID. 嵌套的 JSON 中的事件源时间戳也需要进行此更改。This change is needed for event source timestamps in nested JSON as well.

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

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

后续步骤Next steps