Skip to main content

UpdateAttribute

Description

Updates the Attributes for a FlowFile by using the Attribute Expression Language and/or deletes the attributes based on a regular expression

Tags

Attribute Expression Language, attributes, delete, modification, state, update

Properties

In the list below required Properties are shown with an asterisk (*). Other properties are considered optional. The table also indicates any default values, and whether a property supports the NiFi Expression Language.

Display NameAPI NameDefault ValueAllowable ValuesDescription
Delete Attributes ExpressionDelete Attributes ExpressionRegular expression for attributes to be deleted from FlowFiles. Existing attributes that match will be deleted regardless of whether they are updated by this processor.

Supports Expression Language, using FlowFile attributes and Environment variables.
Store State *Store StateDo not store state
  • Do not store state
  • Store state locally
Select whether or not state will be stored. Selecting 'Stateless' will offer the default functionality of purely updating the attributes on a FlowFile in a stateless manner. Selecting a stateful option will not only store the attributes on the FlowFile but also in the Processors state. See the 'Stateful Usage' topic of the 'Additional Details' section of this processor's documentation for more information
Stateful Variables Initial ValueStateful Variables Initial ValueIf using state to set/reference variables then this value is used to set the initial value of the stateful variable. This will only be used in the @OnScheduled method when state does not contain a value for the variable. This is required if running statefully but can be empty if needed.
Cache Value Lookup Cache Size *canonical-value-lookup-cache-size100Specifies how many canonical lookup values should be stored in the cache

Dynamic Properties

NameValueDescription
A FlowFile attribute to updateThe value to set it toUpdates a FlowFile attribute specified by the Dynamic Property's key with the value specified by the Dynamic Property's value

Supports Expression Language: Yes, evaluated using FlowFile Attributes and Environment variables.

Relationships

NameDescription
successAll successful FlowFiles are routed to this relationship

Reads Attributes

This processor does not read attributes.

Writes Attributes

NameDescription
See additional detailsThis processor may write or remove zero or more attributes as described in additional details

State Management

ScopeDescription
LOCALGives the option to store values not only on the FlowFile but as stateful variables to be referenced in a recursive manner.

Restricted

This component is not restricted.

Input Requirement

This component requires an incoming relationship.

Example Use Cases

Use Case 1

Add a new FlowFile attribute

Configuration

Leave "Delete Attributes Expression" and "Stateful Variables Initial Value" unset.
Set "Store State" to "Do not store state".

Add a new property. The name of the property will become the name of the newly added attribute.
The value of the property will become the value of the newly added attribute. The value may use the NiFi Expression Language in order to reference other
attributes or call Expression Language functions.

Use Case 2

Overwrite a FlowFile attribute with a new value

Configuration

Leave "Delete Attributes Expression" and "Stateful Variables Initial Value" unset.
Set "Store State" to "Do not store state".

Add a new property. The name of the property will become the name of the attribute whose value will be overwritten.
The value of the property will become the new value of the attribute. The value may use the NiFi Expression Language in order to reference other
attributes or call Expression Language functions.

For example, to change the txId attribute to the uppercase version of its current value, add a property named txId with a value of ${txId:toUpper()}

Use Case 3

Rename a file

Configuration

Leave "Delete Attributes Expression" and "Stateful Variables Initial Value" unset.
Set "Store State" to "Do not store state".

Add a new property whose name is filename and whose value is the desired filename.

For example, to set the filename to abc.txt, add a property named filename with a value of abc.txt.
To add the txId attribute as a prefix to the filename, add a property named filename with a value of ${txId}$\{filename}.
Or, to make the filename more readable, separate the txId from the rest of the filename with a hyphen by using a value of ${txId}-$\{filename}.

System Resource Considerations

This component does not specify system resource considerations.

See Also