Using Python with the NiFi REST API
Using Python and the NiFi REST API, you could write your own monitoring tools, or wire up a dashboard. The NiFi REST API documentation is located at https://nifi.apache.org/docs/nifi-docs/rest-api/index.html. You can see all of the different endpoints by type and some information about each of them. This section will highlight some of the endpoints that you have covered in this chapter but by using the GUI.
The first thing we can look at are the system diagnostics. System diagnostics will show you your resource usage. You can see heap size, threads, repository usage, and several other metrics. To call the endpoint with requests, you can use the following code:
r=requests.get('http://localhost:9300/nifi-api/system-diagnostics') data=r.json() data['systemDiagnostics']['aggregateSnapshot']['maxHeap'] #'512 MB' data['systemDiagnostics']['aggregateSnapshot']['totalThreads...