IBM Developer

Tutorial

Create and manage DataStage pipelines using IBM Bob and watsonx.data integration

A hands-on guide to building, running, monitoring, and troubleshooting DataStage ETL pipelines in watsonx.data Integration using IBM Bob and natural language prompts

By Dhara Bagadia, Zeel Patel

Building Extract, Transform, and Load (ETL) pipelines often requires switching between a code editor, a pipeline designer, and a job monitoring interface. Each tool has its own workflow, which can slow down pipeline development and operations. IBM Bob simplifies this process by exposing the full watsonx.data Integration API through a Model Context Protocol (MCP) server, so that you can create flows, run jobs, review logs, and configure alerts by using natural language prompts from a single conversational interface.

This tutorial uses a retail data integration scenario. Five regional systems generate approximately 200 customer orders each day, and each system uses a different date format. Before the data can be used for analytics, it must be filtered, standardized, and cleaned. A nightly ETL pipeline extracts data from PostgreSQL, transforms the records, writes the cleaned output to a sequential file, and monitors pipeline execution for failures.

In this tutorial, you use Bob to connect to the MCP server, explore project assets, create a DataStage flow, create and run a DataStage job, review execution metrics and logs, and configure job failure alerts by using natural language prompts. By the end of the tutorial, you will have completed the full ETL lifecycle, from source data discovery and pipeline development to execution, monitoring, troubleshooting, and alerting, through a single Bob conversation.

Architecture of the AI-driven ETL pipeline

This solution uses Bob, the ibm-agent-data-intg MCP server, and watsonx.data Integration to build, run, and monitor a DataStage ETL pipeline through a single conversation.

Architecture diagram that shows IBM Bob connecting through the ibm-agent-data-intg MCP server to watsonx.data integration, which runs the DataStage ETL pipeline

Bob serves as the user interface for the solution. The wxdi-data-intg skill and wxdi-intg-engineer custom mode help you create flows, run jobs, view logs, and configure alerts by using natural language prompts.

The ibm-agent-data-intg MCP server connects Bob to watsonx.data Integration. It exposes DataStage functions as MCP tools and translates natural language requests into DataStage operations.

watsonx.data Integration provides the DataStage runtime, APIs, job orchestration, and monitoring services that are required to build and manage the ETL pipeline.

The retail_order_ETL DataStage flow contains three stages:

  1. Orders_Source extracts customer order data from PostgreSQL.
  2. Transform_Orders filters records and standardizes date formats.
  3. SF_Cleaned_Orders writes the cleaned data to a Sequential File.

The monitoring layer tracks job execution and generates alerts when failures occur. A high-severity job-failure alert helps operators quickly identify and investigate pipeline issues.

Data schema

The ETL flow processes 11 columns:

Column type Columns
INTEGER order_id, customer_id, product_id, quantity
VARCHAR customer_name, product_name, order_status, order_date, region
DECIMAL unit_price, total_amount

Solution workflow

Each natural language prompt that you submit in Bob maps to one or more MCP tool calls.

  1. Connect and configure: Connect Bob, enable the wxdi-data-intg skill, and activate the wxdi-intg-engineer custom mode.
  2. Discover and build: Discover source systems and create the three-stage DataStage flow.
  3. Run the pipeline: Execute the retail_order_ETL job and review job status and logs.
  4. Configure monitoring: Create a high-severity job-failure alert.
  5. Review results: Verify the cleaned output file and monitor pipeline operations.

The result is a complete ETL workflow that supports pipeline development, execution, monitoring, and alert management from a single Bob conversation.

Prerequisites

Before you begin, make sure you have access to the following resources:

  • Access to IBM Bob. Sign up for a free access to IBM Bob.
  • An IBM Cloud account with watsonx.data and watsonx.data data integration enabled.
  • An ibm-agent-data-intg API key from your watsonx.data Integration service credentials.
  • A PostgreSQL database. You can use IBM Cloud Databases for PostgreSQL or any accessible PostgreSQL instance.
  • Python 3.8 or later to run the data seeding script used in this tutorial.
  • Basic familiarity with DataStage concepts, including connections, flows, and jobs.

Step 1. Prepare and load the sample retail order data

In this step, you prepare the tutorial files and load the sample retail order data into a PostgreSQL database. You install the required Python package, configure the PostgreSQL connection, and load 200 retail order records into the retail.orders table. The DataStage pipeline uses this table as the source dataset later in the tutorial.

  1. Create a folder for the tutorial files on your system. For example, name the folder datastage-etl-pipeline.

  2. Save the orders_data.csv and ingest_csv_to_pgsql.py files in that folder on your system.

  3. The Python script uses the psycopg2 library to connect to the PostgreSQL database. Install the psycopg2-binary package before you run the script.

     pip install psycopg2-binary
    

    You should see output similar to the following. The package version might be different.

     Collecting psycopg2-binary
       Downloading psycopg2_binary-2.9.12-cp39-cp39-macosx_11_0_arm64.whl (3.8 MB)
     Installing collected packages: psycopg2-binary
     Successfully installed psycopg2-binary-2.9.12
    

    The Python csv and sys modules are part of the Python standard library, so you do not need to install them separately.

  4. Configure the PostgreSQL connection details. Update the following values with your PostgreSQL credentials in ingest_csv_to_pgsql.py and save the file.

     PG_HOST     = "<YOUR_PG_HOST>"
     PG_USER     = "<YOUR_PG_USER>"
     PG_PASSWORD = "<YOUR_PG_PASSWORD>"
    
  5. Run the following command to load the sample data.

     python ingest_csv_to_pgsql.py orders_data.csv
    

    The script creates the retail schema, creates the retail.orders table, and loads the records from orders_data.csv.

  6. Verify the imported data. Run the following SQL query.

     SELECT order_status, COUNT(*)
     FROM retail.orders
     GROUP BY order_status;
    

    The output is similar to the following example.

     order_status | count
     -------------+-------
     completed    |   147
     cancelled    |    22
     pending      |    31
     (3 rows)
    

    The output confirms that the sample retail order data loaded successfully.

    Preview of the retail.orders table data in PostgreSQL

    The retail.orders table contains 11 columns, including customer details, product information, order status, order value, order date, and region. The order_date column contains multiple date formats, which represent a common data quality issue found in real-world data integration projects.

Step 2. Create a PostgreSQL connection in watsonx.data Integration

The DataStage flow needs a connection to the PostgreSQL database that contains the retail order data. In this step, you create a reusable PostgreSQL connection in watsonx.data Integration. You use this connection later when you build the retail_order_ETL flow.

  1. Sign in to IBM Cloud and select watsonx.data integration from the resource list.

    IBM Cloud resource list with watsonx.data integration selected

  2. Open watsonx.data integration and navigate to your project.

    The watsonx.data integration service page

  3. Click Assets → New asset → Connection.

    The Assets tab with the New asset menu open and Connection selected

  4. From the connector catalog, select IBM Cloud Databases for PostgreSQL.

    The connector catalog with IBM Cloud Databases for PostgreSQL selected

  5. Provide the PostgreSQL connection information.

    FieldValue
    Connection nameYour connection name
    HostYour PostgreSQL hostname
    PortYour PostgreSQL port
    DatabaseYour PostgreSQL database name
    UsernameYour PostgreSQL username
    PasswordYour PostgreSQL password
    SSLRequired

    The create connection form with the PostgreSQL connection fields

  6. Click Test connection. Verify that the connection test succeeds.

  7. Click Save.

    The PostgreSQL connection after you save it

    The PostgreSQL connection is now available in your project and you can use it as the source connection for the retail_order_ETL DataStage flow.

    The project assets list that includes the PostgreSQL connection

Step 3. Register the watsonx.data Integration MCP server in IBM Bob

Bob uses MCP servers to access external tools and services. In this step, you register the ibm-agent-data-intg MCP server and connect it to your watsonx.data Integration instance by using an API key. After the connection is established, Bob can create DataStage flows, run jobs, retrieve logs, and configure alerts through natural language prompts.

  1. Open the Bob chat panel.
  2. Click Settings → MCP → Open global MCP config.

    The IBM Bob settings with the Open global MCP config option

  3. Add the following configuration in the mcpServers object. Replace <YOUR_API_KEY> with your watsonx.data Integration API key.

     "ibm-agent-data-intg": {
     "type": "streamable-http",
     "url": "https://api.ca-tor.dai.cloud.ibm.com/data_intg_ai/v1/mcp",
     "headers": {
       "Authorization": "ApiKey <YOUR_API_KEY>"
     },
     "disabled": false,
     "alwaysAllow": [
       "get_projects",
       "list_connections",
       "list_data_assets",
       "list_datastage_flows",
       "inspect_project_asset",
       "create_datastage_flow",
       "update_datastage_flow",
       "create_job",
       "create_job_run",
       "list_jobs",
       "list_job_runs",
       "poll_datastage_job",
       "get_job_run_logs",
       "get_job_run_details",
       "create_alert_definition",
       "list_alert_definitions",
       "list_alerts",
       "get_alerts_summary"
      ]
    }
    
  4. Save the configuration file. Restart Bob.

  5. Open the MCP server list and confirm that ibm-agent-data-intg appears with a Connected status.

    The IBM Bob MCP server list that shows ibm-agent-data-intg with a Connected status

    After the MCP server is connected, Bob can access watsonx.data Integration tools and perform DataStage operations through a single conversational interface.

Step 4. Create the Bob skill

Bob skills provide reusable instructions for specific tasks. In this step, you create a wxdi-data-intg custom skill that helps Bob work with watsonx.data Integration and DataStage. The skill defines when Bob activates it, which MCP tools to use, and how to perform common DataStage operations.

  1. Download the SKILL.md file and save it in the following location in your workspace.

     .bob/skills/wxdi-data-intg/SKILL.md
    

    The skill contains:

    • A description field that automatically activates the skill for DataStage and data integration requests.
    • A tool reference section that maps ibm-agent-data-intg tools to their functions.
    • Workflow instructions for creating flows, running jobs, monitoring executions, scheduling jobs, and configuring alerts.
    • Troubleshooting guidance for common DataStage issues.

      The wxdi-data-intg SKILL.md file in the .bob/skills folder

Step 5. Create the Bob custom mode

Custom modes give Bob a focused role and a predefined set of tools. In this step, you create a wxdi-intg-engineer custom mode for watsonx.data Integration tasks. The mode automatically loads the wxdi-data-intg skill and limits Bob to DataStage and data integration tools.

  1. Open the following file.

     ~/.bob/settings/custom_modes.yaml
    
  2. Add the following configuration:

     - slug: wxdi-intg-engineer
       name: "watsonx.data Integration Engineer"
       roleDefinition: >-
         You are a watsonx.data Integration specialist. Use the
         ibm-agent-data-intg MCP server tools to manage DataStage flows,
         jobs, and alerts. Always resolve project IDs, flow names, and
         job IDs from live tool calls. Never hard-code or guess
         identifiers. Present all results as markdown tables.
       groups:
         - read
         - edit
         - mcp
    
  3. Open the Bob chat panel.

  4. Click the mode picker at the bottom of the Bob chat panel.

  5. Select watsonx.data Integration Engineer.

    The IBM Bob mode picker with watsonx.data Integration Engineer selected

  6. Start a new conversation and enter a DataStage request such as:

     List my DataStage flows
    

    or

     Create a DataStage flow
    

    Bob should activate the wxdi-data-intg skill automatically and use the ibm-agent-data-intg MCP tools to perform the requested task.

    The wxdi-intg-engineer custom mode is now ready to support DataStage flow development, job execution, monitoring, scheduling, and alert management through natural language conversations.

Step 6. Explore the watsonx.data integration project

