我是 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文件数据预览
- 进行派生列转换并使用表达式
toString(attributes) 将属性对象转换为字符串
数据预览: - 然后解析字符串属性,如下所示
(session as string,userId as string)
数据预览: - 然后在选择转换中删除
attributes
对象并将解析后的对象重命名为attributes
- 将其存储在具有以下设置的新文件中,否则会给您带来架构错误
输出:
关于azure - 如何在使用 Azure 数据工厂数据流传输之前从日志文件中删除特定字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76637605/