Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is_resolution built in filter is missing #2459

Closed
nikkictl opened this issue Nov 29, 2018 · 2 comments
Closed

is_resolution built in filter is missing #2459

nikkictl opened this issue Nov 29, 2018 · 2 comments

Comments

@nikkictl
Copy link

nikkictl commented Nov 29, 2018

is_resolution logic exists in event.go

"is_resolution": e.IsResolution(),

func (e *Event) IsResolution() bool {
if !e.HasCheck() {
return false
}
// Try to retrieve the previous status in the check history and verify if it
// was a non-zero status, therefore indicating a resolution. The current event
// has already been added to the check history by eventd so we must retrieve
// the second to the last
return (len(e.Check.History) > 1 &&
e.Check.History[len(e.Check.History)-2].Status != 0 &&
!e.IsIncident())
}

but is not implemented in filter.go
switch filterName {
case "is_incident":
// Deny an event if it is neither an incident nor resolution.
if !event.IsIncident() && !event.IsResolution() {
logger.WithFields(fields).Debug("denying event that is not an incident/resolution")
return true
}
case "has_metrics":
// Deny an event if it does not have metrics
if !event.HasMetrics() {
logger.WithFields(fields).Debug("denying event without metrics")
return true
}
case "not_silenced":
// Deny event that is silenced.
if event.IsSilenced() {
logger.WithFields(fields).Debug("denying event that is silenced")
return true
}
default:
// Retrieve the filter from the store with its name
ctx := types.SetContextFromResource(context.Background(), event.Entity)
filter, err := p.store.GetEventFilterByName(ctx, filterName)
if err != nil {
logger.WithFields(fields).WithError(err).
Warning("could not retrieve filter")
return false
}

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
Copy link
Author

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
Copy link
Contributor

IsResolution() method is used in a couple of places (e.g.

if !event.HasCheck() || !event.IsResolution() {
) 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants