【问题标题】:nifi Json data using routeonattributeto filter attribute or attribute valuenifi Json数据使用routeonattribute过滤属性或属性值
【发布时间】:2019-10-15 20:15:51
【问题描述】:

我目前正在使用 Nifi 使用数据来读取 Tealium 事件流并加载到 HDFS。当源未发送属性数据时需要帮助过滤数据。

{"account":"newtv","twitter:description":"发现您最喜欢的 NewTV 节目和主持人的播放时间。","og:locale":"en_US","dcterms:publisher":" NewTV","original-source":"www.newtv.com/","og:url":"www.newtv.com/show/program-guide"}},"post_time":"2019-10-09 11:27:46","useragent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36","event_id":"12345" }

上面的消息示例。当源错过从以下示例数据集中发送 event_id 属性的数据时,我目前坚持过滤数据。

当前的 Nifi 流量, 使用 Kafka -> 评估 Json 路径 -> Jolttransform Json -> 评估 Json 路径 -> RouteOnAttribute -> 合并内容 -> 评估 Json 路径 -> 更新属性 -> PutHDFS ->MoveHDFS

需要帮助如何使用 RouteOnAttribute 拆分数据以将缺少的 event_id 属性或属性值区分为两个不同的流。带有属性或属性值和缺失值的流会出错并加载到不同的输出路径中。

【问题讨论】:

    标签: apache-nifi cloudera hortonworks-data-platform data-ingestion hortonworks-sam


    【解决方案1】:

    EvaluateJsonPath 处理器中添加新属性以从流文件中提取event_id 值。

    如果流文件没有event_id,则 nifi 将空值添加到属性。

    EvaluateJsonPath Configs:

    然后通过使用RouteOnAttribute处理器,我们可以检查属性值并相应地路由流文件。

    RouteOnAttribute Configs:

    非空值

    ${event_id:isEmpty():not()}
    

    空值

    ${event_id:isEmpty()}
    

    然后使用空值而不是空值关系进行进一步处理..!!

    【讨论】:

    • 感谢舒的回复。我已经解决了这个问题。
    猜你喜欢
    • 1970-01-01
    • 2021-08-02
    • 1970-01-01
    • 2010-10-06
    • 2015-10-13
    • 2023-04-03
    • 2013-09-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多