Support Questions

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

Manually change connection id apache NiFi

avatar
Explorer

Hi everyone.

How can i change, if possible, the ID of a connection in Apache NiFi?

from: 9e16eefa-018c-1000-663d-ec184ba2fc6c
to: a0077eefa-023c-1000-423d-ef184ba2fc6c (example)

I think it's not possible and certainly it's not recommended, but it's a client request. They have an external software that identify the connection by its ID. They've deleted the connection and recreated it, so the ID has changed, and now the external software cannot read the status of this connection. We also cannot change de external software.

1 ACCEPTED SOLUTION

avatar
Expert Contributor
hide-solution

This problem has been solved!

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

Register/Login
3 REPLIES 3

avatar
Expert Contributor
hide-solution

This problem has been solved!

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

Register/Login

avatar
Explorer

Thank you Raghuy! Solved.

avatar
Super Mentor

@galt @RAGHUY 

Let me add some correction/clarity to the accepted solution.

Export and Modify Flow Configuration: Export the NiFi flow configuration, typically in XML format. This can be done via the NiFi UI or by utilizing NiFi's REST API. Then, manually adjust the XML to change the ID of the connection to the desired value.


It is not clear here  what is being done.  The only way to export a flow configuration from NiFi in XML format is via generating a NiFi template (deprecated and removed in Apache NIFi 2.x versions).   Even if you were to generate a template and export is via NiFi UI or NiFi's rest-api, modifying it will not change what is on the canvas.  If you were to modify the connection component UUID in all places in the template.  Upon upload of that template back in to NiFI, you would need to drop the template on the the canvas which would result in every component in that template getting a new UUID.  So this does not work.  In newer version of NiFi 1.18+ NiFi supports newer flow definitions which are in json format.  but same issue persists here when using flow definitions in this manor.

In a scenario like the one described in this post where user removed a connection by mistake and then re-created it, the best option is to restore/revert the previous flow. Whenever a change is made to the canvas, NIFi auto archives the current flow.xml.gz (legacy) and flow.json.gz (current) file in to an archive sub-directory and generates a new flow.xml.gz/flow.json.gz file.   Best and safest approach approach is to shutdown all nodes in your NiFi cluster. Navigate to the NiFi conf directory and swap current flow.xml.gz/flow.json.gz files with the archived flow.xml.gz/flow.json.gz files still containing the connection with original needed ID.

When above is not possible (maybe change went unnoticed for to long and all archive version have new connection UUID), you need to manually modify the flow.xml.gz/flow.json.gz files.  Shutdown all your NiFi nodes to avoid any changes being made on canvas while performing following steps.  
Option 1:

  1. Make backup of current flow.xml.gz and flow.json.gz
  2. Search each file for original UUID to make sure it does not exist.
  3. On one node manually modify the flow.xml.gz and flow.json.gz files by locating the current bad UUID and replacing it with the original needed UUID.  
  4. Copy the modified flow.xml.gz and flow.json.gz files to all nodes in the cluster replacing original files. this is possible since all nodes run same version of flow.

Option 2:

  1. same as option 1
  2. same as option 1
  3. same as option 1
  4. Start NiFi only on the node where you modified the flow.xml.gz and flow.json.gz files.
  5. On all other nodes still stopped, remove or rename the flow.xml.gz and flow.json.gz files. 
  6. Start all the remaining nodes. since they do not have a flow.xml.gz or flow.json.gs to load, they will inherit the flow from the cluster as they join the cluster.

NOTE:  The flow.xml.gz was replaced by the newer flow.json.gz format starting with Apache NiFi 1.16.  When NiFi is 1.16 or newer is started with and only has a flow.xml.gz file, it will load from flow.xml.gz and then generate the new flow.json.gz format.  Apache NiFi 1.16+ will load only from the flow.json.gz on startup when that file exists, but will still write out both the flow.xml.gz and flow.json.gz formats anytime a change is made to the canvas.   With Apache NiFi 2.x+ version the flow.xml.gz format will go away.

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