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

Add ability to update in comments (now configurable per receiver) #180

Merged
merged 3 commits into from
Feb 5, 2024

Conversation

twotired
Copy link
Contributor

As an alternative, or as an addition to updating the Description, additional Alert updates should go to comments.

The default behavior is to update the JIRA Description when the Alert details change. This makes it difficult if the viewers of the JIRA are researching each failure because it is not obvious which alerts are new or existing. Depending on the Alert expression, old firing details may also be removed.

Additionally, adding too many firing details to the description increases the likelihood of exceeding the 32KB char limit for the JIRA Description.

By optionally sending each update to a Comment, viewers can better keep track of which activity is new, and it will be possible to continue adding firing details without exceeding the Description char limit.

resolves #160

@twotired
Copy link
Contributor Author

@bwplotka @MytkoEnko @cropalato @holger-waschke

Please review this new PR for adding updates in comments with better configurability and additional tests.

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Epic work! One blocking question and some nits, otherwise LGTM, thanks 💪🏽

@@ -47,6 +47,36 @@ func (s *Secret) UnmarshalYAML(unmarshal func(interface{}) error) error {
return unmarshal((*plain)(s))
}

// NullBool will be used for boolean configuration values that should not
// default to false when undefined and the default setting is true.
type NullBool struct {
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need this? None of other boolean flags required this. Essentially if default is false, it's not needed, right? And we plan to use default false at the moment 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we use a normal bool and the user sets the value to true in the defaults section, and leaves it blank in the receiver configs, the receiver config setting will actually be interpreted as false. By using NullBool, we are able to honor the global setting in the defaults section, which to me, seems more intuitive than allowing users to specify a default setting that does not actually change the behavior of the application.

Copy link
Member

Choose a reason for hiding this comment

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

Got it, thanks--good point about that logic. However wouldn't using *bool fix the problem. Also if we fix it for this field let's do this for all bools that can be in default fields for consistency.

Alternatively we could make it a bool (and accept the bug) and move those bools to *bool or your struct in separate PR, wdyt? I would love to avoid complexity of some fields of the same type having different logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated the PR to use bool* instead of NullBool and applied the same logic to AddGroupLabels so that default will be honored.

numComments = len(issue.Fields.Comments.Comments)
}
if numComments > 0 && issue.Fields.Comments.Comments[(numComments-1)].Body == issueDesc {
// if the new comment is identical to the most recent comment,
Copy link
Member

Choose a reason for hiding this comment

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

nice 👍🏽

pkg/notify/notify.go Outdated Show resolved Hide resolved
@holger-waschke
Copy link
Contributor

That looks good, I will test it in our environment soon.

One idea would be to provide a seperate template for the comments. per example in our case we only want to post the annotations but not the labels as comment.

@twotired
Copy link
Contributor Author

That looks good, I will test it in our environment soon.

@holger-waschke any problems discovered in testing?

@holger-waschke
Copy link
Contributor

Yes it works just fine.

One issue we faced were too long comments, as we have dozen of static labels. I added some code to cut anything but the annotations, this is were changes occur in our case. But that's not suitable for everyone, you think it's a good idea to implement a template which applies only for comments?

Copy link

@cropalato cropalato left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM, just two comments.

Thanks all for reviews!

pkg/notify/notify.go Outdated Show resolved Hide resolved
@@ -47,6 +47,36 @@ func (s *Secret) UnmarshalYAML(unmarshal func(interface{}) error) error {
return unmarshal((*plain)(s))
}

// NullBool will be used for boolean configuration values that should not
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// NullBool will be used for boolean configuration values that should not
// NullBool will be used for boolean configuration values that can have 3 values: true, false and unspecified.

Copy link
Member

Choose a reason for hiding this comment

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

Can we simply use *bool instead though?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -47,6 +47,36 @@ func (s *Secret) UnmarshalYAML(unmarshal func(interface{}) error) error {
return unmarshal((*plain)(s))
}

// NullBool will be used for boolean configuration values that should not
// default to false when undefined and the default setting is true.
type NullBool struct {
Copy link
Member

Choose a reason for hiding this comment

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

Got it, thanks--good point about that logic. However wouldn't using *bool fix the problem. Also if we fix it for this field let's do this for all bools that can be in default fields for consistency.

Alternatively we could make it a bool (and accept the bug) and move those bools to *bool or your struct in separate PR, wdyt? I would love to avoid complexity of some fields of the same type having different logic.

twotired and others added 2 commits February 3, 2024 09:25
Co-authored-by: Bartlomiej Plotka <[email protected]>
Signed-off-by: Jason Wells <[email protected]>
@twotired
Copy link
Contributor Author

twotired commented Feb 5, 2024

@bwplotka please review... I switched from NullBool to bool*

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Nice, much better!

@bwplotka bwplotka merged commit d43cbab into prometheus-community:master Feb 5, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

Send additional Alert updates to Comments
4 participants