Support Questions

Find answers, ask questions, and share your expertise

Fetch a value from diffrent field in NIFI

avatar
Explorer

"result" : "SUCCESS",
"correlationID" : "X8058296",
"generationTimestamp" : "1354",
"meHostName" : "rc01;rik2jc",
"nccVersion" : "SPS__R1",

 
This is my input in my nifi and i want to do changes in meHostName means i want mehostName to have 1st value like in this case rc01 and after that creating 1 more field with name devicename having second value means rik2jc
 
I acheived the 1st part means i configured in UpdateRecord processor 
Ashi_0-1727175059348.png

 

for meHostName and it is printing 1st value means it is running fine ,now please help me in acheiving devicename to have 2nd value of meHostName which is rik2jc . i have tried split(/meHostName, ';')[1] but its not working

2 REPLIES 2

avatar
Master Mentor

@Ashi 
Potential option:

What record Reader and record writers are you using in your UpdateRecord processor?
What schema are you using for your records?

In order to add a new field, that new field needs to be defined in the records schema. 
In your case the schema must contain the field "devicename".
Prior to UpdateRecord, you could use perhaps an ExtractText processor to extract the "rc01;rik2jc" value from the meHostName field to a flowfile.attribute.

Then will you be able to use UdpateRecord to apply a value to that new record field in the record writer.

Property: /devicename
value: ${flowfile.attribute:substringAfter(';')}

Please help our community thrive. If you found any of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "Accept as Solution" on one or more of them that helped.

Thank you,
Matt

 

avatar
Explorer

Record reader -JsonTreeReader

record writer - JsonRecordSetWriter this i am using in my update record and for reference this is my flow looks like

Ashi_0-1727241964250.png