Before you build the DataStage flow, use IBM Bob to review the available project, database connection, and source table. Bob uses the ibm-agent-data-intg MCP tools to retrieve the current project details from watsonx.data integration.

  • List the projects

    Ask Bob:

      List my watsonx.data Integration projects.
    

    Bob uses the get_projects MCP tool and returns the available projects:

    Project nameProject ID
    Default Data Product Delivery Project<YOUR_PROJECT_ID>

    Bob response that lists the watsonx.data integration projects

  • List the project connections

    Ask Bob:

      What connections are available in my project?
    

    Bob uses the list_connections MCP tool and returns the available database connections:

    NameData source type
    retail-postgresql-dbIBM Cloud Databases for PostgreSQL

    Bob response that lists the connections in the project

  • Inspect the source table

    Ask Bob:

      What columns does the retail.orders table have?
    

    Bob uses the discover_connection_data MCP tool and calls the tool with the following path:

      /retail/orders
    

    Bob returns the 11 columns in the retail.orders table:

    ColumnTypeNullable
    order_idINTEGERNo
    customer_idINTEGERYes
    customer_nameVARCHAR(100)Yes
    product_idINTEGERYes
    product_nameVARCHAR(100)Yes
    quantityINTEGERYes
    unit_priceNUMERICYes
    total_amountNUMERICYes
    order_statusVARCHAR(20)Yes
    order_dateVARCHAR(30)Yes
    regionVARCHAR(50)Yes

    Bob response that lists the columns of the retail.orders table

    The results confirm that Bob can access the watsonx.data integration project, the retail-postgresql-db connection, and the retail.orders source table. The PostgreSQL data is now ready for the DataStage flow.

Step 7. Create the DataStage flow

