Skip to content

Business Events Capture - OneAgent#

Using the Dynatrace OneAgent to capture Business Events provides real-time business observability, enabling data-driven decision-making and improved business outcomes by offering precise metrics and context, lossless access to data, and the ability to explore large datasets without pre-indexing.

  • Recommended approach for capturing Business Events when applicable

  • Uses deep payload inspection extracts business data from in-flight application requests and responses

  • Configuration is simple and doesn’t require code changes

  • Automatically enriches business events with context, including host, process group, and trace information, which helps in analyzing anomalies and fostering collaboration

Get business events via OneAgent documentation

This lab will utilize the Dynatrace OneAgent to capture business events for the Place Order step of the Astroshop Order to Shipped business process.

  • Configure a capture rule, triggers and data fields to be extracted
  • Use OpenPipeline to extract and remove fields
  • Validate Business Event data with a Notebook

FlowStepOne

FlowRaw

Place Order#

In this section of the lab we will configure a Business Event capture rule for Place Order step of the Order to Shipped business process.

Business Event - Source Settings#

Go to Settings Classic > Business Analytics > OneAgent Business Event Sources.

Select the Incoming tab.

Rule 1

Business Event - Capture Rule#

Select the Add new capture rule button and name your rule using the following name:

astroshop_placeorder_success

Rule Name

Business Event - Triggers#

To capture Business Events from incoming web requests, we need to define conditions which are called Triggers. Triggers are connected by AND logic per capture rule. If you set multiple trigger rules, all of them need to be fulfilled to capture a business event.

We will use 3 triggers:

Trigger 1

Select the Add trigger button.

In the Data source drop down list select:

Request - Path

In the Operator drop down list select:

equals

In the Value field use:

/api/checkout

Trigger 1

Trigger 2

Select the Add trigger button.

In the Data source drop down list select:

Response - Body

In the Path field use:

*

In the Operator drop down list select:

contains

In the value field use:

orderId

Trigger 2

Trigger 3

Select the Add trigger button.

In the Data source drop down list select:

Response - HTTP Status Code

In the Operator drop down list select:

equals

In the Value field use:

200

Trigger 3

Business Event - Event Provider#

The Event Provider is the source of the event, for example, the name of the component or system that generated the event.

Under Event meta data, for the Event provider section use the following:

In the Data source drop down list select:

Fixed value

In the Fixed value section use:

astroshop

Event Provider

Business Event - Event Type#

The Event Type is the unique identifier of a given event.

Under Event meta data, for the Event type section use the following:

In the Data source drop down list select:

Fixed value

In the Fixed value section use:

astroshop.placeorder.success

Event Type

Business Event - Event Category#

The Event Category is optional.

For this lab we will leave the default value which should be empty.

Business Event - Event Meta Data#

The steps so far conclude the configuration of a business event that will be generated each time the trigger criteria is matched. This might be sufficient if all you need is to answer the question of how many astroshop_placeorder_success events were called.

In most cases you will want to add event attributes to provide granular insight. Attributes are data fields extracted from the event JSON or XML payload.

Below is sample response payload for the Place Order transaction. The following steps will cover how to extract the orderId and units (units will be used for the revenue number) and more from the response payload.

Capturing the orderId is critical for this business process as it will be unique identifier (correlation ID) that is common to all of the process steps.

Note: Use must use exact letter casing for fields that you define for data extraction.

{
    "orderId": "09766d7d-0530-11f0-895b-0e326b3139ca",
    "shippingTrackingId": "c51af8bd-3fe1-4a46-9d9b-45a16cd7cd66",
    "shippingCost": {
        "currencyCode": "USD",
        "units": 47,
        "nanos": 700000000
    },
    "shippingAddress": {
        "streetAddress": "1600 Amphitheatre Parkway",
        "city": "Mountain View",
        "state": "CA",
        "country": "United States",
        "zipCode": "94043"
    },
    "items": [
        {
            "cost": {
                "currencyCode": "USD",
                "units": 349,
                "nanos": 949999999
            },
            "item": {
                "productId": "66VCHSJNUP",
                "quantity": 1,
                "product": {
                    "id": "66VCHSJNUP",
                    "name": "Starsense Explorer Refractor Telescope",
                    "description": "The first telescope that uses your smartphone to analyze the night sky and calculate its position in real time. StarSense Explorer is ideal for beginners thanks to the app’s user-friendly interface and detailed tutorials. It’s like having your own personal tour guide of the night sky",
                    "picture": "StarsenseExplorer.jpg",
                    "priceUsd": {
                        "currencyCode": "USD",
                        "units": 349,
                        "nanos": 950000000
                    },
                    "categories": [
                        "telescopes"
                    ]
                }
            }
        }
    ]
}

Below is sample request payload for the Place Order transaction. The following steps will cover how to extract the userId from the response payload.

Note: Use must use exact letter casing for fields that you define for data extraction.

{
        "userId": "2e31768f-dc87-4a74-b70f-5972ecca30b1",
        "email": "mark@example.com",
        "address": {
          "streetAddress": "1 Hacker Way",
          "state": "CA",
          "country": "United States",
          "city": "Menlo Park",
          "zipCode": "94025"
        },
        "userCurrency": "USD",
        "creditCard": {
          "creditCardCvv": "***",
          "creditCardExpirationMonth": "*",
          "creditCardExpirationYear": "****",
          "creditCardNumber": "****-****-****-****"
        }
}

The following table shows additional examples of how to extract data from JSON payloads.

JSON Payload Extractin Example

Dynatrace Documentation Link

Business Event - orderId Capture#

Under the Event data section, select the Add data field button.

In the Field name section use:

orderId

In the Data Source drop down list select:

Response - Body

In the Path section use:

orderId

Event Data orderId

Business Event - country Capture#

Under the Event data section, select the Add data field button.

In the Field name section use:

country

In the Data Source drop down list select:

Response - Body

In the Path section use:

shippingAddress.country

Event Data country

Business Event - userId Capture#

Under the Event data section, select the Add data field button.

In the Field name section use:

userId

In the Data Source drop down list select:

Request - Body

In the Path section use:

userId

Event Data userId

Business Event - revenue Capture#

Under the Event data section, select the Add data field button.

In the Field name section use:

revenue

In the Data Source drop down list select:

Response - Body

In the Path section use:

items.0.cost.units

Event Data revenue

Business Event - shippingTrackingId Capture#

Under the Event data section, select the Add data field button.

In the Field name section use:

shippingTrackingId

In the Data Source drop down list select:

Response - Body

In the Path section use:

shippingTrackingId

Event Data shippingTrackingId

Business Event - Full Response Body Capture#

Under the Event data section, select the Add data field button.

In the Field name section use:

ResBody

In the Data Source drop down list select:

Response - Body

In the Path section use:

*

Event Data ResBody

Note: Some use cases might require capturing and store the full response body. OpenPipeline can be used for Business Events to extract needed fields, masking. You can also drop the full response body field keeping only what extract.

This approach is also helpful for data validation/debugging during initial setup but not using when you fully deploy. Lastly, using * for the path field value will capture everything. For this lab will use the full response body.

Business Event - Save Rule#

Click the Save changes button.

Save changes

Query Business Events in Dynatrace#

Provided Notebook

Astroshop_SE_Training_Business_Observability_Notebook

Import the Notebook using the source file Astroshop_SE_Training_Business_Observability_Notebook by downloading to your local system and upload to the Notebooks app. This can be during the labs exercises.

Astroshop Notebook

Or, using your own Notebook execute the below DQL query which retrieves the business events for astroshop.placeorder.success step.

DQL:

fetch bizevents
| filter event.provider == "astroshop" and event.type == "astroshop.placeorder.success"
| fields timestamp, event.provider, event.type, userId, orderId, revenue, country,trace_id,ResBody
| sort timestamp desc

Result:

DQL Query

Notice we have null values for orderId, revenue, country fields.

When reviewing the Response Payload, there are multiple references for the string '\u0019'. This is a unicode string that denotes End Of Medium. JSON parsing from the OneAgent capture won't work for this use case.

JSON parsingn unicode

This would be probably rare in your most environments. Don't worry, for this lab we can fix capturing orderId, revenue, country fields using a OpenPipeline rule.

Conclusion#

We have completed the Business Event capture using the OneAgent for Place Order Success step of the Order to Shipped business process. The next section will cover using OpenPipeline to replace the null fields with correct data.

OpenPipeline#

In this section of the lab we will use OpenPipeline to replace the orderId, revenue, country fields values when they are null. Using OpenPipeline, the ResBdy field will be used to extract the correct values needed for the Place Order Business Event.

Business Events - OpenPipeline - Place Order#

Launch the OpenPipeline app.

Select Business events in the OpenPipeline tree.

Select Pipelines tab.

Select the + Pipeline button.

Launch OpenPipeline

Business Events - OpenPipeline - Processing - Place Order#

Name your OpenPipeline rule using the following name:

Astroshop

Select the Processing tab.

Select the + Processor button (left side of the screen), then select DQL.

OpenPipeline Processing Part 1

Fill out the fields with the following data:

Name:

FixFieldsWithNullValues

Matching condition:

event.type == "astroshop.placeorder.success" and isNull(orderId)

DQL processor definition:

parse ResBody, """DATA 'orderId":' DQS:orderId LD 'shippingTrackingId":' DQS:shippingTrackingId LD 'units":' DOUBLE:revenue LD  LD 'country":' DQS:country"""

