Support Questions

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

How to add a line of text to a flowfile

avatar
Rising Star

Is it possible to add a line of text to a flowfile? Or perhaps convert an attribute to a line in a flowfile?

1 ACCEPTED SOLUTION

avatar

What you're looking for is a patch that was recently merged into master:https://issues.apache.org/jira/browse/NIFI-447

It allows the ReplaceText processor to do multiple new things such as prepend or append a property (expression language supported) to either every line or the whole flowfile.

View solution in original post

4 REPLIES 4

avatar

First, you have to ask, what's a flowfile? It may not even be a file to add to, but just some binary chunk of data, an event, or an encrypted 100GB db dump, anything, really.

Next, where would you want to add the line to? Body/payload? Attribute? Prepend or append? Various processors will be used based on those answers. Sometimes it's easier to invoke ExecuteCommand and run your favorite linux command-line hack, too 🙂

Finally, if there's complicated logic on where and how to add the line - consider a custom processor: https://cwiki.apache.org/confluence/display/NIFI/Maven+Projects+for+Extensions

avatar

What you're looking for is a patch that was recently merged into master:https://issues.apache.org/jira/browse/NIFI-447

It allows the ReplaceText processor to do multiple new things such as prepend or append a property (expression language supported) to either every line or the whole flowfile.

avatar
Master Mentor

We need to make sure to get the terminology correct first. A "FlowFile" in NiFi is the combination of Metadata (A map of key/value pair attribute strings) and the associated content. Are we asking how to take an Attribute that is part of the FlowFile and add it to the content portion of a FlowFile? If so, Joe's answer above covers that.

avatar
Rising Star

Sorry about not being clear in the description. I am trying to write a line to the payload of a Flowfile. The content is simply text that I would like to add a time stamp too. Prepend or append both work.

my work around for the moment is to start with a template file that contains place holders for the various content I would like to add. I use the get file processor to pick up the template file and use the replace text processor to replace the place holders with my data. It works 😕