Support Questions

Find answers, ask questions, and share your expertise

append an attribute to flowfile content at the end

avatar
Expert Contributor

Hi All,

 

I am using putdatabaserecord to store a value into DB.

Now i have a flow based on failure link to (this processor), that this failed record will be stored in disc for troubleshooting.

I can store the failed record in disc by using putfile processor.

Now i wanted it more informative during debugging, as the attribute "putdatabaserecord.error" contains the error reason, i want to append the flowfile content with this error reason.

 

 I tried to acheive this using below flow..

putsql/putdbrecord -> failure-> updateattribute (this is to give the flowfile a realistic name)-> attributesToJson (destination flowfileattribute/content -> putfile

SandyClouds_0-1685028702216.png

but in attributestoJson , if the destination is kept as flowfileattribute, the flowfile dont get this attribute or if it is kept as flowfile content, original flowfile content is replaced...

My requirement is to append this single attribute to the existing flowfile content.

 

Any help or suggestion is greatly appreciated.

2 ACCEPTED SOLUTIONS

avatar
Super Guru

Hi,

What is the format of the original flowfile content after PutDatabaseRecord\PUTSQL? if its something like xml or json you can use queryrecord processor or jolt transformation to enrich the content from the attributes.

View solution in original post

avatar
Expert Contributor

Thank You @MattWho @SAMSAL  for your wonderful suggestions.

I achieved solution using JolttransformJSON processor, where i used below jolt specification

 

[{
"operation": "default",
"spec": {
"*": {
"error": "${putdatabaserecord.error}"
}
}
}] 

 

Thanks again for your thought provoking answers.. 

View solution in original post

3 REPLIES 3

avatar
Super Guru

Hi,

What is the format of the original flowfile content after PutDatabaseRecord\PUTSQL? if its something like xml or json you can use queryrecord processor or jolt transformation to enrich the content from the attributes.

avatar
Master Mentor

@SandyClouds If you don't care about the specific formatting of the FlowFiles content, you could use the ReplaceText processor to append test to the end of the existing content.  I am assuming that you are manually investigating the failure later and will simply remove the appended putdatabaserecord.error text during the evaluation.

If you found that the provided solution(s) assisted you with your query, please take a moment to login and click Accept as Solution below each response that helped.

Thank you,

Matt



avatar
Expert Contributor

Thank You @MattWho @SAMSAL  for your wonderful suggestions.

I achieved solution using JolttransformJSON processor, where i used below jolt specification

 

[{
"operation": "default",
"spec": {
"*": {
"error": "${putdatabaserecord.error}"
}
}
}] 

 

Thanks again for your thought provoking answers..