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

Support sending non-state notifications without an incident #188

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

yhabteab
Copy link
Member

@yhabteab yhabteab commented Apr 25, 2024

Facilitates sending non-state notifications even without an active incident. See the individual commits separately for the details of why something was changed and most of them also contain their own reasons.

resolves #106
closes #137

@cla-bot cla-bot bot added the cla/signed CLA is signed by all contributors of a PR label Apr 25, 2024
@yhabteab yhabteab force-pushed the yhabteab/support-non-state-notification-types branch from 0431265 to 62d1ceb Compare April 25, 2024 15:24
@yhabteab yhabteab force-pushed the send-incident-non-state-notifications branch 2 times, most recently from 796ff00 to 0ff79aa Compare April 26, 2024 10:19
@yhabteab yhabteab force-pushed the yhabteab/support-non-state-notification-types branch 5 times, most recently from c2743ba to 8ba8889 Compare April 26, 2024 15:30
@yhabteab yhabteab force-pushed the yhabteab/support-non-state-notification-types branch 3 times, most recently from b7dd933 to 68811f7 Compare May 8, 2024 14:44
@yhabteab yhabteab requested review from oxzi and julianbrost and removed request for julianbrost May 8, 2024 14:45
@yhabteab
Copy link
Member Author

yhabteab commented May 8, 2024

Please review concept and functionality, but be aware that there is no corresponding web PR yet.

@yhabteab yhabteab force-pushed the send-incident-non-state-notifications branch from 8c380a1 to e2269d2 Compare May 13, 2024 12:27
Base automatically changed from send-incident-non-state-notifications to main May 13, 2024 15:45
yhabteab and others added 11 commits May 15, 2024 11:20
We don't need to pass this info around methods since we can easily
determine whether an incident is new based on its `StartedAt` timestamp.

Co-Authored-By: Sukhwinder Dhillon <sukhwinder.dhillon@icinga.com>
We're going to use this recipient channels map elsewhere outside the
`incident` package in the future and it seems reasonable to me to move
it here to the `rule` package.
In the upcoming commits, this will also be used elsewhere.
In the upcoming commits, this will also be used elsewhere.
…t.Key`

This allows us to use `zap.Inline(escalation)` or
`zap.Object("escalation", escalation)`wherever more logging context is
needed without having to add all the individual fields ourselves each
time.
It will be used to determine non-state notification recipients without
an incident.
Given that these configs are user-configurable, they need to be loaded
regulary from the database just like the other types. I have also
already taken careful consideration to deduplicate as much code as
possible.
…ror type

Otherwise, we will have a cyclic import error with the upcoming changes
to non-state event processing support. They kind of also fit into this
package.
It was already quite annoying having to return `types.Int` every single
time this method was used. This commit embeds the functionality for
`insert and fetch ID` directly into the `HistoryRow` type and nowhere
needs to be returned. The just inserted and fetched ID can be accessed
with `history.ID`.
I also replaced `errors` with `github/pkg/errors` package, is it was
quite challenging to track down the errors, as we only get messages
without stack traces with the standard errors package.
yhabteab and others added 4 commits May 15, 2024 11:20
The `incident_event` table is now obsolete and is no longer required,
and the `incident#ProcessEvent()` method has been replaced by the new
`events.Router` type.
Co-Authored-By: Sukhwinder Dhillon <sukhwinder.dhillon@icinga.com>
@yhabteab yhabteab force-pushed the yhabteab/support-non-state-notification-types branch from 68811f7 to 11b142c Compare May 15, 2024 09:20
internal/rule/rule.go Show resolved Hide resolved
internal/rule/rule.go Show resolved Hide resolved
Comment on lines +66 to +77
if i != nil {
if err := i.ProcessEvent(ctx, ev); err != nil {
if errors.Is(err, event.ErrSuperfluousStateChange) {
return err
}

// Expect the actual error to be logged with additional context in the incident package.
return event.ErrEventProcessing
}

return nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if an Incident exists, the other rules aren't even considered? That shouldn't be the case, if you configure that you want to be notified about downtimes, you should be notified about all of them.

@yhabteab yhabteab removed the request for review from oxzi May 17, 2024 07:46
@yhabteab yhabteab marked this pull request as draft May 17, 2024 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla/signed CLA is signed by all contributors of a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support other notification types
2 participants