【问题标题】:Filtering azure events from EventHub with Stream Analytics job query使用流分析作业查询从 EventHub 中过滤 Azure 事件
【发布时间】:2021-03-19 20:25:18
【问题描述】:

因此,我想使用流分析作业捕获 Azure 发送到 EventHub 的管理事件,并仅将符合特定条件的事件转发到 Azure 函数。事件出现在一个像这样的对象中(经过大量修剪以简化):

{
  "records": [
    {
      "resourceId": "<resource_path>",
      "operationName": "MICROSOFT.COMPUTE/VIRTUALMACHINES/WRITE",
    },
    {
      "time": "2021-03-19T19:19:56.0639872Z",
      "operationName": "MICROSOFT.COMPUTE/VIRTUALMACHINES/WRITE",
      "category": "Administrative",
      "resultType": "Accept",
      "resultSignature": "Accepted.Created",
      "properties": {
        "statusCode": "Created",
        "serviceRequestId": "<trimmed>",
        "eventCategory": "Administrative",
        "message": "Microsoft.Compute/virtualMachines/write",
        "hierarchy": "<trimmed>"
      },
      "tenantId": "<trimmed>"
    }
  ],
  "EventProcessedUtcTime": "2021-03-19T19:25:21.1471185Z",
  "PartitionId": 1,
  "EventEnqueuedUtcTime": "2021-03-19T19:20:43.9080000Z"
}

我想根据以下条件过滤查询:records[0].operationName = 'MICROSOFT.COMPUTE/VIRTUALMACHINES/WRITE' AND records[1].properties.statusCode = 'Created'。为此,我从返回此记录的以下查询开始,但它缺少我需要匹配的条件之一(statusCode)

SELECT
    records
INTO
    [output]
FROM
    [input]
WHERE
    GetArrayElement(records, 0).operationName = 'MICROSOFT.COMPUTE/VIRTUALMACHINES/WRITE'

尝试下面的查询不起作用(它返回 0 个匹配项):

SELECT
    records
INTO
    [output]
FROM
    [input]
WHERE
    GetArrayElement(records, 0).operationName = 'MICROSOFT.COMPUTE/VIRTUALMACHINES/WRITE'
    AND GetArrayElement(records, 1).properties.statusCode = 'OK'

有人知道这件事吗?

【问题讨论】:

    标签: azure azure-stream-analytics


    【解决方案1】:

    找到解决方案!我需要使用 GetRecordPropertyValue,如下所示:

    SELECT
        records
    INTO
        [output]
    FROM
        [input]
    WHERE
        GetArrayElement(records, 0).operationName = 'MICROSOFT.COMPUTE/VIRTUALMACHINES/WRITE'
        AND GetRecordPropertyValue(GetArrayElement(records, 1).properties, 'statusCode') = 'Created'
    

    在我看来有点笨拙,但它确实有效!

    【讨论】:

      猜你喜欢
      • 2018-11-03
      • 1970-01-01
      • 1970-01-01
      • 2020-02-23
      • 1970-01-01
      • 2017-07-25
      • 2016-12-26
      • 1970-01-01
      相关资源
      最近更新 更多