Skip to main content
Version: 2.2.0

Monitor Workflow

When the workflow is running, it will generate events in the database. These events can be used to monitor the state of the workflow.

Workflow Events

Belows are the events that will be generated by the workflow with their description.

EventDescriptionAttributes
WorkflowExecutionStartedalways the first event in a workflow execution event historyinput
WorkflowExecutionCompletedindicates that the workflow execution has successfully completedresult
WorkflowExecutionFailedindicates that the workflow execution has unsuccessfully completed with errorfailure
WorkflowExecutionCanceledindicates that the workflow execution has been canceleddetails
WorkflowExecutionTerminatedindicates that the workflow execution has been terminatedreason
ActivityTaskScheduledindicates that the activity task has been scheduledinput
ActivityTaskStartedindicates that the activity task has startedlast_failure
ActivityTaskCompletedindicates that the activity task has completedresult
ActivityTaskCancelRequestedindicates that a request has been made to cancel the activity task
ActivityTaskCanceledindicates that the activity task has been canceled
ActivityTaskFailedindicates that the activity task has failedfailure
FormTaskScheduledindicates that the form task has been scheduledinput
FormTaskStartedindicates that the form task has startedworkflow_id, workflow_run_id
FormTaskCompletedindicates that the form task has completedresult
FormTaskFailedindicates that the form task has failedfailure
RecoverTaskScheduledindicates that the recover task has been scheduledinput
RecoverTaskStartedindicates that the recover task has startedworkflow_id, workflow_run_id
RecoverTaskCompletedindicates that the recover task has completedresult
RecoverTaskFailedindicates that the recover task has failedfailure
CallActivityTaskScheduledindicates that the callActivity task has been scheduledinput
CallActivityTaskStartedindicates that the callActivity task has startedworkflow_id, workflow_run_id
CallActivityTaskCompletedindicates that the callActivity task has completedresult
CallActivityTaskFailedindicates that the callActivity task has failedfailure

Tracking Workflow Execution History

To track the workflow execution history, make a GET HTTP request to {WFM_URL}/v1/workflow/{workflow_id} which returns the history of the workflow execution states up to the current state.

Example API response
{
"data": [
{
"event_type": "WorkflowExecutionStarted",
"timestamp": "2024-10-24T10:47:35.14814Z",
"attributes": {
"input": [
{
"States": []
}
]
}
},
{
"event_type": "ActivityTaskScheduled",
"timestamp": "2024-10-24T10:47:35.160881Z",
"task_name": "example",
"task_type": "ExampleActivity",
"attributes": {
"input": [
"Hello"
]
}
},
{
"event_type": "ActivityTaskStarted",
"timestamp": "2024-10-24T10:47:35.165684Z",
"task_name": "example",
"task_type": "ExampleActivity"
},
{
"event_type": "ActivityTaskCompleted",
"timestamp": "2024-10-24T10:47:35.166853Z",
"task_name": "example",
"task_type": "ExampleActivity",
"attributes": {
"result": [
"Hello"
]
}
},
{
"event_type": "WorkflowExecutionCompleted",
"timestamp": "2024-10-24T10:53:02.343729Z",
"attributes": {
"result": [
{
"example_input": "Hello",
"Result_example": "Hello"
}
]
}
}
],
"sent_at": "2024-10-30T09:37:27Z",
"page": {
"number": 1,
"size": 5,
"total_records": 5,
"count": 5,
"sort": [
""
]
}
}

The API is paginated, so you can get the history of the workflow execution states by specifying the page number and page size as well as you can sort the timestamp in ascending or descending order.

For example, if you want to get the last event of the workflow execution history, you can specify the path parameter with {WFM_URL}/v1/workflow/{workflow_id}?page=1&size=1&sort=timestamp,desc.

Example API response
{
"data": [
{
"event_type": "WorkflowExecutionCompleted",
"timestamp": "2024-10-24T10:53:02.343729Z",
"attributes": {
"result": [
{
"example_input": "Hello",
"Result_example": "Hello"
}
]
}
}
],
"sent_at": "2024-10-30T09:37:27Z",
"page": {
"number": 1,
"size": 1,
"total_records": 5,
"count": 1,
"sort": [
"timestamp desc"
]
}
}

Based on the event type in the response, you can create the corresponding event handler user interface.