Sample data:

     {
           "timestamp": "2025-03-26T23:39:04.840000000-04:00",
           "event.provider": "astroshop",
           "event.type": "astroshop.placeorder.success",
           "userId": "ae844c70-5b7e-471f-9cfb-07715a46bc8d",
           "orderId": null,
           "revenue": null,
           "country": null,
           "trace_id": "104a1ee54db91be0ff9acbcb65cdfee4",
           "ResBody": "{\"orderId\":\"07fa8ff2-0abd-11f0-92d2-0e1e3ab12988\",\"shippingTrackingId\":\"6fd4c157-ca6b-465e-bc39-a5096d6ee08c\",\"shippingCost\":{\"currencyCode\":\"USD\",\"units\":84,\"nanos\":400000000},\"shippingAddress\":{\"streetAddress\":\"1 Hacker Way\",\"city\":\"Menlo Park\",\"state\":\"CA\",\"country\":\"United States\",\"zipCode\":\"94025\"},\"items\":[{\"cost\":{\"currencyCode\":\"USD\",\"units\":209,\"nanos\":949999999},\"item\":{\"productId\":\"2ZYFJ3GM2N\",\"quantity\":2,\"product\":{\"id\":\"2ZYFJ3GM2N\",\"name\":\"Roof Binoculars\",\"description\":\"This versatile, all-around binocular is a great choice for the trail, the stadium, the arena, or just about anywhere you want a close-up view of the action without sacrificing brightness or detail. It\u0019s an especially great companion for nature observation and bird watching, with ED glass that helps you spot the subtlest field markings and a close focus of just 6.5 feet.\",\"picture\":\"RoofBinoculars.jpg\",\"priceUsd\":{\"currencyCode\":\"USD\",\"units\":209,\"nanos\":950000000},\"categories\":[\"binoculars\"]}}}]}"
         }

Select the Run sample data button.

Under the Preview result section validate orderId, country and revenue fields have values.

OpenPipeline Processing Part 2

Business Events - OpenPipeline - Processing - Remove ResBody Field#

Select the + Processor button (left side of the screen), then select Remove fields

OpenPipeline Processing Part 3

Fill out the fields with the following data:

Name:

RemoveResBody

Matching condition:

event.type == "astroshop.placeorder.success"

Remove fields:

After adding the below field to remove, select the Add button.

ResBody

Select the Save Button at the top right of the screen.

OpenPipeline Processing Part 4

Business Events - OpenPipeline Dynamic Route - Place Order#

Now we need to create a Dynamic route for the Astroshop Business Events pipeline. Dynamic routes give you the option to route your ingested data into a pipeline with a matching condition.

Select Business events in the OpenPipeline tree.

Select Dynamic routing tab.

Select + Dynamic route button.

Pipeline Dynamic Route Part 1

Configure the Dynamic route with the following:

Name:

Astroshop_BusinessEvents

Matching condition:

event.provider == "astroshop"

Pipeline:

In the dropdown list select the following:

Astroshop

Select the Add button.

Pipeline Dynamic Route Part 2

Select the Save button.

A warning icon with this message will appear "Do you want to save your changes to this table?" 
Select the Save button.

Pipeline Dynamic Route Part 3

Conclusion#

We have completed the Business Event OpenPipeline section for Place Order step of the Order to Shipped business process. This section covered how to use OpenPipeline to replace the null values for orderId, revenue, country with the correct values. The next section will validate the data.

Data Validation#

In this section of the lab we will validate the data for the Place Order step of the Order to Shipped business process.

Query Business Events in Dynatrace#

Using a Notebook execute the below DQL query which retrieves the buisness events for astroshop.placeorder.success step.

DQL:

fetch bizevents
| filter event.provider == "astroshop" and event.type == "astroshop.placeorder.success"
| fields timestamp, event.provider, event.type, userId, orderId, revenue, country, shippingTrackingId, trace_id
| sort timestamp desc

Result:

DQL Query

Conclusion#

We have completed data validation for the Place Order step of the Order to Shipped business process.

Data Validation#

In this section of the lab we will validate the data for the Place Order step of the Order to Shipped business process.

Query Business Events in Dynatrace#

Using a Notebook execute the below DQL query which retrieves the buisness events for astroshop.placeorder.success step.

DQL:

fetch bizevents
| filter event.provider == "astroshop" and event.type == "astroshop.placeorder.success"
| fields timestamp, event.provider, event.type, userId, orderId, revenue, country, shippingTrackingId, trace_id
| sort timestamp desc

Result:

DQL Query

Conclusion#

We have completed data validation for the Place Order step of the Order to Shipped business process.

Continue#

In the next section, we'll capture Business Events from Logs using OpenPipeline.