gpt4 book ai didi

apache-nifi - 将纪元从 json、nifi 转换为 UTC 日期

转载 作者:行者123 更新时间:2023-12-02 19:55:53 24 4
gpt4 key购买 nike

您好,我在流文件中有以下 json: {"destination.port":"0000","network.packets":"1","event.end":"1563361839","source.地址":"1.2.2.1","消息":"确定","server.address":"ip-1-2-2-3.ec2.internal","event.action":"接受","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")} 一起使用,没走对。我已经阅读了一些有关处理器的内容,但没有。谢谢

最佳答案

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

如果此 JSON 位于您的 FlowFile 的内容中,则使用 EvaluateJsonPath,并将 Destination 属性设置为 flowfile-attribute 和新的自定义名为 event.start 的属性设置为 $['event.start']
现在您已将其作为属性,将其传输到 JoltTransformJSON,并将 Jolt Transformation DSL 设置为 修改 - 覆盖Jolt 规范 设置为:

{
"event.start": "${event.start:append('000'):format('yyyy-MM-dd HH:mm:ss.SSS')}"
}

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

关于apache-nifi - 将纪元从 json、nifi 转换为 UTC 日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57074841/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com