Support Questions

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

How to access Nifi Rest-API in all Nifi nodes?

avatar
Contributor

I want to get node details from nifi rest-api in primary node. For this, I can use "192.xxx.xx.xx:8080" address. But, what happens if primary node is down? I can not access the rest api using above address, after new primary node will be elected. Can I use "localhost:8080" address for this purpose for all nifi nodes? Does this work?

5 REPLIES 5

avatar
Super Mentor
@Adam J

-

You can execute your rest-api calls against any node in the NIFi cluster. It does not have to be the primary node,

-

Thank you,

Matt

avatar
Contributor

@Matt Clarke firstly, thank you for your response Matt.

Yes, I know that. But the processor that does works only works on the primary node. It sends get request to "192.xxx.xx.50:8080". When new primary node is elected, this address will be changed(for example "192.xxx.xx.68:8080"). In new primary node, processor will not be able to send request to nifi api. Because existing address("192.xxx.xx.50:8080") represents the node that was down. For this; Can I send request if I use "localhost:8080" address.

avatar
Super Mentor

@Adam J

-

Now i am following. You have a GetHTTP or invokeHTTP processor running on this NiFi cluster in primary node only mode which is configured with a url that is for one of the nodes within this same cluster. So this is not directly related to primary node at all. Your issue is what to do if the target node URL being used happens to become unavailable (down node). In that case you certainly could use localhost:8080.

-

Now if you decide at some point to secure your NiFi, localhost is not going to work.

Another option may be to consider placing a Load-balancer in front of your NiFi to handle a down node scenario. That way target URL could be that of the LB which would be able to handle sending request to any one of the still up and running servers.

-

Thanks,

Matt

-

If you found this answer addressed your question, please take a moment to login in and click the "ACCEPT" link.

avatar
Contributor

@Matt Clarke

Does "secure Nifi" mean secure nifi cluster?

Each nifi instance have nifi.properties file. I will read this file, and prepare url after receive node ip and port number from this file. Then I will send this url to invoke http, and get cluster summary from rest-api. If pimary node is down, and new primary node will be elected, this solution will be working. Is it correct?

avatar
Super Mentor

@Adam J

By secure, I mean when NiFi has been configured to run over https.
-

In the invokeHTTP processor, why not just use NiFi Expression Language (EL) to build your remoteURL.

for example:

http://${hostname(true)}:9090/.

This would allow which ever node is primary node to fetch its hostname and use it in the URL when the invokeHTTP executes.