Support Questions

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

Can we stop a specific Nifi processor (i.e consumeJMS) from the background Linux server?

avatar

We're looking to automate the shutdown/restart the processor instead of manually stopping through Nifi UI. We don't want to bring down everything through nifi.sh stop, instead looking to bring down a specific processor.

1 ACCEPTED SOLUTION

avatar
Super Mentor

@Dan Alan

-

Anything you can do via the UI, you should be able to accomplish using NiFi's rest-api.

https://nifi.apache.org/docs/nifi-docs/rest-api/index.html

-

The easiest way to learn what specific rest-api call you need to make to accomplish a task is through using the developer tools in your browser. Perform the action via the UI and then via developer tolls save off that action as a curl command.

-

for example (assume secured NiFi using a login provider):

obtain authentication token:

token=$(curl -k 'https://<nifi-node>:9091/nifi-api/access/token'  --data 'username=<username>&password=<password>’)

-

Then use that token to stop a specific processor by processor UUID:

curl 'https://<nifi-node>:9091/nifi-api/processors/aab961c3-6bcd-18e7-0000-00001d74d4ea' -X PUT -H "Authorization: Bearer $token" -H 'Content-Type: application/json' -H 'Accept: application/json, text/javascript, */*; q=0.01'  --data-binary '{"revision":{"clientId":"248a328f-a133-1cd0-18c1-8997e36ef898","version":1},"component":{"id":"aab961c3-6bcd-18e7-0000-00001d74d4ea","state":"STOPPED"}}' --compressed --insecure

-

Thank you,

Matt

-

When an "Answer" addresses/solves your question, please select "Accept" beneath that answer. This encourages user participation in this forum.

View solution in original post

8 REPLIES 8

avatar
Super Mentor

@Dan Alan

-

Anything you can do via the UI, you should be able to accomplish using NiFi's rest-api.

https://nifi.apache.org/docs/nifi-docs/rest-api/index.html

-

The easiest way to learn what specific rest-api call you need to make to accomplish a task is through using the developer tools in your browser. Perform the action via the UI and then via developer tolls save off that action as a curl command.

-

for example (assume secured NiFi using a login provider):

obtain authentication token:

token=$(curl -k 'https://<nifi-node>:9091/nifi-api/access/token'  --data 'username=<username>&password=<password>’)

-

Then use that token to stop a specific processor by processor UUID:

curl 'https://<nifi-node>:9091/nifi-api/processors/aab961c3-6bcd-18e7-0000-00001d74d4ea' -X PUT -H "Authorization: Bearer $token" -H 'Content-Type: application/json' -H 'Accept: application/json, text/javascript, */*; q=0.01'  --data-binary '{"revision":{"clientId":"248a328f-a133-1cd0-18c1-8997e36ef898","version":1},"component":{"id":"aab961c3-6bcd-18e7-0000-00001d74d4ea","state":"STOPPED"}}' --compressed --insecure

-

Thank you,

Matt

-

When an "Answer" addresses/solves your question, please select "Accept" beneath that answer. This encourages user participation in this forum.

avatar

Thank you Matt.

avatar

Hi @Matt Clarke

I'm able to stop/start a processor that are under HTTP without any issues. However getting an error with secured nifis (i.e https UI.)

I tried to get the token using below command and it's successful.

token=$(curl 'https://server:port/nifi-api/access/token' --data 'username=userid&password=xxxx')

But when I tried to get the processors status using $token and --cacert option, it's giving me an error. (/tmp/G2_Root_CA.cer is the root CA certificate)

$curl 'https://<server_name>:8443/nifi-api/processors/228b783f-0164-1000-f665-9e6e093d6085' -H "Authorization: Bearer $token" --cacert /tmp/G2_Root_CA.cer

curl: (60) Peer's Certificate issuer is not recognized. More details here: http://curl.haxx.se/docs/sslcerts.html curl performs SSL certificate verification by default, using a "bundle" of Certificate Authority (CA) public keys (CA certs). If the default bundle file isn't adequate, you can specify an alternate file using the --cacert option.

If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL). If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option.

$

avatar
Super Mentor

@Dan Alan

Rather then using --cacerts, trying using the -k option in your curl command. This disables Cleint verificaton of teh server's presented cert.

avatar

Perfect. It works now. Thanks again Matt.

avatar

Hi @Dan Alan!
Did you check the NIFI Api Rest?
https://nifi.apache.org/docs/nifi-docs/rest-api/index.html
Hope this helps

avatar

Thank you Vinicius.

avatar

Hi @Matt Clarke

Is there anyway to use the encrypted password or keytab instead of passing the plain password while obtaining the token?

token=$(curl 'https://server:port/nifi-api/access/token' --data 'username=userid&password=xxxx')