Skip to content

Golang Lambda Function for sending RDS metrics to Slack

Notifications You must be signed in to change notification settings

AlyRagab/LambdaFunc-rds-alert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LambdaFunc-rds-alert

Golang Lambda Function for sending RDS Metrics to Slack, The Flow as below :

Steps :

  • Create the RDS instance :
aws rds create-db-instance \
    --db-instance-identifier $INSTANCE_NAME \
    --db-instance-class $CLASS_NAME \
    --engine mysql \
    --master-username $USER_NAME \
    --master-user-password $PASSWORD \
    --allocated-storage 50
  • Create the SNS topic :
aws sns create-topic --name rds
aws sns subscribe --topic-arn $TOPIC_ARN --protocol lambda --notification-endpoint $LAMBDA_ARN
  • Create the CloudWatch Alarm :
aws cloudwatch put-metric-alarm --alarm-name "HighCPUUtilization"  --alarm-description "High CPU Utilization" \
--actions-enabled  \
--alarm-actions "$ROLE_ARN"  \
--metric-name "CPUUtilization"  \
--namespace AWS/RDS --statistic "Average" \
--period 60  \
--evaluation-periods 60  \
--threshold 70  \
--comparison-operator "GreaterThanOrEqualToThreshold"
  • Build it :
go build -o main main.go
zip deployment.zip main
  • Create the Lambda Function :
aws lambda create-function --function-name rds-slack \
--zip-file fileb://./deployment.zip \
--runtime go1.x --handler main \
--role $ROLE_ARN \
--environment Variables={SLACK_WEBHOOK=""}

About

Golang Lambda Function for sending RDS metrics to Slack

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages