# Detect failure in workflow

**URL:** https://community.temporal.io/t/detect-failure-in-workflow/15365
**Category:** Community Support
**Tags:** python-sdk, error-handling, activity
**Created:** [November 25, 2024, 8:02pm UTC](https://community.temporal.io/t/detect-failure-in-workflow/15365 "2024-11-25T20:02:46Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Weixi\_Wu](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/weixi_wu/32/6409_2.png) [@Weixi\_Wu](https://community.temporal.io/u/Weixi_Wu)
#### Post date: [November 25, 2024, 8:02pm UTC](https://community.temporal.io/t/detect-failure-in-workflow/15365/1 "2024-11-25T20:02:47Z")

</div>

Hi,

I am trying to detect errors in workflow and get alarms, which can be either non-determinism error or activities retry exceed N attempts.

Is there any easy way to achieve this goal in python-sdk?

---

<div class="post-metadata">

### Author: ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)
#### Post date: [December 1, 2024, 7:25pm UTC](https://community.temporal.io/t/detect-failure-in-workflow/15365/2 "2024-12-01T19:25:38Z")

</div>

> which can be either non-determinism

worker metric `temporal_workflow_task_execution_failed`

> or activities retry exceed N attempts

worker metrics do have temporal\_activity\_execution\_failed, but for specific requirement (exceed N attempts)  
you will need to get attempt count via api in your activity code and if its \> X increment custom counter metric
