Automatic discovery of recipients/groups


Brandon
 Share

Recommended Posts

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.

image.thumb.png.7241611e20d1efc0309564a728833ff4.png

image.thumb.png.927a8b73d4b67a44be1cec05e7ffefd6.png

 

Link to comment
Share on other sites

  • 7 months later...

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 

 

Integration.JPG

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share