Import flow traces programmatically via Azure Event Hubs
Invictus allows developers to programmatically import flow traces via an Event Hub. You can locate this resource by the following:
- EventHub namespace:
invictus-{env}-we-sft-evnm - Event Hub name:
invictus-{env}-we-sft-genericreceiver-evhb
Sending flow traces to Invictus
The Event Hub import accepts a series of event models in a JSON array, each representing a status of the flow:
[
{
// Flow started event.
},
{
// Flow completed event.
}
]
The minimal event values are the following:
// event
{
// When event was executed, recommended UTC datetime.
// (used to determine the order of events)
"Time":"2019-07-23 08:55:04.0500000 +00:00",
// Transactional ID to link events together.
// (like 'client tracking ID')
"ChainId": "edbd5ddb-b206-4437-8ac3-5401b148c8cb",
// Represents a single 'step' taken in the transaction of events.
// (like workflow 'Started')
"Step": {
// Operation ID within the transaction of events.
// (like 'workflow run ID')
"Id": "8ecd1ea4-de94-4741-9c4a-a18477398299",
// Human-readable name for the operation/step ID.
"Name": "Invoice",
// Available values are:
// - Started
// - Active
// - Cancelled
// - Completed
// -Failed
"Status": "Started"
}
}
A Started event is always required to create at least a single event in Invictus' backend storage. A Completed/Failed event then indicates the end of a given operation.
Map Dashboard flows to Event Hub receive events
Make sure that any of the event mappings match the values in the flow created via the Dashboard
// event
{
// [omitted]
"Mappings": {
"Domain": "Invoicing",
"Action": "New invoice",
"Service": "Invoice system",
"Version": "v1.2.3"
}
}
Execution tree of sequentially events
Use the Step.Id/Step.ParentId combination to create parent-child relationships. This link is similar as how you can set the x-iv-parent-workflow-run-id when importing flows via Azure Logic App workflows.
[
// event
{
// [omitted]
"Step": {
"Id": "8ecd1ea4-de94-4741-9c4a-a18477398299"
// [omitted]
}
},
// event
{
// [omitted]
"Step": {
"Id": "3e8e3fa4-b85a-4ee6-aaea-e0fd82008f8c",
"ParentId": "8ecd1ea4-de94-4741-9c4a-a18477398299"
// [omitted]
}
}
]
Tracked properties of events
Besides the Milestone and EventText, there also exists a set of custom Data properties that you can link to the flow.
// event
{
// [omitted]
"Properties": {
"Milestone": "LA-A-Reached",
"EventText": "Line1-A",
"Data": {
"MyKey1": "MyValue1",
"MyKey2": "MyValue2"
}
}
}
Errors on events
If an event represents an error, it can provide context information in the form of a code and a description:
// event
{
// [omitted]
"Error": {
"Code": "123",
"Description": "there was a failure during this operation"
}
}
Azure link on events
Add a link and resource ID if you can track back an event to Azure. These details will populate the Dashboard for a click-through experience.
// event
{
"Azure": {
"ResourceId": "/subscriptions/.../resourceGroups/...",
"PortalLink": "https://portal.azure.com/to-your-resource"
}
}