Introduction
In this blog, we will demonstrate how to use custom business events in mule in order to track the business data for audit purposes or any other kind of reporting purpose.
Use the Custom Business Event component (tracking:custom-event element in the XML view) to add metadata and Key Performance Indicators (KPIs) to your flow.
The Business Events tab on the management console gives you visibility into business transactions and events on your Mule servers, allowing you to track and analyze the flow and disposition of messages. For example, you can use the data to do root cause analysis on a failure within a business transaction or identify message processing bottlenecks.
Anypoint Platform supports defining the same set of business events whether it is On-Premise or iPaaS. These events can be designed, developed, and monitored seamlessly across on-premise and iPaaS solutions.
‘All’ or ‘None’ events
The property (see below) marks all events in the flow to be flagged as “on” or “off”. By using this property, default events provided by Anypoint Platform can be tracked:
<flow name=”custom-business-eventFlow” tracking:enable-default-events=”true|false”>
Configure Custom Business Events
Let’s see how to configure custom business events in our mule flow.
Create a project in AnyPoint studio and configure the listener.
Drag and drop custom business events from the mule palette and configure the Event Name and KPIs as shown below
Here the KPI is eventId so that we can track the transaction without any hurdles.
Let’s deploy the same application to the CloudHub.
To see KPI you must enable Insights for your application during deployment, like below:
Once deployment is completed Successfully, let’s Test the same.
Validate Custom Business Events
Open the Postman, and trigger the request for Custom Business Event as below:
Goto the CloudHub and click on the insight Tab.
Trace the transaction and you can check the application KPIs that you defined in your mule application.
This is the simplest way to add the Custom Business Event ID. Similar way, we can add as many KPIs as you need.
For your KPIs, use names that are easy to search for in the Anypoint Runtime Manager interface, and use a representative value, which can be any Mule expression:
Name |
Expression / Value |
employee-id | #[payload[‘ID’]] |
employee-email | #[payload[‘Email’]] |
employee-git-id | #[payload[‘GITHUB_ID’]] |
price | 700 |
price-after-discount | #[vars.price] |
order-id | #[payload.order.header.orderID] |