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 custom alertmanager go template to enhance email config #1721
Add custom alertmanager go template to enhance email config #1721
Conversation
Hi @Priyankasaggu11929. Thanks for your PR. I'm waiting for a integr8ly member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/assign @laurafitzgerald Please review. Thanks! |
c18c4a1
to
13f9e47
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
cdca6e3
to
0e7a935
Compare
Hi @laurafitzgerald just to add, the following is the solution as to how we have customized the alertmanager email output and some field of the pagerduty output. Assuming an
Challenge:
Solution:
|
@Priyankasaggu11929 thanks for the pr. 👏 This change should get visibility of more than one engineer on the team. Could you also share it to either rhoam engineering or customer success team channel for visibility. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pepedocs @Priyankasaggu11929 One small issue above and a question. Do you think there is any risk in the new email template being incompatible with newer versions of AlertManager?
|
||
// For OpenShift console | ||
grafanaRouteName = "grafana-route" | ||
grafanaRouteNamespace = "redhat-rhoam-middleware-monitoring-operator" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Priyankasaggu11929 We need to consider RHMI here. The namespace may be "redhat-rhmi-middleware-monitoring-operator" You can probably use "config.getOperatorNamespace()"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm testing for the grafana route by passing the namespace value using config.getOperatorNamespace()
, in place of creating a constant variable like above grafanaRouteNamespace
. It's working fine in the reconciler.go file (L807-L810) & I'm able to verify changes in the alertmanager config.
grafanaRoute := &routev1.Route{}
if err := serverClient.Get(context.TODO(), types.NamespacedName{Name: grafanaRouteName, Namespace: r.Config.GetOperatorNamespace()}, grafanaRoute); err != nil {
return integreatlyv1alpha1.PhaseFailed, fmt.Errorf("failed to fetch OpenShift console URL details for alertmanager config: %w", err)
}
But, I'm unable to find out a way to use the same function, config.getOperatorNamespace()
, in reconciler_test.go (L414-L422) file. Could you suggest how I can do that?
grafanaRoute := &routev1.Route{
ObjectMeta: metav1.ObjectMeta{
Name: grafanaRouteName,
Namespace: <THIS_PLACE_HOLDER>,
},
Spec: routev1.RouteSpec{
Host: "example-grafana.com",
},
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the test, just hardcode in a relevant namespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard-coding the grafana route namesapce in reconciler_test.go
file is failing one of the unit-test defined here.
For now, I have rebased the branch with upstream master & removed grafana route changes from all the files it was referenced. I've testing it again on a staging OSD cluster & it's working fine for me.
I'll raise a separate PR for the grafana route changes once this is merged.
Confirmed on cluster with RHOAM install. |
Sorry forgot to add mention. @briangallagher
Yes but if that happens that would also break all current assumptions about writing a custom template. We basically just duplicated the default template and then modified some areas that will contain cluster-specific info. If AM deprecates a template variable and make it unusable for example, this will break the custom template we made here, but all users of this variable will also get affected, hence it'd be unlikely. Apart from this risk, I don't see anything else TBH. |
0e7a935
to
5290159
Compare
5290159
to
f19befe
Compare
/ok-to-test |
@Priyankasaggu11929: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@briangallagher @laurafitzgerald, could any of you please mark the PR Thank you! |
/ok-to-test |
Hi @briangallagher, just re-iterating. All the prow tests passed successfully. Is it fine to merge now? Thank you. |
/lgtm Verified based on above steps |
@Priyankasaggu11929 The PR is blocked from merging due to the ongoing release. As soon as that blocking JIRA is remove (release complete) you can ask one of the approvers to approve |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: pmccarthy The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
…alertmanager-email-template Add custom alertmanager go template to enhance email config
…alertmanager-email-template Add custom alertmanager go template to enhance email config
…alertmanager-email-template Add custom alertmanager go template to enhance email config
Description
The PR make changes to add a custom alertmanager go template (as a second data item in the
alertmanager-application-monitoring
secret). The new custom go template is aiming to enhance the pre-existing email configuration.Related JIRA ticket: https://issues.redhat.com/browse/MGDAPI-1580
Files updated:
pkg/products/monitoring/reconciler.go
pkg/products/monitoring/reconciler_test.go
pkg/products/monitoring/templateHelper.go
templates/monitoring/alertmanager/alertmanager-email-config.tmpl
~ (New alertmanager custom go template)templates/monitoring/alertmanager/alertmanager-application-monitoring.yaml
Steps to verify changes
RHOAM
using this PR branch.Subject: '{{template "email.integreatly.subject" . }}'
html: '{{ template "email.integreatly.html" . }}'
description: '{{template "email.integreatly.subject" . }}'
cluster_ID: <cluster-id>
cluster_name: <cluster-name>
console: <console-url>
grafana: <grafana-url>
pkg/products/monitoring/...
are passing:command: ~
go test -v -coverprofile cover.out ./pkg/products/monitoring/...
The final result of the above changes would look like:
In Email:
Following is the new email subject format:
Type of change
Checklist