Skip to content

feat(alerting): Make email alert provider e-mail customizable #1119

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

imrelaszlo
Copy link
Contributor

Summary

Now, we can override e-mail messages texts via provider-override settings, like this:

        provider-override:
          text-email-subject-triggered: "E-mail subject when triggered: {endpoint}"
          text-email-subject-resolved: "E-mail subject when resolved: {endpoint}"
          text-email-body-triggered: "E-mail body when triggered: {endpoint}"
          text-email-body-resolved: "E-mail body when resolved: {endpoint}"
          text-email-description: "Description: {description}"
          text-email-header: "Hello!"
          text-email-footer: "Bye."
          text-include-condition-results: false

All fields are optional, and backwards compatible. You can hide the condition results if needed.

Checklist

  • Tested and/or added tests to validate that the changes work as intended, if applicable.
  • Updated documentation in README.md, if applicable.

@github-actions github-actions bot added the area/alerting Related to alerting label May 27, 2025
subject = fmt.Sprintf("[%s] Alert resolved", ep.DisplayName())
message = fmt.Sprintf("An alert for %s has been resolved after passing successfully %d time(s) in a row", ep.DisplayName(), alert.SuccessThreshold)
if len(cfg.TextEmailSubjectResolved) > 0 {
subject = strings.Replace(cfg.TextEmailSubjectResolved, "{endpoint}", ep.DisplayName(), 1)
Copy link
Owner

Choose a reason for hiding this comment

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

If we're going to implement placeholders, they should be the same as the other placeholders throughout the configuration. See https://github.com/TwiN/gatus?tab=readme-ov-file#configuring-custom-alerts

[ENDPOINT_NAME] (resolved from endpoints[].name)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello! I've used {endpoint} and {description} placeholders i the Twilio provider, too. Should I unify them?
#1120

Comment on lines 34 to 41
TextEmailSubjectTriggered string `yaml:"text-email-subject-triggered,omitempty"`
TextEmailSubjectResolved string `yaml:"text-email-subject-resolved,omitempty"`
TextEmailBodyTriggered string `yaml:"text-email-body-triggered,omitempty"`
TextEmailBodyResolved string `yaml:"text-email-body-resolved,omitempty"`
TextEmailHeader string `yaml:"text-email-header,omitempty"`
TextEmailFooter string `yaml:"text-email-footer,omitempty"`
TextEmailDescription string `yaml:"text-email-description,omitempty"`
TextIncludeConditionResults *bool `yaml:"text-include-condition-results,omitempty"`
Copy link
Owner

Choose a reason for hiding this comment

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

I'm really not sure about this. I'd almost rather have just the subject and the body, and then have a placeholder for the condition results. This would remove the need for the header, the footer, the description and the bool to include/exclude the condition results.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello! I would like to be able to say hello and display information in the footer in the case of an email alert provider, all fields as optional parameter. And everything is backward compatible. Given that not everyone understands the technical details, I would like to optionally hide the condition results section.

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'm really not sure about this. I'd almost rather have just the subject and the body, and then have a placeholder for the condition results. This would remove the need for the header, the footer, the description and the bool to include/exclude the condition results.

Sorry, I just understood exactly what you wanted. I'll edit it and report back with the changes.

@imrelaszlo
Copy link
Contributor Author

Hello @TwiN ! I've updated the code as you requested: imrelaszlo@324d2cd

Copy link
Owner

@TwiN TwiN left a comment

Choose a reason for hiding this comment

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

Perfect! Can you update the README to document the new feature?

@TwiN TwiN changed the title Make email alert provider e-mail customizable feat(alerting): Make email alert provider e-mail customizable May 31, 2025
@TwiN TwiN added the feature New feature or request label May 31, 2025
@imrelaszlo
Copy link
Contributor Author

Perfect! Can you update the README to document the new feature?

Yes, but please be patient, I found a bug and am making a better version, which I will submit as a separate pull request.

@TwiN
Copy link
Owner

TwiN commented Jun 11, 2025

@imrelaszlo Should I close this in favor of #1129?

@imrelaszlo
Copy link
Contributor Author

@imrelaszlo Should I close this in favor of #1129?

Yes, the other solution is much nicer, more capable and more modern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/alerting Related to alerting feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants