Bosch IoT Insights

Configuring a pipeline to process data

In Bosch IoT Insights, you can process data according to your own needs using a pipeline. In this tutorial, we will show you how to configure a basic pipeline with a custom step.

This tutorial is based on the example Pipelines: Configuring the custom step. We will use the provided Python code example to configure the custom step.

For more information on data processing and the configuration of pipelines, refer to the following chapters:

Prerequisites

  • You need to have a paid plan of Bosch IoT Insights. (The free plan does not include this feature.)

  • You are an Admin in your project.

The content of the Configuring a pipeline to process data tutorial is also available as a YouTube video.

images/confluence/download/attachments/1685948147/youtube_screencast5.png

This chapter details the following topics:

Modifying the Python code example

As a first step, we will download the Python code example from the Pipelines: Configuring the custom step chapter and modify the step.py file.

Proceed as follows

  1. Open the Pipelines: Configuring the custom step chapter and download the Python code example.

  2. Unzip the folder.

  3. Open the src folder.

  4. Open the step.py script for editing as we will add a random value to our pipeline data.

  5. Add from random import randrange to the beginning of the script.

  6. Underneath # modify the data, replace the first_doc['payload']["addedValue"] = "my python invoked and attached new value" line with first_doc['payload']["addedRandom"] = randrange(100).

  7. Save the file.

  8. Zip the folder.

Configuring the pipeline

We will now create a pipeline and upload the modified zip folder to the custom step.

Proceed as follows

  1. Open the Processing > Pipelines tab.

  2. Click the Create New Pipeline button.

  3. In the Pipeline App Name field, enter a name for the pipeline.

  4. Click the Create New Pipeline button.
    → The App Settings of the pipeline are displayed.

  5. Open the Configuration tab.

  6. For the Input Trigger, activate the Custom Filter checkbox so that not every document will be processed by this pipeline but only those that have the metadata type python.

  7. Enter { "metaData.type": "python" } as the filter.

    images/confluence/download/attachments/1685948147/tutorial5_input_step.png
  8. Leave the Parser as it is.

    You can use the Parser to transform input data into exchange data, which is the internal data format of the pipeline.
    To do so, you would choose from parser types like default, ZIP files, JSON, XML, or Vector DBC. The default parser type is always a good choice as it parses all formats.

  9. Click the plus icon and add a Custom step.

  10. Click the Edit icon images/confluence/download/thumbnails/1685948147/icon_edit_history.png to add a name for the custom step.

  11. Drag and drop the modified zip folder into the upload box.
    → The zip folder is added to the custom step.

    images/confluence/download/attachments/1685948147/tutorial5_custom_step.png
  12. Open the Output step.

  13. Next to the Output Collection drop-down list, click the New Collection button.
    → The Create New Collection dialog is displayed.

    1. In the Technical Name field, enter a technical name for the collection.

    2. In the Label field, enter a label that will be displayed.

    3. Click the Create button.
      → The new collection is created.

  14. Click the Save button to create the pipeline.

    This may take a few seconds.

    → The pipeline has been configured.

  15. Click the Start button to start the pipeline.

    This may take a few seconds.

    → The pipeline is started and can be used to process data.

Uploading a document for processing

For processing data, we will create a simple JSON file and upload it to Bosch IoT Insights.

Proceed as follows

  1. Open Notepad++ or any other tool.

  2. Enter {"Hello": "Python"}.

  3. Save the document.

  4. Open Processing > Data Upload.

  5. Click the Select Files button to upload the file we just created.

  6. Select the file.
    → The file is added.

  7. Click the + Metadata button to add the python type.

    1. In the Key field, enter type.

    2. In the Value field, enter python.

      images/confluence/download/attachments/1685948147/tutorial5_upload_data.png
  8. Click the Upload button to upload the file.
    → The file is processed.

Viewing the processed data

After the data was processed, you can see the result in the Data Browser.

Proceed as follows

  1. Click the View Processed Data button to be redirected to the Data Browser.
    → The processed document with the random value is displayed.
    images/confluence/download/attachments/1685948147/tutorial5_processed_data1.png

    If the random value is not displayed in the processed document, we recommend to either disable the default pipeline or configure the custom filter in the input trigger of the default pipeline to not process data of the type python. In case you uploaded the document before, you could also delete/purge the corresponding input history and processing information entries.

  2. Open the tab with the new output collection we created while configuring the pipeline.
    → The processed data and also the random value is displayed.

    images/confluence/download/attachments/1685948147/tutorial5_processed_data3.png
  3. Open the Processed Data tab to find out how the data was processed with the default pipeline.
    → The processed data is displayed without the random value.

    images/confluence/download/attachments/1685948147/tutorial5_processed_data2.png