Adding User-Defined Attributes
In addition to having Processors that are able to extract particular pieces of information from FlowFile content into Attributes, it is also common for users to want to add their own user-defined Attributes to each FlowFile at a particular place in the flow. The UpdateAttribute Processor is designed specifically for this purpose. Users are able to add a new property to the Processor in the Configure dialog by clicking the "+" button in the top-right corner of the Properties tab. The user is then prompted to enter the name of the property and then a value. For each FlowFile that is processed by this UpdateAttribute Processor, an Attribute will be added for each user-defined property. The name of the Attribute will be the same as the name of the property that was added. The value of the Attribute will be the same as the value of the property.
The value of the property may contain the Expression Language, as well. This allows
Attributes to be modified or added based on other Attributes. For example, if we want to
prepend the hostname that is processing a file as well as the date to a filename, we could
do this by adding a property with the name filename
and the value
${hostname()}-${now():format('yyyy-dd-MM')}-${filename}
.
While this may seem confusing at first, the section below on Expression Language / Using Attributes in Property
Values will help to clear up what is going on here.
In addition to always adding a defined set of Attributes, the UpdateAttribute
Processor has an Advanced UI that allows the user to configure a set of rules for which
Attributes should be added when. To access this capability, in the Configure dialog's
Properties tab, click the Advanced
button at the bottom of the dialog.
This will provide a UI that is tailored specifically to this Processor, rather than the
simple Properties table that is provided for all Processors. Within this UI, the user is
able to configure a rules engine, essentially, specifying rules that must match in order
to have the configured Attributes added to the FlowFile.