Tutorial: Design and create a streams flow in the canvas

Learning objective

You learn how to design and create a simple streams flow in the canvas. We supply the Data Historian sample data.

This tutorial is an introduction to the canvas and how you can use it to customize a streams flow to suit your analytic needs. Other tutorials do an in-depth analysis into specific operators that are available in the canvas.

It takes approximately 15 minutes to finish.

Overview

We start with an empty canvas and introduce you to the various features.

In the canvas, you select operators - Sample Data and Debug - and connect them to design a simple flow of data.

The Sample Data operator uses sample data that is taken from five weather stations. The data includes weather station ID, time zone, date in Universal Coordinated Time (UTC) format, latitude, longitude, temperature, barometric pressure, humidity, indoor temperature, and rainfall today.

The Debug operator displays the sample data.

Preview

   

To complete this tutorial, follow these steps:

  1. Prerequisites
  2. Create an empty streams flow
  3. Explore canvas
  4. Try out other features in the canvas
  5. Run the new streams flow
  6. Learn more

Now it’s your turn - try out the following tutorial steps in your own environment.

Prerequisites

You must have a Streams service up and running.

Create an empty streams flow

To get acquainted with the canvas, perform the following steps:

Blank tab

  1. In the Blank tab of the New Streams Flow window, perform the following steps:
    • In the Name field, type in a name for the streams flow. Use Simple Stream Flow in Canvas.
    • In the Description field, type in some text to describe the new streams flow. Type in This is a simple streams flow to get acquainted with the canvas. It uses Data Historian sample data.
    • In the Streaming Analytics service list, the Streams service that is associated with the project is already selected. An example might be

    Blank tab

    • In the Select Example area, click the Manually box, and then click Create. The canvas opens.

   

Explore the canvas

The canvas has several distinctive features to help you to design a streams flow that better suits your analytic needs.

The following screen capture shows the canvas of a new streams flow.

Entire screen

   

Taskbar

At the top of the canvas, note the taskbar with various icons.

Taskbar

Hover your mouse pointer over any of the icons to see what each one does. An icon that cannot be used is disabled.

We’ll try out the icons after we create a streams flow.

   

Canvas palette

A palette with operators is on the left side of the canvas. The operators are grouped by type.

The groups are Sources, Targets, Processing and Analytics, and Alerts. To list the operators in each group, click the arrow next to the group name.

   

Canvas area

The center of the canvas area is where you design the streams flow and make any changes or corrections to it.

In a new canvas, we list some initial tips to get you started. You can close that graphic if you want by clicking X in the upper-right corner of the graphic.

Design a streams flow

  1. In the canvas palette, click Sources to open the Sources group. Drag the Sample Data operator from the pane and drop it in the canvas area.

  2. In the canvas palette, click Targets to open the Target group. Drag the Debug operator from the pane and drop it in the canvas area.

  3. Link the two operators together by dragging your mouse cursor from the output port of the Sample Data operator to the input port of the Debug operator.

Linking operators

All actions are verified in the canvas. If an error occurs, you are notified immediately so that you can correct the problem.

Looks like we have some errors, so let’s fix them now.

Correct the streams flow

  1. Click Notifications icon to see the specific error message and the operator type. Notice that the operators also have a red error icon Error icon. This icon is helpful because you might have several operators of the same type, but only one of them is problematic. Which one must we fix?

    Error messages in canvas

  2. Click the first error message to open the Properties pane of the Sample Data operator.

    First error messages in canvas

    An error icon Error icon is next to the field that is problematic. In our case, we need to select a topic.

  3. Click Select topic, and then select Data Historian. We selected the Data Historian sample data for the streams flow.

  4. In the Edit Schema window, click Close.

    Notice that the Notification messages were immediately updated. One error remains in the Debug operator.

  5. In the File Creation policy field, let’s select Number of events. In the Number of events field, let’s type in 100.

    The error icons are removed as each error is corrected.

   

Try out other icons in the taskbar

Before we run the streams flow, let’s look at some helpful features in the taskbar.

We created a simple streams flow that uses Data Historian sample data. We corrected all errors, checked the schema of the sample data to be sure it can stream the information that we need, and we set up our COS storage to create a new file with a unique name after every 100 streamed events.

   

Run the new streams flow

We’re ready to run our streams flow.

Your new streams flow is automatically shown in the Metrics page. The Status indicator shows that it is in a “Stopped” state.

The Status indicator changes to “Starting” and then to “Running”.

Notice that until the status is “Running”, the streams flow uses arrows to connect operators.

When the status is “Running”, you can see the data as it flows between operators. Put your mouse pointer over a data flow to get real-time metrics. Click the data flow to see the events flow to the next operator.

   

Summary

You just created a streams flow and used the Data Historian sample data. You started the streams flow in the Metrics page and saw the data flow between operators.

   

Learn more

Check out our other tutorials for streams flow.