Over a million developers have joined DZone.

Simple Apache NiFi Operations Dashboard (Part 2): Spring Boot

DZone's Guide to

Simple Apache NiFi Operations Dashboard (Part 2): Spring Boot

In this post, we continue with uilding a dashboard with the open source big data platform Apache NiFi, using Spring Boot 2.0.6.

· Big Data Zone ·
Free Resource

The open source HPCC Systems platform is a proven, easy to use solution for managing data at scale. Visit our Easy Guide to learn more about this completely free platform, test drive some code in the online Playground, and get started today.

If you missed Part 1, you can check it out here.

Simple Apache NiFi Operations Dashboard - Part 2

To access data to display in our dashboard we will use some Spring Boot 2.06 Java 8 microservices to call Apache Hive 3.1.0 tables in HDP 3.0 on Hadoop 3.1.

We will have our website hosted and make REST Calls to Apache NiFi, our microservices, YARN, and other APIs.

As you can see we can easily incorporate data from HDP 3 — Apache Hive 3.1.0 in Spring Boot Java applications with not much trouble. You can see the Maven build script (all code is in GitHub).

Our motivation is to put all this data somewhere and show it on a dashboard that can use REST APIs for data access and updates. We may choose to use Apache NiFi for all REST APIs or we can do some in Apache NiFi. We are still exploring. We can also decide to change the backend to HBase 2.0, Phoenix, Druid or a combination of these. We will see.

Spring Boot 2.0.6 Loading

JSON Output

Spring Boot Microservices and UI


To start, I have a simple web page that calls one of the REST APIs.

The microservice can be run off of YARN 3.1, Kubernetes, CloudFoundry, OpenShift, or any machine that can run a simple Java 8 jar.

We can have this HTML as part of a larger dashboard or hosted anywhere.

For parsing the monitoring data we have some schemas for metrics, status, and bulletins.

Now that I'm monitoring data is in Apache Hive, I can query it with ease in Apache Zeppelin (or any JDBC/ODBC tool).

Apache Zeppelin Screens

We have a lot of reporting tasks for Monitoring NiFi.

We read from NiFi and send to NiFi, would be nice to have a dedicated reporting cluster.

Just Show Me Bulletins for MonitorMemory (You Can See That in Reporting Tasks)

NiFi Query To Limit Which Bulletins We Are Storing In Hive (For Now Just grab Errors)

Spring Boot Code for REST APIs

Metrics REST API Results

Bulletin REST API Results

Metrics Home Page

Run the Microservice

java -Xms512m -Xmx2048m -Dhdp.version=3.0.0 -Djava.net.preferIPv4Stack=true -jar target/operations-0.0.1-SNAPSHOT.jar

Maven POM

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<description>Apache Hive Operations Spring Boot</description>




With some help from the Internet, we have some simple JavaScript to read the Spring Boot /metrics REST API and fill some values:

HTML and JavaScript (see src/main/resources/static/index.html)

<div id="output" name="output"  class="white-frame">
  <ul id="metrics"></ul>  
<script language="javascript">var myList = document.querySelector('ul');var myRequest = new Request('./metrics/');fetch(myRequest).then(function(response) { return response.json(); }).then(function(data) {for (var i = 0; i < data.length; i++) {var listItem = document.createElement('li');listItem.innerHTML = '<strong>Timestamp' + data[i].timestamp + '</strong>Flow Files Received: ' +data[i].flowfilesreceivedlast5minutes + ' JVM Heap Usage:' + data[i].jvmheap_usage +' Threads Waiting:' + data[i].jvmthread_statestimed_waiting +' Thread Count: ' + data[i].jvmthread_count +' Total Task Duration: ' + data[i].totaltaskdurationnanoseconds +' Bytes Read Last 5 min: ' + data[i].bytesreadlast5minutes +' Flow Files Queued: ' + data[i].flowfilesqueued +' Bytes Queued: ' + data[i].bytesqueued;myList.appendChild(listItem);}});</script>

Example API Calls to Spring Boot

REST API for NiFi of Interest

Managing data at scale doesn’t have to be hard. Find out how the completely free, open source HPCC Systems platform makes it easier to update, easier to program, easier to integrate data, and easier to manage clusters. Download and get started today.

spring boot ,microservices ,rest api ,tutorial ,big data

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}