Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How to apply condition on json response in NIFI

Highlighted

How to apply condition on json response in NIFI

Explorer

@myoung ...in nifi i have used invoked http processor that get data from web app.. i want to apply the condition on json data file ...i means when the resource="abc" the alarm get filter and goes to one processor and other alarm will go to another processor.....so my question is what are the processor is required..as of now i have used one http invoked that will provide all the alarm form my web app ..two putfile processor for storing alarm one for resource="abc" and one for other resource. and i have also used one Routonatrribute processor for condition..in RoutOnAttribute config i have decalred on dynamic property whic is ....the name of property is alarms.resource and the value is ${alarms.resource:equals('abc')} 

renuu_0-1590061592158.png

the below is respon of Invoked http processor...want the alarm that contain resource='abc' that will go to one put file processor
Spoiler
{ "alamrs": [ { "correlate": [ " ", " ", " " ], "event": " ", "group": " ", "history": [ { "event": " ", "href": " ", "id": " ", "resource": " abc ", "status": " ", "text": " ", "type": " ", "updateTime": " ", "user": " ", "value": "--" } ], "href": " ", "id": "", "rawData": null, "receiveTime": " ", "service": [ " " ], "resource": "abc", "status": " ", "tags": [ "" ], "text": " : ", "timeout": , }, { "correlate": [ " ", " ", " " ], "event": " ", "group": " ", "history": [ { "event": " ", "href": " ", "id": " ", "resource": " abc ", "status": " ", "text": " ", "type": " ", "updateTime": " ", "user": " ", "value": "--" } ], "href": " ", "id": "", "rawData": null, "receiveTime": " ", "service": [ " " ], "resource": "abc", "status": " ", "tags": [ "" ], "text": " : ", "timeout": , }, { "correlate": [ " ", " ", " " ], "event": " ", "group": " ", "history": [ { "event": " ", "href": " ", "id": " ", "resource": " abc ", "status": " ", "text": " ", "type": " ", "updateTime": " ", "user": " ", "value": "--" } ], "href": " ", "id": "", "rawData": null, "receiveTime": " ", "service": [ " " ], "resource": "abc", "status": " ", "tags": [ "" ], "text": " : ", "timeout": ,
1 REPLY 1
Highlighted

Re: How to apply condition on json response in NIFI

Master Collaborator

@renuu   RouteOnAttribute is the method to do this.  You will need to use EvaluateJsonPath to get the attributes you want to route on. For Example:

checkResource = $.alarms.resource  

Then code off that attribute in RouteOnAttribute:

 ${checkResource:equals('abc')}

 Also be sure to use valid json.  In your post above,  the snippet is incorrect format with spelling errors.  See my other reply for more info on JSON Validation as well as input on EvaluateJSON.

 

 

If this answer resolves your issue or allows you to move forward, please choose to ACCEPT this solution and close this topic. If you have further dialogue on this topic please comment here or feel free to private message me. If you have new questions related to your Use Case please create separate topic and feel free to tag me in your post.  

 

Thanks,


Steven @ DFHZ

 


 


If this answer resolves your issue or allows you to move forward, please choose to ACCEPT this solution and close this topic. If you have further dialogue on this topic please comment here or feel free to private message me. If you have new questions related to your Use Case please create separate topic and feel free to tag me in your post.  


 


Thanks,



Steven

Don't have an account?
Coming from Hortonworks? Activate your account here