Support Questions

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

How to Add Dynamic Tags in NiFi

avatar
Rising Star

Is it possible to use Expression language in UpdateAttribute processor?

Not for the Property Value but for the Property Name?

My mission is to get Dynamic Tag names.. If my JSON has 2 tags.. say Tag_1 and Tag_2.. I want to change them (tag_name not tag_value) to some other name, can that be done ?

OR

if existing tag name cannot be renamed, can I add a new tag? but again, the name of the Tag cannot be hardcoded in NiFi..

1 ACCEPTED SOLUTION

avatar
Master Mentor
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login
6 REPLIES 6

avatar
Master Mentor

Can you provide a little more detail on your use case? Are you trying to dynamically create new FlowFile Attributes or are you trying to update JSON tag names in the FlowFile content's JSON itself? The updateAttribute processor works with FlowFile Attributes using the expression language. The FlowFile's content is not read by this processor.

avatar
Rising Star

UpdateAttribute will change the value of the JSON tag.. but it wont change the name of the Tag.. I am looking to change the name of the tag dynamically..

Like suppose in my JSON, i have a tag named CREDIT_FLAG with value 'C'.. I want the name of the tag to change from CREDIT_FLAG to say CR_FL.. assuming the data "CR_FL" is also present in our flow..

-----

and if the above cannot be done, can we create new FlowFile Attributes dynamically? or any other way

-----

Summary:

Change tag name "CREDIT_FLAG" to "CR_FL" in any possible way using NiFi built in processors

-----

Let me know if more clarification is required..

avatar
Master Mentor
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login

avatar
Master Guru

If there is a fixed mapping of names, you can use JoltTransformJSON to rename the fields. For more complex things (dynamic attribute creation), you can use ExecuteScript.

avatar
Rising Star

there is no fixed mapping.. might go with Custom Processor to do all the tasks

avatar
Rising Star

yes, you are right.. even if the attributes get created.. I have no way to further reference them.. I was looking to create statements in PutSQL but yes I wont be able to do it..