My first stream

My first stream

This tutorial provides you with a step-by-step guide to create and run a simple stream. It provides an introduction to basic processes, including data collection, processing, and forwarding. 

The stream that you will build includes these functions:

  • A Count function that collects data. It is intended to collect or receive data for further processing. 

  • A Script function that you will configure to double the value of the data collected in JavaScript. It allows users to use custom code and operations to transform the input data. 

  • A Log function that will forward the processed data to the log section. 

Note!

All of your entries are automatically saved. There is no need to look for any Save buttons. 

Creating a stream

When you first log in, you are presented with the Sample Solution view. For this example, we can use the sample solution to create your very first stream.

my-first-stream-sample-solution.png
First time log in screen
  1. To add a stream to your solution, click Create Stream.

  2. Give your stream a name and click Create.

    my-first-stream-create-stream.png
    Create Stream dialog
  1. You are then taken to the Stream Editor where you can begin to build your stream.

my-first-stream-1.png
Stream Editor with the function list open

Add a Count function

Now we will proceed with adding the first function. The Count function will generate numerical values in increments of 1. These values will simulate data being collected.

  1. Click on Add new function and type in count to display the Count function from the functions library. You may also search for the function itself by scrolling through the Collectors list.

    my-first-stream-add-count.png
    Stream Editor with the Count function
  2. Click on the Count function and move your cursor and the function around the canvas until you have found a spot. Click again to place the Count function onto the canvas.

Note!

You may notice in the upper right corner, there is a red notification dot with a number in it. This is where any error’s stream is listed, and you can click on the notification icon to view a list of errors and expand on its description.

Error’s are expected during the stream design phase since the stream is incomplete.

my-first-stream-error.png
Error notification
  1. Double click on the Count function to open it.

  2. Configure the Count function by leaving the Max value at 10. Click Preview for a preview of the first 10 lines of data. You can choose to preview between Table, Tree, and Log.

    my-first-stream-count-configuration.png
    Configuration view for the Count function
  3. You have now configured Count so you can close it.

Adding the Script function

Now we will proceed with adding the second function. This function will contain a script that will manipulate the data from the Count function, in which case the numerical values received from the first function, will be doubled to simulate the data being processed.

  1. Click on Add new function and type in script to display the Script function from the functions library. You may also search for the function itself by scrolling through the Processors list.

  2. Click and drop the Script function onto the canvas.

  3. Link the Count function with the Script function by clicking and dragging your mouse cursor from the arrow icon for the Count function onto the leftmost arrow icon on the Script function

    my-first-stream-2.png
    Linking two functions
  4. Double click on the Script function to open it.

  5. Paste the following code into the Transform section:
    This script will get the data as a payload, and each value will be doubled. You can leave the Flush section empty.

const { value } = payload; await push({ value, doubled: value * 2 });
  1. Click Preview for a preview of how the function will handle the data.

    my-first-stream-script-preview.png
    Preview result for the Transform script
  2. You have now configured Script so you can close it.

Adding the Log function

The third finction will be added here. The final function of this tutorial will receive the transformed data from the Script function and forward it to the log.

  1. Click on Add new function and type in log to display the Log function from the functions library. You may also search for the function itself by scrolling through the Forwarders list.

  2. Click and drop the Log function onto the canvas.

  3. Link the Script function with the Log function by clicking and dragging your mouse cursor from the rightmost arrow icon for the Script function onto the leftmost arrow icon on the Log function

my-first-stream-3.png
Linking the Log function into the canvas
  1. You can double click on the Script function to open it, but there will be no need to update anything on the Log function.

  2. This completes your stream and there should be no error notification.

Running the stream

Now you may choose to run your stream and have the result be displayed on the log.

  1. You can run your stream in 3 ways:

    1. You can run the stream from the Stream Editor, by clicking Start.

      my-first-stream-run-by-steam-editor.png
    2. You can run it from your Streams view, by selecting your stream and clicking Start.

      my-first-stream-run-by-steam-view.png
    3. You can run it from your Streams view, by selecting Start from the Actions drop down menu.

      my-first-stream-run-by-dropdown.png
  2. When your stream has finished running, the status Complete is shown.

  3. To view the output of your stream in the log, select View Logs from the Stream Editor or Log from the Actions drop down menu.

    my-first-stream-log-results.png

You have now successfully created and run your first stream! This basic step-by-step tutorial has given an introduction to three of the base functions and some sample data transformations.

Throughout this tutorial various elements of the service have been explored, including the ability to click and drop functions onto the canvas, interacting with them, and previewing the results. All of this shows how just how easy is to get started with Usage Engine. Continue on with the other tutorials to see how powerful the platform can be. 

Note!

We suggest that you play around with other functions by using the Count function to generate example data. However, bear in mind that some additions and processes may require you to restart the stream if it's already running. Do that by pressing Stop and then Start once again.