Community Articles

Find and share helpful community-sourced technical articles.
Announcements
Celebrating as our community reaches 100,000 members! Thank you!
avatar

Introduction

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

  1. To test this, Make sure HDF-2.x version of NiFi is up an running.
  2. You Already have a MonitorDiskUsage/MonitorMemory Reporting task created and configured, set a lower threshold to force generate the alert while testing.

15111-10.png

3. Make a note of the Reporting Task uuid to be monitored:

15113-0.png

Creating a Flow to Monitor Reporting Task.

  1. Drop a GenerateFlowFile to execute every 5mins, with 1 byte file to trigger the flow.

15114-1.png

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>

15116-2.png

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}

15117-3.png

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:

15118-4.png

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

15119-5.png

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

15120-6.png

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.

15121-7.png

13. Add a connection from EvaluateJsonPath processor to ControlRate processor with FlowFile Expiration as 30 sec. Auto-terminate other relations.

15122-8.png

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}

15123-9.png

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:

15128-final-flow.png

Staring the flow, Reporting task and testing it

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.

15124-11.png

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:15125-12.png

3. This concludes the tutorial for Monitoring your Reporting Tasks with NiFi itself.

4. Too lazy to create the flow???.. Download my template here

References

NiFi REST API

NiFI Expression Language

Thanks,

Jobin George


3.png
5,498 Views
Comments
avatar
Expert Contributor

@Jobin George can we monitor multiple disk usages from single reporting task(MonitorDiskUsage).

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