In this step, you use Bob to create a complete DataStage ETL pipeline. Bob uses the ibm-agent-data-intg MCP tools to create the flow, define the stages, configure the links, and compile the pipeline. The resulting retail_order_ETL flow reads retail order data from PostgreSQL, transforms the records, and writes the output to a sequential file.

  1. Ask Bob.

     Create a DataStage flow called retail_order_ETL in the Default Data Product Delivery Project with three stages.
    
     Before writing any SDK code:
     1. Call get_projects to resolve the project ID
     2. Call list_connections to get the asset ID of retail-postgresql-db
     3. Call list_datastage_flows to check if retail_order_ETL already exists
       - If it exists: use update_datastage_flow with preserve_parameters=True
       - If it does not exist: use create_datastage_flow
    
     Stage 1 — PostgreSQL source (PG_Source)
     - Stage type: IBM Cloud Databases for PostgreSQL
     - Connection: pg_source.configuration.connection.asset_id = "<retail-postgresql-db asset ID from list_connections>"
       Do NOT use project.connections.get(name=...) — it triggers vault resolution and causes compile errors
     - Schema: retail, Table: orders
     - Select statement: SELECT * FROM retail.orders
     - Read method: POSTGRESQL_IBMCLOUD.ReadMethod.general
     - Runtime column propagation: pg_source.configuration.runtime_column_propagation = True
    
     Stage 2 — Transformer (Transformer)
     - Runtime column propagation: transformer.configuration.runtime_column_propagation = True
     - Output link named Link_2, all 11 columns passed through using source="Link_1.<column_name>" on each add_field call
    
     Stage 3 — Sequential File sink (SeqFile_Sink)
     - Stage type string: "Sequential file"  ← lowercase 'f', exactly as shown
     - file: ["cleaned_orders.csv"]
     - first_line_is_column_names: SEQUENTIALFILE.FirstLineColumnNames.true
     - file_update_mode: SEQUENTIALFILE.AppendOverwrite.overwrite
     - create_data_asset: True
     - data_asset_name: "cleaned_orders"
     - Do NOT set force_sequential
    
     Link schema — Link_1 (PG_Source → Transformer), Link_2 (Transformer → SeqFile_Sink):
     order_id       INTEGER
     customer_id    VARCHAR   length=20
     customer_name  VARCHAR   length=100
     product_id     VARCHAR   length=20
     product_name   VARCHAR   length=100
     quantity       INTEGER
     unit_price     DECIMAL   length=10, precision=10, scale=2
     total_amount   DECIMAL   length=10, precision=10, scale=2
     order_status   VARCHAR   length=20
     order_date     VARCHAR   length=20
     region         VARCHAR   length=50
    
     SDK rules (must follow exactly):
     - Schema objects MUST be created with link.create_schema() before calling add_field
       CORRECT:   pg_source_schema = link_1.create_schema()
                 pg_source_schema.add_field("VARCHAR", "customer_id", length=20)
       WRONG:     schema_1 = link_1.schema
                 schema_1.add_field(...)
       WRONG:     link_1.schema.add_field(...)
    
     - add_field signature: first arg = type string, second arg = column name string
       CORRECT:   schema.add_field("VARCHAR", "customer_id", length=20)
       WRONG:     schema.add_field(name="customer_id", data_type=DataType.VARCHAR, length=20)
    
     - DECIMAL fields must always include precision= alongside length= and scale=
    
     - Transformer output columns use source= on each add_field call on link_2's schema
       CORRECT:   transformer_schema.add_field("VARCHAR", "customer_id", length=20, source="Link_1.customer_id")
       WRONG:     transformer.add_output_column("customer_id", source="Link_1.customer_id")
    
     - connect_output_to() takes the stage variable as first arg, not a string
       CORRECT:   link_1 = pg_source.connect_output_to(transformer)
       WRONG:     link_1 = pg_source.connect_output_to("Transformer", "Link_1")
    
     - Set link name after connect_output_to: link_1.name = "Link_1"
    
     - Runtime column propagation must go through configuration:
       CORRECT:   pg_source.configuration.runtime_column_propagation = True
       WRONG:     pg_source.runtime_column_propagation = True
    
     - Do NOT set host, port, database, username, or password on the stage — invalid stage properties
     - Do NOT set connection via project.connections.get() — use connection.asset_id only
    

    Bob performs the following tasks:

    • Resolves the project ID.
    • Retrieves the PostgreSQL connection asset ID.
    • Checks whether the retail_order_ETL flow already exists.
    • Creates or updates the DataStage flow.
    • Validates stage properties and link schemas.
    • Compiles the DataStage flow.

    During flow creation, Bob uses the following MCP tools:

    • get_projects to resolve the project ID.
    • list_connections to retrieve the PostgreSQL connection.
    • list_datastage_flows to check for an existing flow.
    • datastage_property_lookup to validate stage properties.
    • create_datastage_flow to create the flow.
    • update_datastage_flow to update the flow schema and configuration when required.

    Bob creates a three-stage ETL pipeline:

    StagePurpose
    PG_SourceReads data from the retail.orders PostgreSQL table
    TransformerProcesses records and passes all 11 columns through the pipeline
    SeqFile_SinkWrites the cleaned data to cleaned_orders.csv
  2. After the flow compiles successfully, Bob returns a response similar to the following:

     Flow compiled successfully.
    
     Flow: retail_order_ETL
    
     Stages:
       PG_Source
           → Transformer
           → SeqFile_Sink
    
     Link:
     https://<FLOW_URL>
    

    Bob response that confirms the retail_order_ETL flow compiled successfully

  3. Open the watsonx.data Integration project and locate the retail_order_ETL flow.

    The project assets list that shows the retail_order_ETL flow

  4. Open the flow to review the pipeline design, stage configuration, link definitions, and data movement path.

    The retail_order_ETL flow canvas that shows the PG_Source, Transformer, and SeqFile_Sink stages

Step 8. Create a DataStage job

A DataStage flow must have a job before it can run. In this step, you use Bob to create a job for the retail_order_ETL flow. The job provides the runtime configuration that DataStage uses to execute the pipeline.

  1. Ask Bob.

     Create a job for the retail_order_ETL flow
    

    Bob uses the create_job MCP tool and returns a response similar to the following:

     Job created successfully.
    
     Job name: retail_order_ETL.DataStage job
     Flow:     retail_order_ETL
    

    Bob response that confirms the job was created for the retail_order_ETL flow

  2. Open the retail_order_ETL flow in watsonx.data integration and confirm that the following job is available.

     retail_order_ETL.DataStage job
    

Step 9. Run the DataStage job

