Skip to main content

Introducing Mm FLaNK... An Apache Flink Stack for Rapid Streaming Development From Edge 2 AI

Introducing Mm FLaNK... 

An Apache Flink Stack for Rapid Streaming Development From Edge 2 AI


Stateless NiFi:

To show an example of using the Mm FLaNK stack we have an Apache NiFi flow that reads IoT data (JSON) and send it to Apache Kafka.   An Apache Flink streaming application running in YARN reads it, validates the data and send it to another Kafka topic.  We monitor and check the data with SMM.    The data from that second topic is read by Apache NiFi and pushed to Apache Kudu tables.

Mm FLaNK Stack (MXNet, MiNiFi, Flink, NiFi, Kafka, Kudu)

 First, we rapidly ingest, route, transform, convert, query and process data with Apache NiFi.   Once we have transformed it into a client, schema-validated known data type we can stream it to Kafka for additional processing.

Second, we read from that Kafka topic, iot, with a Java Apache Flink application.   We then filter out empty records and then push it to another Kafka topic, iot-result.
       public static class NotNullFilter implements FilterFunction<String> {                    @Override public boolean filter(String string) throws Exception {                  if ( string == null || string.isEmpty() || string.trim().length() <=0) {                return false;}           
        return true; } 
Properties properties = new Properties();
properties.setProperty("bootstrap.servers", "cloudera:9092");
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
FlinkKafkaConsumer<String> consumer = new FlinkKafkaConsumer<>("iot", new SimpleStringSchema(), properties);
DataStream<String> source = env.addSource(consumer).name("Flink IoT Kafka Source");
source.filter(new NotNullFilter());
source.addSink(new FlinkKafkaProducer<>("cloudera:9092", "iot-result",
new SimpleStringSchema())).name("Flink Kafka IoT Result Sink");

We compile our Java application with maven and build a big JAR that we will use the Flink Client to push to YARN on our CDH 6.3 cluster.

Once the Flink application is running we can see a lot of metrics, logs and information on our streaming service.  We can browse the logs via YARN UI and Flink UI.

From the Hadoop YARN UI, you can Link to this application's Flink Dashboard.

You can easily see logs from various components, your application, containers and various systems.

The Apache Flink Dashboard is a very rich easy to navigate to interface for all the information related to your running job.

You can see and add charts to view various metrics about sources, sinks and a large number of other interesting real-time attributes.

There is also an older view that is still available to show a less dynamic interface.

You can also dive down into individual task managers with their attributes.

Logs are easily accessible:

Another Apache NiFi flow reads from the iot-result topic and does additional processing, could do machine learning / deep learning and then stores to a data store such as Apache Kudu.   If you have attended any of the CDF Workshops, you will notice we could integrate machine learning via a LookupRecord processor calling CDSW Python Machine Learning application via REST.   Data read from Kafka is streaming in with helpful metadata into our provenance data stream including kafka offset, partition, topic and a unique id on the data.

Since we are using Apache Kafka 2.x for a lot of streams, we really need to see what is going on in there.   Fortunately Cloudera Streams Messaging Manager gives us full insight into everything.  We can browse brokers, topics, consumers and producers.   We can also setup alerts to notify someone via various methods (email, rest, etc...) if something happens such as consumer lag.   From the below screen we can see that these two consumers are lagging.   This is because I have stopped them so they cannot process the message in their respective topics.

I restart my consumers and quickly the lag is gone.   Flink and NiFi process Kafka topics quickly!

We can see a nice overview of my FLaNK application via this screen.   I see my current stats on the source and sink Kafka topics I am working with from NiFi and Flink.

I can also dive into a topic (if I have permissions) and see the content of the data.   There's also a link to the Schema Registry for this particular topic and the ability to view various types of Kafka data including Strings and Avro.   As you can see our payloads are JSON IoT data.

Once our NiFi Kafka Consumer has acquired the data we use our PutKudu processor to auto infer the schema of the JSON data and write to an existing Kudu table.  We can query the data via an interface such as Apache Hue.   We run a quick Apache Impala SQL query to get back data as it arrives.   Apache NiFi is inserting data as we stream it through Apache Kafka from our Apache Flink application.

That was easy!   Next up we will expand our Edge piece by utilizing MiNiFi deployed by Cloudera Edge Flow Manager as well as add our second M with Apache MXNet with my Apache MXNet NiFi processor as well as some Python GluonCV, GluonTS and more via Cloudera Data Science Workbench.  We will also use Stateless Apache NiFi 1.10 for some FaaS Kafka consuming and producing.

More FLaNK to come!

Upcoming:  GluonTS for Forecasting Time Series


Popular posts from this blog

Ingesting Drone Data From DJII Ryze Tello Drones Part 1 - Setup and Practice

Ingesting Drone Data From DJII Ryze Tello Drones Part 1 - Setup and Practice In Part 1, we will setup our drone, our communication environment, capture the data and do initial analysis. We will eventually grab live video stream for object detection, real-time flight control and real-time data ingest of photos, videos and sensor readings. We will have Apache NiFi react to live situations facing the drone and have it issue flight commands via UDP. In this initial section, we will control the drone with Python which can be triggered by NiFi. Apache NiFi will ingest log data that is stored as CSV files on a NiFi node connected to the drone's WiFi. This will eventually move to a dedicated embedded device running MiniFi. This is a small personal drone with less than 13 minutes of flight time per battery. This is not a commercial drone, but gives you an idea of the what you can do with drones. Drone Live Communications for Sensor Readings and Drone Control You must connect t

NiFi on Cloudera Data Platform Upgrade - April 2021

CFM 2.1.1 on CDP 7.1.6 There is a new Cloudera release of Apache NiFi now with SAML support. Apache NiFi Apache NiFi Registry See:   For changes: Get your download on: To start researching for the future, take a look at some of the technical preview features around Easy Rules engine and handlers. Make sure you use the latest possible JDK 8 as there are some bugs out there.   Use a recent v

Using Apache NiFi in OpenShift and Anywhere Else to Act as Your Global Integration Gateway

Using Apache NiFi in OpenShift and Anywhere Else to Act as Your Global Integration Gateway What does it look like? Where Can I Run This Magic Engine: Private Cloud, Public Cloud, Hybrid Cloud, VM, Bare Metal, Single Node, Laptop, Raspberry Pi or anywhere you have a 1GB of RAM and some CPU is a good place to run a powerful graphical integration and dataflow engine.   You can also run MiNiFi C++ or Java agents if you want it even smaller. Sounds Too Powerful and Expensive: Apache NiFi is Open Source and can be run freely anywhere. For What Use Cases: Microservices, Images, Deep Learning and Machine Learning Models, Structured Data, Unstructured Data, NLP, Sentiment Analysis, Semistructured Data, Hive, Hadoop, MongoDB, ElasticSearch, SOLR, ETL/ELT, MySQL CDC, MySQL Insert/Update/Delete/Query, Hosting Unlimited REST Services, Interactive with Websockets, Ingesting Any REST API, Natively Converting JSON/XML/CSV/TSV/Logs/Avro/Parquet, Excel, PDF, Word Documents, Syslog, Kafka, JMS, MQTT, TCP