azure - 如何在使用 Azure 数据工厂数据流传输之前从日志文件中删除特定字段

标签 azure data-science azure-data-factory

我是 ADF 新手,但我已经成功完成了一些事件。我的问题陈述是:我有服务器生成的日志文件,我需要将它们传输到另一个位置以进行进一步处理。但是,在传输之前,我想从日志文件中删除某些字段,例如“partnerToken”、“orgToken”和“phi_msg”。我已经测试过使用 Azure 数据工厂复制数据传输文件,但我不确定如何实现过滤部分。我是否应该在 Azure 数据工厂中引入数据流?如果是,我可以使用什么表达式从日志文件中删除指定字段?

架构:

    {
  "type": "object",
  "properties": {
    "date": {
      "type": "string",
      "format": "date-time"
    },
    "level": {
      "type": "string"
    },
    "msg": {
      "type": "string"
    },
    "logId": {
      "type": "integer"
    },
    "traceId": {
      "type": "string"
    },
    "spanId": {
      "type": "string"
    },
    "resource": {
      "type": "object",
      "properties": {
        "appName": {
          "type": "string"
        },
        "module": {
          "type": "string"
        },
        "class": {
          "type": "string"
        },
        "function": {
          "type": "string"
        },
        "line": {
          "type": "integer"
        },
        "pid": {
          "type": "integer"
        },
        "thread": {
          "type": "string"
        }
      }
    },
    "attributes": {
      "type": "object",
      "properties": {
        "session": {
          "type": "string"
        },
        "orgToken": {
          "type": "string"
        },
        "partnerToken": {
          "type": "string"
        },
        "userId": {
          "type": "string"
        },  
        "phi_msg": {
          "type": "string"
        }
      }
    }
  }
}

任何有关如何使用 Azure 数据工厂数据流以及用于删除指定字段的适当表达式来实现此目的的指导都将受到高度赞赏。预先感谢您!

最佳答案

要删除字段,您需要首先将属性对象转换为字符串,然后使用所需字段解析它并选择它。

您可以按照以下步骤操作:

  • 我的Json文件数据预览 enter image description here
  • 进行派生列转换并使用表达式 toString(attributes) 将属性对象转换为字符串 enter image description here 数据预览: enter image description here
  • 然后解析字符串属性,如下所示(session as string,userId as string) enter image description here 数据预览: enter image description here
  • 然后在选择转换中删除 attributes 对象并将解析后的对象重命名为 attributes enter image description here
  • 将其存储在具有以下设置的新文件中,否则会给您带来架构错误 enter image description here

输出: enter image description here

关于azure - 如何在使用 Azure 数据工厂数据流传输之前从日志文件中删除特定字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76637605/

相关文章:

python - 使用 SimpleImputer 后 Dataframe 变成 numpy 数组。我希望它返回一个 dataframe

python - 我想帮助优化带有 if in 语句的三重 for 循环

python - 这是来自 Python 的 `c` 函数吗?

azure - 使用过滤器事件传递参数以复制事件

Azure 数据工厂 : Acquire MI token from MI store V1 failed. 错误代码 2403

python - 在 python 中将字节 block 流式传输到 csv 行

linux - 无法使用 CLI 将 Azure Function 发布到 Linux

c# - 当异常消息包含不可打印字符时,TraceSource.TraceEvent() 无法记录

c# - web.config 转换不转换

java - Azure 数据工厂 - 无法验证 invalid_grant