With the DataStage flow and job in place, you can run the ETL pipeline. In this step, Bob starts the job, monitors its progress, and returns the execution results. After the job completes, you can review the processing statistics and job details in watsonx.data Integration.

  1. Ask Bob.

     Run the retail_order_ETL job now
    

    Bob uses the following MCP tools:

    • create_job_run to start the job.
    • poll_datastage_job with timeout=-1 to monitor the job until it reaches a final state.

    Bob returns a response similar to the following:

     Job run completed successfully.
    
     Status:        Completed
     Duration:      2 seconds
     Total stages:  3
    
     Rows read:     200
     Rows written:  200
    
     Stage breakdown:
    
     PG_Source       — read 200 rows
     Transformer     — read 200 rows, wrote 200 rows
     SeqFile_Sink    — wrote 200 rows to cleaned_orders.csv
    
  2. Open the retail_order_ETL.DataStage job in watsonx.data Integration. Select the latest job run to view:

    • Job status
    • Execution duration
    • Stage metrics
    • Link metrics
    • Execution logs

      The project assets list that shows the retail_order_ETL flow and the retail_order_ETL.DataStage job

      A successful run confirms that the pipeline read 200 records from PostgreSQL, processed the records through the transformer stage, and wrote 200 records to the output file.

      Job run statistics for the retail_order_ETL job in watsonx.data integration

      Note: If a subsequent job run fails with the following error, the Sequential file stage is not configured to overwrite an existing output file.

      Fatal Error: File DataStage/files//tmp/cleaned_orders.csv exists on COS;
      it will not be overwritten.
      

      Verify that the flow contains the following setting:

      snk.configuration.file_update_mode = SEQUENTIALFILE.AppendOverwrite.overwrite
      

      If the setting is missing, update the flow by using the update_datastage_flow MCP tool and run the job again.

Step 10. Review job run details and execution logs

After the job completes, you can inspect the execution metrics and runtime logs. Bob can retrieve stage statistics, link statistics, and log entries from the most recent job run. These details help you verify the pipeline results and troubleshoot issues when a job fails.

  1. Ask Bob.

     Show me the details of the last retail_order_ETL run
    

    Bob uses the get_job_run_details MCP tool and returns information similar to the following:

    Bob response with the job run details, part 1 of 2

    Bob response with the job run details, part 2 of 2

The stage and link metrics confirm that 200 records moved through the pipeline successfully.

  1. Review the execution logs. Ask Bob.

     Show me the logs for the last retail_order_ETL run
    

    Bob uses the get_job_run_logs MCP tool and filters the logs to show errors, warnings, and fatal messages only. For a successful job run, the log output contains informational messages and no errors or warnings.

    Bob response that shows the job run logs

Step 11. Create a job failure alert

Production ETL pipelines should notify operators when a job fails. In this step, you use Bob to create a high-severity alert for the retail_order_ETL job. The alert helps you detect failures quickly and respond before downstream systems are affected.

  1. Ask Bob.

     Alert me if the retail_order_ETL job fails. Severity high.
    

    Bob uses the create_alert_definition MCP tool and creates the alert with the following settings:

    • Alert type: JobRunState
    • Condition: this.state == 'failed'
    • Severity: high
    • Monitored job: retail_order_ETL.DataStage job

    Bob returns a response similar to the following:

    Bob response that confirms the job failure alert was created

  2. Verify the alert definition. Ask Bob.

     Are there any active alert definitions for my project?
    

    Bob uses the list_alert_definitions MCP tool and returns the active alert definitions:

    Bob response that lists the active alert definitions for the project

    The alert is now active and monitors the retail_order_ETL.DataStage job. If a future job run fails, watsonx.data Integration generates an alert so that you can investigate the issue immediately.

Summary

In this tutorial, you built an end-to-end ETL pipeline by using natural language prompts instead of manually configuring pipeline components. You started by loading sample retail order data into a PostgreSQL database, created the required connections and configurations, and explored available project assets.

You then created a DataStage flow to extract data from PostgreSQL, transform the records, and write the output to a file. After creating the flow, you created and ran a DataStage job, reviewed execution metrics and logs, and verified that the pipeline processed the data successfully.

You also configured a job failure alert to monitor pipeline health and improve operational visibility. By the end of the tutorial, you completed the full ETL lifecycle, including data preparation, pipeline creation, job execution, monitoring, troubleshooting, and alerting, through a single conversational interface.