Support Questions

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

Nifi: Dynamic Attribute Creation

avatar

I'm trying to come up with a means for dynamic attribute creation. Say I've got a flat Json structured string of name value pairs, in a cassandra db as a text field.

{"A":"1", "B":"2"}

Is there a way to parse this out to a result of an A attribute with value 1 and B attribute with value 2 without explicitly creating a A attribute then polling the jsonpath?

I haven't had any luck in finding a way to dynamically set the lefthand side of an 'update attribute' and wondering if I'm just overlooking something.

1 ACCEPTED SOLUTION

avatar
Master Guru

You could probably implement a custom processor like "JsonToAttributes" very easily, iterate through a JSON document and add each field/value as an attribute to the flow file, or do it with a Groovy script in ExecuteScript.

The reason it doesn't exist is that in the general case you should be careful about adding a significant amount of attributes because those are held in memory, so if we provided this processor people would start using it to adding 100s of attributes to their flow files which could lead to poor performance and memory issues.

View solution in original post

1 REPLY 1

avatar
Master Guru

You could probably implement a custom processor like "JsonToAttributes" very easily, iterate through a JSON document and add each field/value as an attribute to the flow file, or do it with a Groovy script in ExecuteScript.

The reason it doesn't exist is that in the general case you should be careful about adding a significant amount of attributes because those are held in memory, so if we provided this processor people would start using it to adding 100s of attributes to their flow files which could lead to poor performance and memory issues.