I have the following JSON:
{
"From": "stuart",
"Payload": {
"Alert": "Critical",
"Recipient": "Joe"
}
}
I want to route this based on if the field in Alert is 'Critical' or not.
I've tried RouteOnAttribute processor and also an EvaluateJson processor. Neither are working.
For RouteOnAttribute I've tried
Alerted: ${Payload:jsonPath('$.Alert'):equals('Critical')}
Then I have a relationship based on Alerted but nothing ever goes into my RouteOnAttribute processor, the queue just sits there till it fills to 10,000.
I need the full JSON to be routed, I can't lose information in the routing.
The issue is with jsonPath function works on flowfile attributes but you are not having Payload attribute associated with the flowfile.
How to add attribute to the flowfile?
After generateflowfile processor use EvaluateJsonPath processor with destination as flowfile-attribute,
Add new property
payload.alert as $.Payload.Alert
Then use routeonattribute processor add new property as
Alerted
${payload.alert:equals('Critical')}
Flow:
1.GenerateFlowFile
2.EvaluateJsonPath //extract the value and keep as attribute to the flowfile
3.RouteOnAttribute //check the attribute value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With