从json,nifi将纪元转换为UTC日期

时间:2019-07-17 11:31:35

标签: apache-nifi

嗨,我在流文件中包含以下json:{"destination.port":"0000","network.packets":"1","event.end":"1563361839","source.address":"1.2.2.1","message":"OK","server.address":"ip-1-2-2-3.ec2.internal","event.action":"ACCEPT","event.module":"s3bucket","source.port":"478","network.protocol":"6","cloud.account.id":"123456","event.type":"data","organization.id":"Fusion","destination.address":"1.2.2.2","network.bytes":"60","event.start":"1563361837","event.kind":"2","host.id":"eni-06f72","timestamp":"2019-07-17T11:16:39.792Z"},其中event.end和event.start为时期。

我正在使用nifi-1.9.2。 帮助我将纪元转换为UTC的日期并将其替换。我尝试将updateAttribute处理器与/event.start=${event.start:format("yyyy-MM-dd HH:mm:ss.SSS")}一起使用,但操作不正确。我已经为处理器读了一些书,但没有。谢谢

1 个答案:

答案 0 :(得分:0)

问题的根源是如何尝试从JSON中提取event.start。表达式语言用于操作FlowFile的属性,而不是FlowFile的内容。

如果您的FlowFile内容中包含此JSON,请使用EvaluateJsonPath,并将Destination属性设置为flowfile-attribute,并将新的自定义属性event.start设置为{{ 1}}。
现在,您已将其作为属性,将$['event.start']设置为JoltTransformJSON,将Jolt Transformation DSL设置为:{p>

Modify - Overwrite

后面的3个零是因为NiFi中的纪元以毫秒为单位。