sensu / sensu-go

Simple. Scalable. Multi-cloud monitoring.
https://sensu.io
MIT License
1.02k stars 175 forks source link

is_resolution built in filter is missing #2459

Closed nikkictl closed 5 years ago

nikkictl commented 5 years ago

is_resolution logic exists in event.go https://github.com/sensu/sensu-go/blob/e3421f7ed050bfb3310f83a28aed5b9d85b4be64/api/core/v2/event.go#L113 https://github.com/sensu/sensu-go/blob/e3421f7ed050bfb3310f83a28aed5b9d85b4be64/api/core/v2/event.go#L84-L96 but is not implemented in filter.go https://github.com/sensu/sensu-go/blob/95acb053dcc16a9eaa3d9faaacad8df707cccc74/backend/pipelined/filter.go#L101-L128

We should add the follow case to filter.go so users can invoke the built-in is_resolution filter. We should also document this filter.

case "is_resolution":
    // Deny event that is not a resolution.
    if !event.IsResolution() {
        logger.WithFields(fields).Debug("denying event that is not a resolution")
        return true
    }
nikkictl commented 5 years ago

It appears is_incident filters resolution events, so if that is the preferred terminology, perhaps we should remove the is_resolution key from event.go?

palourde commented 5 years ago

IsResolution() method is used in a couple of places (e.g. https://github.com/sensu/sensu-go/blob/15b4e2e48a3ef7804938875b4503e9435a6feae5/backend/eventd/silenced.go#L75) and it's not the same as !IsIncident() so I feel like it's still relevant to have that. That being said, maybe it could be exposed as a built-in filter if required.