Forum Discussion

Brandon's avatar
5 years ago

Automatic discovery of recipients/groups

We have begun implementing a tagging standard in our cloud accounts to better control discovered resources and route alerts accordingly.  I would like to be able to route alerts by default based on the value of a tag.  I'm aware that I can already set up specific users and then achieve exactly what I'm requesting, but I would much prefer to have a blanket rule that uses the tag's value as the recipient email address(es) directly.  Some examples below:

system.aws.tag.MonitorAlertEmail=ThisIsAnExample@PleaseOfferThisFeature.com

system.aws.tag.SendAlertsHere=AnotherExcellentExample@WeWillPayExtraForThisFunctionality.gov AnotherEmailAddress@OkayNotReally.net

See the screenshots below for a visual example of how I'd like to structure this automation.

 

1 Reply

  • Hi Brandon,

    I think LogicMonitor does not have feature to send notification based on AWS tag like owner name etc. but it can discover it. You can create small solution using AWS API Gateway, Lambda and SES. I have done it for testing purpose and was working fine.

    Flow would be:

    Alert Rule -->Escalation Chain -->HTTP JSON integration (POST) --> AWS API getaway --> Lambda function (python or Node.js) --> SES services.

    Below is simple python code for this.

    Quote


    import json
    import boto3
    import re 
    from botocore.exceptions import ClientError

    def lambda_handler(event, context):

            # Replace sender@example.com with your "From" address.
            # This address must be verified with Amazon SES.
            SENDER = "sender@yourcompany.com"
            # Make a regular expression 
            # For validating an Email 
            regex = '^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,3}$'
            # Replace recipient@example.com with a "To" address. If your account 
            # is still in the sandbox, this address must be verified.
            if(re.search(regex,event['recipient'].strip())):
                RECIPIENT = event['recipient']
            else:
                RECIPIENT="defaultemail@yourcompany.com >"
           
            AWS_REGION = "ap-south-1"
             # The subject line for the email.
            SUBJECT = "LogicMonitor " + event['level'] + " " + event['hostname'] 
            
            # The email body for recipients with non-HTML email clients.
            BODY_TEXT = ("LogicMonitor Genrated Mail\r\n"
                         "This email was sent for threshold breach "
                         "on your system."
                        )
                        
            # The HTML body of the email.
            BODY_HTML = """<html>
            <head></head>
            <body>
              <h1>LogicMonitor Alert</h1>
              <p>
              <table style="width:100%">
              <tr>
              <td>Hostname</td>
              <td>"""+event['hostname']+"""</td>
              </tr>
              <tr>
              <td>Alert Message</td>
              <td>"""+event['message']+"""</td>
              </tr>
              <tr>
              <td>Start Time</td>
              <td>"""+event['start']+"""</td>
              </tr>
              </table>
              </p>
            </body>
            </html>

     

    LogicMonitor HTTP integration screenshot