5 Replies Latest reply on Jun 17, 2014 4:20 AM by pilhuhn

    Customizing email alert message body

    raylite3

      Hello,

       

      Is there a way to customize the message body in an email alert? For example, when the call time for a EJB method invocation exceeds a threshold, I want to include the caller principal as well since it will help in troubleshooting. Can I insert my own class to do the sending?

      Thanks in advance.

        • 1. Re: Customizing email alert message body
          mazz

          The alert template text file can be modified by editing this file:

           

          <server-install-dir>/modules/org/rhq/server-startup/main/deployments/rhq.ear/rhq-server.jar/alert-email-template.txt

           

          Not sure if there is a way to inject the data you want though - what "caller principal" are you asking for? I don't think there is any user information replacement token to use.

          • 2. Re: Customizing email alert message body
            mazz

            BTW: the class that takes that template and replaces the @@@ tokens is org.rhq.enterprise.server.core.EmailManagerBean in the modules/enterprise/server/jar module - if there is some enhancement you think you can code up, create a pull request and the team can take a look.

            • 3. Re: Customizing email alert message body
              raylite3

              Right, there isn't information about the caller principal to do the replacement. We have java standalone applications (that end users login to) making remote EJB invocations and I wanted to include information about the end user's login for troubleshooting. If I use a log event source, I can probably get this information though (for example, I can log a message saying "Call to saveXYZ by 'abc' took NNN millis" ). Can I then write my own AlertSender subclass perhaps and customize the message body?

              • 4. Re: Customizing email alert message body
                genman

                I think for log events, the email should contain the actual log event message.

                • 5. Re: Customizing email alert message body
                  pilhuhn

                  I've created a pull-request ( Allow to use an email template instead of the default. by pilhuhn · Pull Request #56 · rhq-project/rhq · GitHub ) from some changes I had hanging around on disk, which allow to use templates for the EmailSender alert sender plugin.

                  This does not yet cover the Subject and Roles senders.

                  It also does not allow to specify more stuff than what is currently available for the normal Template.

                   

                  To enhance this, look at org.rhq.enterprise.server.alert.AlertManagerBean#sendAlertNotificationEmails and org.rhq.enterprise.server.core.EmailManagerBean