Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

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

Solved Go to solution
Highlighted

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

New Contributor

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

Accepted Solutions

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

Master Guru

@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.

8 REPLIES 8

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

Master Guru

@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.

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

New Contributor

Thank you Matt.

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

New Contributor

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.

$

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

Master Guru

@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.

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

New Contributor

Perfect. It works now. Thanks again Matt.

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

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

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

New Contributor

Thank you Vinicius.

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

New Contributor

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')



Don't have an account?
Coming from Hortonworks? Activate your account here