# Apply alert fatigue filter on continuous failing event subsequence

**URL:** <https://discourse.sensu.io/t/apply-alert-fatigue-filter-on-continuous-failing-event-subsequence/2070>\
**Category:** Sensu Go\
**Tags:** filter\
**Created:** [September 30, 2020, 6:16am UTC](https://discourse.sensu.io/t/apply-alert-fatigue-filter-on-continuous-failing-event-subsequence/2070 "2020-09-30T06:16:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![GeorgeHe](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/georgehe/32/473_2.png) [@GeorgeHe](https://discourse.sensu.io/u/GeorgeHe)\
**Post date:** [September 30, 2020, 6:16am UTC](https://discourse.sensu.io/t/apply-alert-fatigue-filter-on-continuous-failing-event-subsequence/2070/1 "2020-09-30T06:16:22Z")

</div>

## Feature Suggestion

We are researching to use sensu-go observability pipeline as an alert service. So call api to only generate Failing event to inpuPreformatted textt data. There is no Passing event being input to pipeline. So we don’t know the fixed interval of check as well.  
Alert fatigue strategy we need:

- Alert when occurrences == 3
- Avoid duplicated alert in one hour/day

## Possible Implementation

I found [handle\_when](https://docs.sensu.io/sensu-enterprise/latest/filters/handle-when/#handlewhen-attributes) filter maybe can implement similar function. But it seems not possible in Sensu-Go when [migrate from sensu core](https://docs.sensu.io/sensu-go/latest/operations/maintain-sensu/migrate/#filters).  
Could you offer and describe some other solutions if existed.

## Context

This is my create event request body:

```auto
{
    "entity": {
        "entity_class": "proxy",
        "metadata": {
            "name": "{{$someHost}}",
            "namespace": "default"
        }
    },
    "check": {
        "issued": {{$timestamp}},
        "executed": {{$timestamp}},
        "output": "Server error",
        "state": "failing",
        "status": 2,
        "handlers": [
            "email"
        ],
        "metadata": {
            "name": "urlWatch",
            "labels":{
                "serverTypeId": "131",
                "zoneType": "URL Watch Zone"
            },
            "annotations":{
                "fatigue_check/occurrences": "4",
                "fatigue_check/interval": "600",
                "fatigue_check/allow_resolution": "false"
            }
        }
    },
    "timestamp": {{$timestamp}}
}

```

---

<div class="post-metadata">

**Author:** ![GeorgeHe](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/georgehe/32/473_2.png) [@GeorgeHe](https://discourse.sensu.io/u/GeorgeHe)\
**Post date:** [September 30, 2020, 6:17am UTC](https://discourse.sensu.io/t/apply-alert-fatigue-filter-on-continuous-failing-event-subsequence/2070/2 "2020-09-30T06:17:19Z")

</div>

Github issue link: [https://github.com/sensu/sensu-go/issues/4025](https://github.com/sensu/sensu-go/issues/4025)

---

<div class="post-metadata">

**Author:** ![jspaleta](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/jspaleta/32/141_2.png) [@jspaleta](https://discourse.sensu.io/u/jspaleta)\
**Post date:** [November 11, 2020, 8:37am UTC](https://discourse.sensu.io/t/apply-alert-fatigue-filter-on-continuous-failing-event-subsequence/2070/3 "2020-11-11T08:37:01Z")

</div>

Hey!

This is an interesting use case. Have you thought about creating your own javascript filter asset and having it compare the check history status and timestamps? You can extend filters by providing your own javascript based runtime assets. And you can share those assets via Sensu Bonsai.

The Sensu Go event model records the return status and timestamp in the check history attribute, for up to the last 20 check executions I believe. So it should be possible for you to use that information in a javascript asset to implent the filter logic you need.

We don’t have a javascript filter asset template repository yet (we need need to put one together to help people get started with building their own filter assets) But if you want to look at an example of a javascript filter asset, take a look at:  
[https://github.com/nixwiz/sensu-go-fatigue-check-filter](https://github.com/nixwiz/sensu-go-fatigue-check-filter)

Hopefully this helps.
