Created 06-18-2018 03:19 PM
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.
Created 06-18-2018 03:47 PM
-
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.
Created 06-18-2018 03:47 PM
-
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.
Created 06-18-2018 08:06 PM
Thank you Matt.
Created 06-21-2018 01:51 PM
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.
$
Created 06-21-2018 02:12 PM
Rather then using --cacerts, trying using the -k option in your curl command. This disables Cleint verificaton of teh server's presented cert.
Created 06-21-2018 02:27 PM
Perfect. It works now. Thanks again Matt.
Created 06-18-2018 04:01 PM
Hi @Dan Alan!
Did you check the NIFI Api Rest?
https://nifi.apache.org/docs/nifi-docs/rest-api/index.html
Hope this helps
Created 06-18-2018 08:07 PM
Thank you Vinicius.
Created 10-25-2018 03:11 PM
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')