How to watch all workflow's events inside a namespace?

I find GetWorkflowHistory can only watch one workflow. But I want to get notified when any workflow completed inside the specified namespace. So what should I do?

Thank you for your help!

Through SDK you can get per workflow type counter metrics:

temporal_workflow_completed
temporal_workflow_canceled
temporal_workflow_failed
temporal_workflow_continue_as_new

You can filter those by namespace, workflow_type and task_queue attributes.

You can also emit custom metrics from your workflow code if you want. If cannot use metrics, another option could be activity that runs right before workflow completes that sends this notification.

What is your use case that requires such functionality?

@tihomir
Using metrics may be a way to get notification. But it seems that I have to listen to prometheus (or other stats system) to get notified, and can’t get which workflow is finished directly.

@maxim
I’m trying to porting an existing DSL based workflow system to Temporal. We have a feature that the web ui can watch all running workflows and update their state in almost realtime.
Sending notification in a workflow activity is a potential solution. But I found temporal sdk can long poll a single workflow history, so ask here to get some advices.

I see. At this point periodically querying the workflows that are currently shown in the UI is the best option that doesn’t involve a separate notification subsystem.

In the future, we are planning to provide a way for workflows to post notifications that could be listened to.

Hello Maxim,

Is there a GitHub issue on the workflow notifications/listener feature that could be followed / voted for (couldn’t find it) ? Just for our planning, is it something that is going to be implemented soon ?

We would need this functionality to persist workflow/activity lifecycle events to our own database to be queried later.

Thanks

I don’t think there is an issue. Feel free to file one.

Issue created: Workflows/activities to post event notifications that could be listened to · Issue #3709 · temporalio/temporal · GitHub