Support Questions

Find answers, ask questions, and share your expertise

Nifi UpdateAttribute questions

avatar
Contributor

Hi

How do you pull in a new attribute added by using UpdateAttribute, such as add a new attribute name as 'label' and value as 'source1', to flow file (say file saved to location by PutFile processor)?

Data Provenance showed new attribute with the right value in Attributes tab, but in Content tab Output Claim view does not show the new attribute at all. Shouldn't it shows there too?

Thanks!

Shannon

1 ACCEPTED SOLUTION

avatar
Expert Contributor

Hey Shannon,

You would call the new attribute with the expression language so you would type /root/${label}/ the {$VARIABLE} syntax can be used anywhere where expression language is allowed.

View solution in original post

7 REPLIES 7

avatar
Expert Contributor

Hey Shannon,

You would call the new attribute with the expression language so you would type /root/${label}/ the {$VARIABLE} syntax can be used anywhere where expression language is allowed.

avatar
Contributor

@Chris Gambino

Hey Chris,

Thanks for the help! A follow up question-- what processor would it take to call the new attribute and add to the flowfile before sending to PutFile? It can't be MergeContent, right? couldn't find anything like union.

Thanks again!

Shannon

avatar
Expert Contributor

are you looking to replace the flowfile content with the extracted attribute? Perhaps AttributesToJSON

If you could mark my answer as correct if that solves the first one it closes out this question!

avatar
Contributor
@Chris Gambino

Hey Chris,

No - not replace, but add the new attribute to original attributes.

Thanks!

Shannon

avatar
Expert Contributor

Architecturally each mmessage is immutable, changing anything in it means re-writing the flow-file contents. To add text to a message like that is tough. Is the message already in JSON format?

avatar
Contributor

@Chris Gambino

yes, it is json format already.

update: parse all to attributes then turn them all back to Json together with new attribute solved it.

Thanks a lot for all your help!

Shannon

avatar
Expert Contributor

Shannon, try to extract the entire json into an attribute like you do. Then do "attributesToJson" to push it all inot one flow file perhaps?