This use case shows how your data can be captured, how a processing rule is set, and how this data can be further analyzed and visualized.
This article is intended for business analysts and process managers who understand how their businesses are performing in real time and look for optimal execution of their business processes. You should have a basic knowledge of how business events are captured and some domain knowledge of the business area you are trying to analyze.
EasyTrade is a simulated trading application with the following use cases:
In this scenario, we suppose you need to calculate the total value of deposits placed on each account, the total and maximum dollar trading volume per account on EasyTrade, and the total value of buy-asset transactions per account in quick buy operations.
You need to determine:
Because you need to calculate the dollar trading volume, your processing rule should multiply the price by the amount and add the result as a new field to the event:
Dollar Trading Volume = Price * Amount
You also need to define the data items of the quick-buy-asset request. For example:
{"accountId":6,"amount":10,"instrumentId":1,"price":157.025}
Go to Settings app.
Select Collect and capture > Business Events > Incoming.
Select Add new capture rule and set Rule name to easyTrade- /v1/trade/buy
.
Select Add trigger and, in the Summary section, set the following:
Request - Path
starts with
- /v1/trade/buy
Select again Add trigger and, in the Summary section, set the following:
Request – HTTP Method
equals
POST
Define the Event provider:
Fixed value
www.easytrade.com
Define the Event type:
Fixed value
com.easytrade.quick-buy
If you need to add more event types, select Event type separately for each event type. In this case, the event types will also be com.easytrade.
and com.easytrade.deposit
.
Define the Event category:
Fixed value
In the Event data section, you need to add four data fields.
For each data field:
Select Add data field.
Set the Field name, Source, and Path values according to the following table:
Field name
Source
Path
accountId
Request-Body
accountId
amount
Request-Body
amount
instrumentId
Request-Body
instrumentID
price
Request-Body
price
Select Save changes.
To create your data processing rule
Go to OpenPipeline app.
Select Business Events > Pipelines tab.
To create a new pipeline, select Pipeline and enter the name—Process EasyTrade data
.
In the Processing tab, select Processor > DQL and name your processor EasyTrade trade volume
.
Set your rule's Matching condition to the following matcher-specific DQL query:
matchesValue(event.provider, "www.easytrade.com")
com.easytrade.buy-assets
), the matcher would be:
matchesValue(event.type, "com.easytrade.buy-assets")
matchesValue(event.type, "com.easytrade.buy-assets") or matchesValue(event.type, "com.easytrade.sell-assets")
matchesValue(event.provider, "www.easytrade.com")
In the DQL processor definition field, add
fieldsAdd trade_volume=amount*price
Select Save.
To create a new route, go to the Dynamic routing tab > Dynamic route and specify:
matchesValue(event.provider, "www.easytrade.com")
Select the Process EasyTrade data
pipeline, where the business events will be routed.
Select Add, then Save.
Note: Any rule put under Dynamic routing in Process EasyTrade data
pipeline will process data under the same matching condition.
To add your business event metric
Go to OpenPipeline app.
Select Business Events > Pipelines tab.
Select the previously created Process EasyTrade data
pipeline.
Go to the Metric Extraction tab.
Select Processor > Value metric and name it bizevents.EasyTrade.TradingVolume
.
Add Matching condition to your rule by pasting your matcher-specific DQL query:
matchesValue(event.type, "com.easyTrade.quick-buy")
Choose the Field extraction on which your metric will be based—add trading_volume
.
In Metric key, name your metric bizevents.EasyTrade.TradingVolume
.
You can also choose Dimensions, either Pre-defined, for example dt.entity.host
, or Custom.
Select Save.
To display your metrics
Go to Notebooks.
Select Notebook and name it Notebook for business analytics metrics
.
To open the metrics query builder, add a new section and select Metrics.
Find your metric in the search window, select Run, and display your results.
You can also:
If you need to store your data for one year, for example, for tax purposes, first you need to create a bucket for bizevents with a one year retention period.
easytrade-bizevents
.EasyTrade bizevents
.bizevents
.After creating the bucket, you need to define the rules to store the incoming bizevents in that bucket.
Process Easytrade data
from the pipelines list.Easytrade data bucket assignment
.true
(since the routed bizevents all belong to the EasyTrade data
).EasyTrade bizevents
.To see if your data was captured correctly
Select Run in Playground below this query:
fetch bizevents| filter event.provider == "www.easytrade.com"| filter event.type == "com.easytrade.quick-buy" OR event.type == "com.easytrade.deposit" OR event.type == "com.easytrade.quick-sell"| sort timestamp desc
Select New notebook and the query will run itself automatically.
You should get results something like the following:
At this point, you can start building your DQL queries to analyze the data loaded, define metrics, and create charts and dashboards.
You need to calculate:
To analyze your data using DQL, select Run in Playground below this query:
fetch bizevents, from:now()-30d, to:now()| filter event.provider == "www.easytrade.com" and (event.type == "com.easytrade.quick-buy" OR event.type == "com.easytrade.deposit" OR event.type == "com.easytrade.quick-sell")| fieldsAdd moneyTransfered = if(event.type == "com.easytrade.deposit", toDouble(amount)),buyAssets = if(event.type == "com.easytrade.quick-buy", toDouble(amount)),trading_volume= if(event.type == "com.easytrade.quick-sell",(amount*price))| summarize sum(moneyTransfered), sum(buyAssets), sum(trading_volume), max(trading_volume), by:accountId
Results table:
accountid
max(trading_volume)
sum(buyAssets)
sum(moneyTransfered)
sum(trading_volume)
6
19924.3187495
609491
1340160.809059129
526623.1340707905
7
47827.65870614
593648
1287203.0690401047
922284.0555854205
8
16718.08125
615123
1288892.9309932007
550042.8770441795
You can display your results in several ways, including the following options.
As a bar chart in Notebooks, limiting the result to the top 10 with maximum money transfer.
On a dashboard tile
To pin your results to a dashboard in Notebooks