Created on 05-05-2017 07:33 PM - edited 08-17-2019 01:08 PM
Recently I was asked how to Monitor and alert while MonitorDiskUsage or MonitorMemory Reporting Task WARNINGS are generated when it exceeds a predefined threshold, I am trying to capture the steps to implement the same.
Prerequisites
3. Make a note of the Reporting Task uuid to be monitored:
Creating a Flow to Monitor Reporting Task.
2. Drop an UpdateAttribute processor to the canvas with below configuration:
NIFI_HOST : <Your NiFi FQDN> NIFI_PORT : <Your NiFi http port> REPORTING-TASK-UUID : <Your MonitorDiskUsage or MonitorMemory controller service uuid>
3. Connect Success relationship of GenerateFlowFile to UpdateAttribute.
4. Drop a InvokeHTTP processor to the canvas, and configure it as below:
HTTP Method : GET Remote URL : http://${NIFI_HOST}:${NIFI_PORT}/nifi-api/reporting-tasks/${REPORTING-TASK-UUID}
5. Connect Success relation of UpdateAttribute to InvokeHTTP and auto terminate all relationships of InvokeHTTP processor but Response relationship.
6. Drop a EvaluateJsonPath processor to the canvas with below configuration:
7. Auto terminate All relationship of EvaluateJsonPath processor except Matched relationship and connect InvokeHTTP processor’s Response relation to it.
8. Drop a SplitJson processor to canvas with below Configurtaion. [The reason for splitting json is because the REST call to reporting task gives duplicate json array in the result, which contains details we need.]
9. Connect Matched relationship of EvaluateJsonPath to SplitJson processor.
10. Drop another EvaluateJsonPath processor to the canvas with below configuration:
LEVEL : $.bulletin.level MESSAGE : $.bulletin.message SOURCE-NAME : $.bulletin.sourceName TIMESTAMP : $.bulletin.timestamp
11. Add a connection with split relationship from SplitJson to second EvaluateJsonPath processor. Auto-terminate other relationships.
12. Add a ControlRate processor so that only one alert is sent for multiple json arrays with below configuration which passes only 1 flowfile per minute.
13. Add a connection from EvaluateJsonPath processor to ControlRate processor with FlowFile Expiration as 30 sec. Auto-terminate other relations.
14. Finally Drop an PutEmail processor to canvas with below configuration to sent your alerts, update with your SMTP details
SMTP Hostname : west.xxxx.yourServer.net SMTP Port : 587 SMTP Username : jgeorge@hortonworks.com SMTP Password : Its_myPassw0rd_updateY0urs SMTP TLS : true From : jgeorge@hortonworks.com To : jgeorge@hortonworks.com Subject : ${SOURCE-NAME} ALERT
and message content should look something like below to grab all the values:
Message : ${MESSAGE} LEVEL : ${LEVEL} TIMESTAMP : ${TIMESTAMP} SOURCE-NAME : ${SOURCE-NAME}
15. Auto terminate all relationships of PutEmail processor and connect Success relationship of ControlRate processor to it.
16. Now you have your flow ready and can start it to monitor and sent Email Alert for UI Notification thrown by NiFi when Disk or Memory utilization exceeds given threshold. The Flow Would Look like below:
1. Now lets start the MonitorDiskUsage Reporting task to generate an Alert to test it with below configuration with a lower threshold to force generate the alert. I am monitoring disk on my mac and it’s disk is more than 50% utilized, so I will get this WARNING in the NiFi UI.
2. As soon as this Warning show up and the flow created is running you will get alert in your inbox stating the same, similar as below:
3. This concludes the tutorial for Monitoring your Reporting Tasks with NiFi itself.
4. Too lazy to create the flow???.. Download my template here
Thanks,
Jobin George
Created on 05-08-2017 03:14 PM
@Jobin George can we monitor multiple disk usages from single reporting task(MonitorDiskUsage).
Created on 05-09-2017 06:39 AM
@Bharadwaj Bhimavarapu Not as of today. you need multiple MonitorDiskUsage tasks to do so. But I already did brought this up to product team and hopefully soon we may have that feature.