问题描述
尝试使用NiFi路由属性。 我正在尝试获取一个json文件,其中两个json记录包含以下属性(此文件中还有其他具有不同属性的json文档):
{
"ts" : "2020-010-07T12:00:00.448392Z","uid" : "CHh3F30dkfueLhnxSk","id.orig_h" : "10.10.10.10","id.orig_p" : 19726,"id.resp_h" : "172.10.10.20","id.resp_p" : 443,"proto" : "tcp","conn_state" : "SH","local_orig" : false,"local_resp" : false,"missed_bytes" : 0,"history" : "F","orig_pkts" : 1,"orig_ip_bytes" : 52,"resp_pkts" : 0,"resp_ip_bytes" : 0}
{
"ts" : "2020-10-10T12:00:00.461880Z","uid" : "CdoiLnRscrxO1BSYb","id.orig_h" : "10.10.17.777","id.orig_p" : 40433,"id.resp_h" : "172.10.10.77","version" : "TLSv12","cipher" : "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384","curve" : "secp777r1","server_name" : "connect-stackoverflow.questions.com","resumed" : false,"established" : true,"cert_chain_fuids" : [ "FR84qjkl2342SZLwV7","Ffweqiof48b8j" ],"client_cert_chain_fuids" : [ ],"subject" : "CN=connect-ulastm.bentley.com","issuer" : "CN=Let's Encrypt Authority X3,O=Let's Encrypt,C=US","validation_status" : "ok"}
我想专门路由$ .conn_state属性,但是它不起作用。我尝试将表达式与评估JSONpath处理器匹配,并将其传递给routeOnAttribute。这是我的设置:
上述处理器与json不匹配并转发文档
,然后是validateJSONpath,然后是routeOnAttribute处理器:
我尝试直接从jsonRecord路由routeOnAttribute,但是它似乎没有拉出或标识要路由的属性...
我该怎么做?
解决方法
@Advent United
JSON示例不止一个对象,您的validateJson期望匹配$ .conn_state的一条记录。对于针对json或任何数据流的多记录工作,应使用QueryRecord。在该处理器中配置了记录读取器和记录写入器后,只需单击+创建路由,值就是select语句,其中conn_state不为null。然后,您可以将该路由拖动到下一个处理器。