Support Questions

Find answers, ask questions, and share your expertise

How can I save my NiFi flows into XML?

avatar
Rising Star

I need to save my NiFi flow into an XML file.

We can import the xml file into template, but I also need to save NiFi flows as an XML file

1 ACCEPTED SOLUTION

avatar
Guru

If you select a section of your flow, you can turn that into a template with the New Template button

6011-new-templatetiff.png

You can then use the template manager:

6012-template-managertiff.png

This lists all your templates and allows you to download them as an XML file.

6014-save-templatetiff.png

If you want to save the entire flow you have in the system, you can also find that in nifi/conf/flow.xml.gz on your nifi box. This is not a template, but would be able to drop into a clean NiFi instance.

View solution in original post

12 REPLIES 12

avatar
Master Mentor
@sagar gaikwad

Difference between templating the entire NiFi canvas and copying the actual flow.xml.* files. When you generate a template it is saved as and xml and contains all the configuration from the canvas with the EXCEPTION of sensitive property values (passwords). Sensitive processor properties are encrypted using the sensitive props key configured in the nifi.properties file. So by removing these values when a template is created the templates to be loaded into any other NiFi successfully. If you capture the flow.xml.* files directly from NiFi, you will also need to save/reserve the value set for the sensitive props key in order to use them on another system. The above is true no matter which version of NiFi you are using.

NiFi 0.x /HDF 1.x versions:

With these versions of NiFi you have a NiFi Cluster Manager (NCM) and NiFi nodes.

The Nodes all have identical flow.xml.gz files and an identical list of templates inside the /templates directory.

The NCM has a flow.tar file. This file is not the same as what is on the nodes. The flow.tar consists of numerous files important to the NCM only. (NCM specific controller services, primary node designator, etc..) The flow.tar also includes a flow.xml file. It is from this flow.xml file on the NCM that the flow.xml.gz and templates inside the /templates dir on the nodes are derived from.

You can build a new cluster if you have the flow.tar file as it contains everything new nodes need plus what ta new NCM needs. The flow.tar cannot be used on a standalone install of NiFi nor can it be used by the nodes directly themselves. It is intended for an NCM only.

The flow.xml.gz file from any of the nodes can be used to stand-up a standalone NiFi instance.

You may choose to keep a backup of both.

NiFi 1.x /HDF 2.x versions:

These versions of NiFi have eliminated the need for a NCM (zero-master clustering). As a result every instance of Nifi is a node and they all have identical flow.xml.gz files. These flow.xml.gz files do not contain the exact same content as the nodes from 0.x versions of NiFi. The templates have all been moved into the flow.xml.gz file and there is no longer a need for a separate /templates dir.

With this version you can keep a backup or flow.xml.gz from any node. The flow.xml.gz file can be used to buidl another cluster or a standalone NiFi instance.

Thanks,

Matt

avatar
Master Mentor

Side note: You can install a NiFi 1.x or HDF 2.x and use the flow.xml.gz file from an older 0.5.x+ or HDF 1.1+ version of NiFi. The newer version of NiFi will convert it to the new format.

avatar
Explorer

If I create a new template, it is creating a flow.xml.gz and working fine. However If I replace the flow.xml.gz with old flow.xml.gz (one backup taken earlier in same cluster node HDF2.X) nifi UI is not coming after login and giving error as "com.sun.jersey.api.client.ClientHandlerException: java.net.SocketTimeoutException: Read timed out".

Have tried with all parameter tuning as described by "Matt Clarke" in some other post but no results.

Again If I move old file and replace with new flow.xml.gz then nifi is working fine.

Please let me know if anyone faces such issues and probable reason and working around.

Thanks,

Suman