Support Questions

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

Importing JSON Export into top-level NiFi Flow

avatar
Contributor

If I took an export of the main flow (NiFi Flow) from a server via the Export to JSON option on the right-click menu, how can I import that into a new server as the top-level flow?  I know I can create new process groups with the export.  But I want to restore the controller services and parameter contexts.

 

I know I could import into a process group, and then move things out again.  But, that would also require re-creating all the controller services back at the top level...which would create new UUIDs...and require updating 400-500 processors manually to map them to the new controller services.

 

I've seen various posts about using NiFi registry and the toolkit.  But even when I look at that, I don't see how that works with the top-level group.  If there is some way to handle this that will require a minimum of reconfiguration on services, processors or process groups after the import, it would be appreciated.

1 REPLY 1

avatar
Contributor

I did end up finding a hacky way to do this.  But something using APIs or the registry would be preferred.  It was a multi-step process:

 

  1. Bring up a new NiFi server.
  2. Import the process group from the JSON file into the canvas.
  3. Stop the server and copy out flow.xml.gz
  4. Rebuild the server to get an empty flow.xml.gz, then stop it again.
  5. Unzip and edit both files.
    1. Copy the contents of the only <processorGroup> tag to replace the contents of the <rootGroup>
    2. Update the coordinates in the new root group to 0.0/0.0.
    3. Copy the <parameterContexts> over <parameterContexts/> in the new file.
  6. re-zip the updated file and start up the server.
  7. Re-enable broken controller services.

Not pretty, but it worked to restore a server from a JSON export copy I had made with minimal fixes in NiFi itself.  If there is no easier way, I hope this helps someone else.