Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

How to ignore/filter flow-files on the base of attributes in Nifi

avatar
Expert Contributor

Hi,

I have a scenario where I want to ignore flow files if an attribute of a flowfile contains invalid value (like filename contains invalid value i.e name of a directory rather then a filename)

Is there a way to totally discard/ignore a FlowFile on the base of an attribute value?

Thanks

Obaid

1 ACCEPTED SOLUTION

avatar
Master Guru

The RouteOnAttribute processor is what you're looking for, you can match on an attribute value (for example), and only route to a "matched" relationship; self-terminating the "unmatched" relationship would cause the FlowFile to be discarded/ignored. Also if you want to do any error handling you could route unmatched flow files to another processor to log or otherwise handle them.

View solution in original post

6 REPLIES 6

avatar
Master Guru

The RouteOnAttribute processor is what you're looking for, you can match on an attribute value (for example), and only route to a "matched" relationship; self-terminating the "unmatched" relationship would cause the FlowFile to be discarded/ignored. Also if you want to do any error handling you could route unmatched flow files to another processor to log or otherwise handle them.

avatar

I'd add as a comment to Matt's answer that you can check the content of your attributes using the expression language [1]. It provides a lot of functions to deal with attributes and apply conditions to route your flow files if and only if they respect the conditions you want.

[1] https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html

avatar
Expert Contributor

Thanks a lot @Matt Burgess and @Pierre Villard for a quick response,

avatar
Explorer

Hello,

Is it possible to compare the attributes of two different flowfiles and only pass one if the comparisson results matched?

Thank you,

Jon

avatar
@Jon Rodriguez Breton

This should be a new question in HCC, not appended to your first question.

avatar
Explorer