What is the best way to get the number of executed activities (metrics, historic queries, other)?

Hello everyone,
I am analyzing the possibility to see how many activities have been invoked in a given interval in a given namespace. Or put another way, how many tasks have been executed?

Is it possible by examining the metrics? For example with the metric “task_requests”.

Another possible solution I can think of is to examine the history of a workflow and then run an aggregation, but I don’t know if this is the best way to do it.

Is it possible to achieve my purpose without adding advanced search capabilities (elasticsearch)?

Thanks

If you have SDK metrics running, you could use the

temporal_request_total

metric and filter it by activity_type=“MyActivityType” and namespace=“MyNameSpace”, and operation=“RespondActivityTaskCompleted”, (can filter by workflow_type and task queue as well)

This is a counter metric tho.

For histogram you could use temporal_request_latency_seconds I believe and filter on activity_type and task_queue and same operation. This data should be also reported via the activity_end_to_end_latency_bucket metric on server metrics.

Thank you Tihomir,

Actually, I was trying to avoid metrics at the SDK level as not something that I can control 100% (a clever developer might not enable metrics or not use the official Temporal SDK).

That’s why I’m exploring mechanisms to get this type of metric using only the Temporal server.

:wink:

Looking at just server metrics you should be able to use service_requests metric on history service:

For example following Grafana queries:

Started Activities:

sum(rate(service_requests{temporal_service_type=“history”,operation=“RecordActivityTaskStarted”}[2m]))

Completed Activities:

sum(rate(service_requests{temporal_service_type="history",operation=~"RespondActivityTaskCompleted|RespondActivityTaskFailed|RespondActivityTaskCanceled"}[2m]))

Sounds great Tihomir, something like that works for me :wink: