SlideShare a Scribd company logo
AWS and Slack Integration
Sending CloudWatch Notifications to Slack
Contents
Objective..................................................................................................................................... 1
AWS CloudWatch ...................................................................................................................... 1
Create an AWS Access Key and Secret...................................................................................... 2
Create a Role............................................................................................................................... 2
Deploy the Lambda function ...................................................................................................... 3
Create an SNS topic and subscription......................................................................................... 7
Create a Cloudwatch Alarm........................................................................................................ 8
Testing AWS Cloudwatch Alarm Notification to Slack........................................................... 10
References:................................................................................................................................ 11
Objective
To create a Proof of Concept project that monitors AWS resources and sends notifications to a
Slack channel in the event of application metrics exceeding threshold limits.
This writing is of February 2021, when the requirement of including this module was raised for
the larger project. As the project starts getting deployed on Amazon AWS, we need continuous
monitoring of the workloads and application metrics. In case of any warnings or errors, suitable
messages should be routed to Slack so that admin or dedicated team members would be notified
and then they can take suitable actions to fix the anomalies.
AWS CloudWatch
CloudWatch enables us to monitor our AWS resources and the applications in real time. It not
only gives us access to metrics, but also creates alarms for specific cases.
To establish this system, following steps were carried out.
 Create an AWS Access Key and Secret
 Create a Role
 Deploy the Lambda function
 Create an SNS topic and subscription
 Create a Cloudwatch Alarm
Create an AWS Access Key and Secret
Prior to getting started with this project, having an account on AWS is required. Secondly, a key-
pair is also needed. Both the prerequisites were already present, hence we can continue to the
next step.
Create a Role
The Role will be used by the Lambda function and requires permission to do certain things.
Type a role name, such as “cloudwatch-to-slack-role,” click on the newly created role in the list
and copy the ARN name. We will use it later during deployment of the Lambda function.
Deploy the Lambda function
To deploy the AWS Lambda function, clone this repository and have Node.js installed on your
local machine.
linux@Docker-Host:/opt$ sudo git clone https://github.com/assertible/lambda-cloudwatch-slack
Cloning into 'lambda-cloudwatch-slack'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 268 (delta 2), reused 0 (delta 0), pack-reused 262
Receiving objects: 100% (268/268), 695.88 KiB | 769.00 KiB/s, done.
Resolving deltas: 100% (131/131), done.
linux@Docker-Host:/opt$ cd /opt/lambda-cloudwatch-slack
linux@Docker-Host:/opt/lambda-cloudwatch-slack$ sudo cp .env.example .env
Open the .env file and fill in the environment variables.
linux@Docker-Host:/opt/lambda-cloudwatch-slack$ sudo vi .env
linux@Docker-Host:/opt/lambda-cloudwatch-slack$ cat .env
#KMS_ENCRYPTED_HOOK_URL= you can use ENCRYPTED_HOOK_URL if you want
UNENCRYPTED_HOOK_URL=https://hooks.slack.com/services/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
AWS_FUNCTION_NAME=cloudwatch-to-slack
AWS_REGION=us-east-2
AWS_ROLE="arn:aws:iam::386222297872:role/cloudwatch-to-slack-role"
AWS_ACCESS_KEY_ID=ABCLMNXYZXYZ
AWS_SECRET_ACCESS_KEY=ABCLMNXYZXYZABCLMNXYZXYZ
linux@Docker-Host:/opt/lambda-cloudwatch-slack$ sudo apt install npm
Now as we are ready to deploy, run the following command in your terminal from the folder
where the repository was cloned:
root@Docker-Host:/opt/lambda-cloudwatch-slack# npm run deploy
> lambda-cloudwatch-slack@0.4.0 deploy /opt/lambda-cloudwatch-slack
> ./scripts/deploy.sh
=> Moving files to temporary directory
=> Running npm ci --production
=> Zipping deployment package
=> Zipping repo. This might take up to 30 seconds
=> Reading zip file to memory
=> Reading event source file to memory
=> Uploading zip file to AWS Lambda us-east-2 with parameters:
{
FunctionName: 'cloudwatch-to-slack',
Code: {
ZipFile: <Buffer 50 4b 03 04 14 00 08 00 08 00 82 80 4c 52 00 00 00 00 00 00 00 00 00 00 00 00 04 00
00 00 2e 65 6e 76 6d 91 4b 6f a3 30 14 85 f7 fc 0a ab 59 13 12 a8 ... 5669872 more bytes>
},
Handler: 'index.handler',
Role: 'arn:aws:iam::386222297872:role/cloudwatch-to-slack-role',
Runtime: 'nodejs12.x',
Description: 'Better Slack notifications for AWS CloudWatch',
MemorySize: 128,
Timeout: 60,
Publish: false,
VpcConfig: { SubnetIds: [], SecurityGroupIds: [] },
Environment: {
Variables: {
UNENCRYPTED_HOOK_URL:
'https://hooks.slack.com/services/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'
}
},
KMSKeyArn: '',
DeadLetterConfig: { TargetArn: null },
TracingConfig: { Mode: null },
Layers: [],
Tags: {}
}
=> Done uploading. Results follow:
{
FunctionName: 'cloudwatch-to-slack',
FunctionArn: 'arn:aws:lambda:us-east-2:386222297872:function:cloudwatch-to-slack',
Runtime: 'nodejs12.x',
Role: 'arn:aws:iam::386222297872:role/cloudwatch-to-slack-role',
Handler: 'index.handler',
CodeSize: 5669922,
Description: 'Better Slack notifications for AWS CloudWatch',
Timeout: 60,
MemorySize: 128,
LastModified: '2021-02-12T16:04:22.752+0000',
CodeSha256: 'ctOhrmjW+SK0phhGvvwVwYjqk7rY1WS6zA/hqbOKbJA=',
Version: '$LATEST',
VpcConfig: { SubnetIds: [], SecurityGroupIds: [], VpcId: '' },
Environment: {
Variables: {
UNENCRYPTED_HOOK_URL:
'https://hooks.slack.com/services/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'
}
},
KMSKeyArn: null,
TracingConfig: { Mode: 'PassThrough' },
MasterArn: null,
RevisionId: '48d25390-16cb-4580-916a-7562aac9c4ea',
Layers: [],
State: 'Active',
StateReason: null,
StateReasonCode: null,
LastUpdateStatus: 'Successful',
LastUpdateStatusReason: null,
LastUpdateStatusReasonCode: null
}
=> All tasks done. Results follow:
{}
root@Docker-Host:/opt/lambda-cloudwatch-slack#
Create an SNS topic and subscription
In AWS web interface, go to the Simple Notification Service.
In the Topics, click Create New Topic, such as “cloudwatch-alarms” for the notification that will
be sent.
Select AWS Lambda as your Protocol and pick the endpoint with the name of your function.
Create a Cloudwatch Alarm
Navigate through Cloudwatch to your AWS account and click Create Alarm.
Chose the metric you would like to monitor, define the alarm configuration and select your SNS
topic name in the Send Notification To section.
Testing AWS CloudWatch Alarm Notification to Slack
Start or choose the AWS resource to monitor, as an ECS container in our case. For testing
purpose, decrease the value of metric suitably.
If everything is configured properly, you will see the message in your Slack channel.
References
Amazon CloudWatch Documentation
https://docs.aws.amazon.com/cloudwatch/index.html
AWS Lambda Documentation
https://docs.aws.amazon.com/lambda/index.html

More Related Content

Similar to AWS and Slack Integration - Sending CloudWatch Notifications to Slack.pdf

Intro to AWS Lambda
Intro to AWS LambdaIntro to AWS Lambda
Intro to AWS Lambda
Sandra Garcia
 
Reusable, composable, battle-tested Terraform modules
Reusable, composable, battle-tested Terraform modulesReusable, composable, battle-tested Terraform modules
Reusable, composable, battle-tested Terraform modules
Yevgeniy Brikman
 
Hands-on Lab: Comparing Redis with Relational
Hands-on Lab: Comparing Redis with RelationalHands-on Lab: Comparing Redis with Relational
Hands-on Lab: Comparing Redis with Relational
Amazon Web Services
 
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
Amazon Web Services Korea
 
Introduction to Apache CloudStack by David Nalley
Introduction to Apache CloudStack by David NalleyIntroduction to Apache CloudStack by David Nalley
Introduction to Apache CloudStack by David Nalley
buildacloud
 
Disaster Recovery Site on AWS - Minimal Cost Maximum Efficiency (STG305) | AW...
Disaster Recovery Site on AWS - Minimal Cost Maximum Efficiency (STG305) | AW...Disaster Recovery Site on AWS - Minimal Cost Maximum Efficiency (STG305) | AW...
Disaster Recovery Site on AWS - Minimal Cost Maximum Efficiency (STG305) | AW...
Amazon Web Services
 
Cutting through the fog of cloud
Cutting through the fog of cloudCutting through the fog of cloud
Cutting through the fog of cloud
Kyle Rames
 
Hands-on Lab: Amazon ElastiCache
Hands-on Lab: Amazon ElastiCacheHands-on Lab: Amazon ElastiCache
Hands-on Lab: Amazon ElastiCache
Amazon Web Services
 
Scalable and Fault-Tolerant Apps with AWS
Scalable and Fault-Tolerant Apps with AWSScalable and Fault-Tolerant Apps with AWS
Scalable and Fault-Tolerant Apps with AWS
Fernando Rodriguez
 
Programming the Physical World with Device Shadows and Rules Engine
Programming the Physical World with Device Shadows and Rules EngineProgramming the Physical World with Device Shadows and Rules Engine
Programming the Physical World with Device Shadows and Rules Engine
Amazon Web Services
 
Hands-on Lab: Migrating Oracle to PostgreSQL
Hands-on Lab: Migrating Oracle to PostgreSQL Hands-on Lab: Migrating Oracle to PostgreSQL
Hands-on Lab: Migrating Oracle to PostgreSQL
Amazon Web Services
 
Amazon ECS Deep Dive
Amazon ECS Deep DiveAmazon ECS Deep Dive
Amazon ECS Deep Dive
Amazon Web Services
 
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel AvivSelf Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
Amazon Web Services
 
AWS Presents: Infrastructure as Code on AWS - ChefConf 2015
AWS Presents: Infrastructure as Code on AWS - ChefConf 2015AWS Presents: Infrastructure as Code on AWS - ChefConf 2015
AWS Presents: Infrastructure as Code on AWS - ChefConf 2015
Chef
 
Scaling Drupal in AWS Using AutoScaling, Cloudformation, RDS and more
Scaling Drupal in AWS Using AutoScaling, Cloudformation, RDS and moreScaling Drupal in AWS Using AutoScaling, Cloudformation, RDS and more
Scaling Drupal in AWS Using AutoScaling, Cloudformation, RDS and more
Dropsolid
 
DevOps, Microservices and Serverless Architecture
DevOps, Microservices and Serverless ArchitectureDevOps, Microservices and Serverless Architecture
DevOps, Microservices and Serverless Architecture
Mikhail Prudnikov
 
Serverless cat detector workshop - cloudyna 2017 (16.12.2017)
Serverless cat detector   workshop - cloudyna 2017 (16.12.2017)Serverless cat detector   workshop - cloudyna 2017 (16.12.2017)
Serverless cat detector workshop - cloudyna 2017 (16.12.2017)
Paweł Pikuła
 
以Device Shadows與Rules Engine串聯實體世界
以Device Shadows與Rules Engine串聯實體世界以Device Shadows與Rules Engine串聯實體世界
以Device Shadows與Rules Engine串聯實體世界
Amazon Web Services
 
AWS IoT 핸즈온 워크샵 - 실습 3. AWS IoT Thing Shadow (김무현 솔루션즈 아키텍트)
AWS IoT 핸즈온 워크샵 - 실습 3. AWS IoT Thing Shadow (김무현 솔루션즈 아키텍트)AWS IoT 핸즈온 워크샵 - 실습 3. AWS IoT Thing Shadow (김무현 솔루션즈 아키텍트)
AWS IoT 핸즈온 워크샵 - 실습 3. AWS IoT Thing Shadow (김무현 솔루션즈 아키텍트)
Amazon Web Services Korea
 
Hands-on Lab - Combaring Redis with Relational
Hands-on Lab - Combaring Redis with RelationalHands-on Lab - Combaring Redis with Relational
Hands-on Lab - Combaring Redis with Relational
Amazon Web Services
 

Similar to AWS and Slack Integration - Sending CloudWatch Notifications to Slack.pdf (20)

Intro to AWS Lambda
Intro to AWS LambdaIntro to AWS Lambda
Intro to AWS Lambda
 
Reusable, composable, battle-tested Terraform modules
Reusable, composable, battle-tested Terraform modulesReusable, composable, battle-tested Terraform modules
Reusable, composable, battle-tested Terraform modules
 
Hands-on Lab: Comparing Redis with Relational
Hands-on Lab: Comparing Redis with RelationalHands-on Lab: Comparing Redis with Relational
Hands-on Lab: Comparing Redis with Relational
 
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
 
Introduction to Apache CloudStack by David Nalley
Introduction to Apache CloudStack by David NalleyIntroduction to Apache CloudStack by David Nalley
Introduction to Apache CloudStack by David Nalley
 
Disaster Recovery Site on AWS - Minimal Cost Maximum Efficiency (STG305) | AW...
Disaster Recovery Site on AWS - Minimal Cost Maximum Efficiency (STG305) | AW...Disaster Recovery Site on AWS - Minimal Cost Maximum Efficiency (STG305) | AW...
Disaster Recovery Site on AWS - Minimal Cost Maximum Efficiency (STG305) | AW...
 
Cutting through the fog of cloud
Cutting through the fog of cloudCutting through the fog of cloud
Cutting through the fog of cloud
 
Hands-on Lab: Amazon ElastiCache
Hands-on Lab: Amazon ElastiCacheHands-on Lab: Amazon ElastiCache
Hands-on Lab: Amazon ElastiCache
 
Scalable and Fault-Tolerant Apps with AWS
Scalable and Fault-Tolerant Apps with AWSScalable and Fault-Tolerant Apps with AWS
Scalable and Fault-Tolerant Apps with AWS
 
Programming the Physical World with Device Shadows and Rules Engine
Programming the Physical World with Device Shadows and Rules EngineProgramming the Physical World with Device Shadows and Rules Engine
Programming the Physical World with Device Shadows and Rules Engine
 
Hands-on Lab: Migrating Oracle to PostgreSQL
Hands-on Lab: Migrating Oracle to PostgreSQL Hands-on Lab: Migrating Oracle to PostgreSQL
Hands-on Lab: Migrating Oracle to PostgreSQL
 
Amazon ECS Deep Dive
Amazon ECS Deep DiveAmazon ECS Deep Dive
Amazon ECS Deep Dive
 
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel AvivSelf Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
 
AWS Presents: Infrastructure as Code on AWS - ChefConf 2015
AWS Presents: Infrastructure as Code on AWS - ChefConf 2015AWS Presents: Infrastructure as Code on AWS - ChefConf 2015
AWS Presents: Infrastructure as Code on AWS - ChefConf 2015
 
Scaling Drupal in AWS Using AutoScaling, Cloudformation, RDS and more
Scaling Drupal in AWS Using AutoScaling, Cloudformation, RDS and moreScaling Drupal in AWS Using AutoScaling, Cloudformation, RDS and more
Scaling Drupal in AWS Using AutoScaling, Cloudformation, RDS and more
 
DevOps, Microservices and Serverless Architecture
DevOps, Microservices and Serverless ArchitectureDevOps, Microservices and Serverless Architecture
DevOps, Microservices and Serverless Architecture
 
Serverless cat detector workshop - cloudyna 2017 (16.12.2017)
Serverless cat detector   workshop - cloudyna 2017 (16.12.2017)Serverless cat detector   workshop - cloudyna 2017 (16.12.2017)
Serverless cat detector workshop - cloudyna 2017 (16.12.2017)
 
以Device Shadows與Rules Engine串聯實體世界
以Device Shadows與Rules Engine串聯實體世界以Device Shadows與Rules Engine串聯實體世界
以Device Shadows與Rules Engine串聯實體世界
 
AWS IoT 핸즈온 워크샵 - 실습 3. AWS IoT Thing Shadow (김무현 솔루션즈 아키텍트)
AWS IoT 핸즈온 워크샵 - 실습 3. AWS IoT Thing Shadow (김무현 솔루션즈 아키텍트)AWS IoT 핸즈온 워크샵 - 실습 3. AWS IoT Thing Shadow (김무현 솔루션즈 아키텍트)
AWS IoT 핸즈온 워크샵 - 실습 3. AWS IoT Thing Shadow (김무현 솔루션즈 아키텍트)
 
Hands-on Lab - Combaring Redis with Relational
Hands-on Lab - Combaring Redis with RelationalHands-on Lab - Combaring Redis with Relational
Hands-on Lab - Combaring Redis with Relational
 

More from Manish Chopra

Getting Started with ChatGPT.pdf
Getting Started with ChatGPT.pdfGetting Started with ChatGPT.pdf
Getting Started with ChatGPT.pdf
Manish Chopra
 
Grafana and AWS - Implementation and Usage
Grafana and AWS - Implementation and UsageGrafana and AWS - Implementation and Usage
Grafana and AWS - Implementation and Usage
Manish Chopra
 
Containers Auto Scaling on AWS.pdf
Containers Auto Scaling on AWS.pdfContainers Auto Scaling on AWS.pdf
Containers Auto Scaling on AWS.pdf
Manish Chopra
 
OpenKM Solution Document
OpenKM Solution DocumentOpenKM Solution Document
OpenKM Solution Document
Manish Chopra
 
Alfresco Content Services - Solution Document
Alfresco Content Services - Solution DocumentAlfresco Content Services - Solution Document
Alfresco Content Services - Solution Document
Manish Chopra
 
Jenkins Study Guide ToC
Jenkins Study Guide ToCJenkins Study Guide ToC
Jenkins Study Guide ToC
Manish Chopra
 
Ansible Study Guide ToC
Ansible Study Guide ToCAnsible Study Guide ToC
Ansible Study Guide ToC
Manish Chopra
 
Microservices with Dockers and Kubernetes
Microservices with Dockers and KubernetesMicroservices with Dockers and Kubernetes
Microservices with Dockers and Kubernetes
Manish Chopra
 
Unix and Linux Operating Systems
Unix and Linux Operating SystemsUnix and Linux Operating Systems
Unix and Linux Operating Systems
Manish Chopra
 
Working with Hive Analytics
Working with Hive AnalyticsWorking with Hive Analytics
Working with Hive Analytics
Manish Chopra
 
Preparing a Dataset for Processing
Preparing a Dataset for ProcessingPreparing a Dataset for Processing
Preparing a Dataset for Processing
Manish Chopra
 
Organizations with largest hadoop clusters
Organizations with largest hadoop clustersOrganizations with largest hadoop clusters
Organizations with largest hadoop clusters
Manish Chopra
 
Distributed File Systems
Distributed File SystemsDistributed File Systems
Distributed File Systems
Manish Chopra
 
Difference between hadoop 2 vs hadoop 3
Difference between hadoop 2 vs hadoop 3Difference between hadoop 2 vs hadoop 3
Difference between hadoop 2 vs hadoop 3
Manish Chopra
 
Oracle solaris 11 installation
Oracle solaris 11 installationOracle solaris 11 installation
Oracle solaris 11 installation
Manish Chopra
 
Big Data Analytics Course Guide TOC
Big Data Analytics Course Guide TOCBig Data Analytics Course Guide TOC
Big Data Analytics Course Guide TOC
Manish Chopra
 
Emergence and Importance of Cloud Computing for the Enterprise
Emergence and Importance of Cloud Computing for the EnterpriseEmergence and Importance of Cloud Computing for the Enterprise
Emergence and Importance of Cloud Computing for the Enterprise
Manish Chopra
 
Steps to create an RPM package in Linux
Steps to create an RPM package in LinuxSteps to create an RPM package in Linux
Steps to create an RPM package in Linux
Manish Chopra
 
Setting up a HADOOP 2.2 cluster on CentOS 6
Setting up a HADOOP 2.2 cluster on CentOS 6Setting up a HADOOP 2.2 cluster on CentOS 6
Setting up a HADOOP 2.2 cluster on CentOS 6
Manish Chopra
 
The Anatomy of GOOGLE Search Engine
The Anatomy of GOOGLE Search EngineThe Anatomy of GOOGLE Search Engine
The Anatomy of GOOGLE Search Engine
Manish Chopra
 

More from Manish Chopra (20)

Getting Started with ChatGPT.pdf
Getting Started with ChatGPT.pdfGetting Started with ChatGPT.pdf
Getting Started with ChatGPT.pdf
 
Grafana and AWS - Implementation and Usage
Grafana and AWS - Implementation and UsageGrafana and AWS - Implementation and Usage
Grafana and AWS - Implementation and Usage
 
Containers Auto Scaling on AWS.pdf
Containers Auto Scaling on AWS.pdfContainers Auto Scaling on AWS.pdf
Containers Auto Scaling on AWS.pdf
 
OpenKM Solution Document
OpenKM Solution DocumentOpenKM Solution Document
OpenKM Solution Document
 
Alfresco Content Services - Solution Document
Alfresco Content Services - Solution DocumentAlfresco Content Services - Solution Document
Alfresco Content Services - Solution Document
 
Jenkins Study Guide ToC
Jenkins Study Guide ToCJenkins Study Guide ToC
Jenkins Study Guide ToC
 
Ansible Study Guide ToC
Ansible Study Guide ToCAnsible Study Guide ToC
Ansible Study Guide ToC
 
Microservices with Dockers and Kubernetes
Microservices with Dockers and KubernetesMicroservices with Dockers and Kubernetes
Microservices with Dockers and Kubernetes
 
Unix and Linux Operating Systems
Unix and Linux Operating SystemsUnix and Linux Operating Systems
Unix and Linux Operating Systems
 
Working with Hive Analytics
Working with Hive AnalyticsWorking with Hive Analytics
Working with Hive Analytics
 
Preparing a Dataset for Processing
Preparing a Dataset for ProcessingPreparing a Dataset for Processing
Preparing a Dataset for Processing
 
Organizations with largest hadoop clusters
Organizations with largest hadoop clustersOrganizations with largest hadoop clusters
Organizations with largest hadoop clusters
 
Distributed File Systems
Distributed File SystemsDistributed File Systems
Distributed File Systems
 
Difference between hadoop 2 vs hadoop 3
Difference between hadoop 2 vs hadoop 3Difference between hadoop 2 vs hadoop 3
Difference between hadoop 2 vs hadoop 3
 
Oracle solaris 11 installation
Oracle solaris 11 installationOracle solaris 11 installation
Oracle solaris 11 installation
 
Big Data Analytics Course Guide TOC
Big Data Analytics Course Guide TOCBig Data Analytics Course Guide TOC
Big Data Analytics Course Guide TOC
 
Emergence and Importance of Cloud Computing for the Enterprise
Emergence and Importance of Cloud Computing for the EnterpriseEmergence and Importance of Cloud Computing for the Enterprise
Emergence and Importance of Cloud Computing for the Enterprise
 
Steps to create an RPM package in Linux
Steps to create an RPM package in LinuxSteps to create an RPM package in Linux
Steps to create an RPM package in Linux
 
Setting up a HADOOP 2.2 cluster on CentOS 6
Setting up a HADOOP 2.2 cluster on CentOS 6Setting up a HADOOP 2.2 cluster on CentOS 6
Setting up a HADOOP 2.2 cluster on CentOS 6
 
The Anatomy of GOOGLE Search Engine
The Anatomy of GOOGLE Search EngineThe Anatomy of GOOGLE Search Engine
The Anatomy of GOOGLE Search Engine
 

Recently uploaded

GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
lorraineandreiamcidl
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
Drona Infotech
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
ISH Technologies
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
mz5nrf0n
 

Recently uploaded (20)

GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
 

AWS and Slack Integration - Sending CloudWatch Notifications to Slack.pdf

  • 1. AWS and Slack Integration Sending CloudWatch Notifications to Slack Contents Objective..................................................................................................................................... 1 AWS CloudWatch ...................................................................................................................... 1 Create an AWS Access Key and Secret...................................................................................... 2 Create a Role............................................................................................................................... 2 Deploy the Lambda function ...................................................................................................... 3 Create an SNS topic and subscription......................................................................................... 7 Create a Cloudwatch Alarm........................................................................................................ 8 Testing AWS Cloudwatch Alarm Notification to Slack........................................................... 10 References:................................................................................................................................ 11 Objective To create a Proof of Concept project that monitors AWS resources and sends notifications to a Slack channel in the event of application metrics exceeding threshold limits. This writing is of February 2021, when the requirement of including this module was raised for the larger project. As the project starts getting deployed on Amazon AWS, we need continuous monitoring of the workloads and application metrics. In case of any warnings or errors, suitable messages should be routed to Slack so that admin or dedicated team members would be notified and then they can take suitable actions to fix the anomalies. AWS CloudWatch CloudWatch enables us to monitor our AWS resources and the applications in real time. It not only gives us access to metrics, but also creates alarms for specific cases. To establish this system, following steps were carried out.  Create an AWS Access Key and Secret  Create a Role  Deploy the Lambda function  Create an SNS topic and subscription  Create a Cloudwatch Alarm
  • 2. Create an AWS Access Key and Secret Prior to getting started with this project, having an account on AWS is required. Secondly, a key- pair is also needed. Both the prerequisites were already present, hence we can continue to the next step. Create a Role The Role will be used by the Lambda function and requires permission to do certain things. Type a role name, such as “cloudwatch-to-slack-role,” click on the newly created role in the list and copy the ARN name. We will use it later during deployment of the Lambda function.
  • 3. Deploy the Lambda function To deploy the AWS Lambda function, clone this repository and have Node.js installed on your local machine. linux@Docker-Host:/opt$ sudo git clone https://github.com/assertible/lambda-cloudwatch-slack Cloning into 'lambda-cloudwatch-slack'... remote: Enumerating objects: 6, done. remote: Counting objects: 100% (6/6), done. remote: Compressing objects: 100% (6/6), done. remote: Total 268 (delta 2), reused 0 (delta 0), pack-reused 262 Receiving objects: 100% (268/268), 695.88 KiB | 769.00 KiB/s, done. Resolving deltas: 100% (131/131), done. linux@Docker-Host:/opt$ cd /opt/lambda-cloudwatch-slack linux@Docker-Host:/opt/lambda-cloudwatch-slack$ sudo cp .env.example .env Open the .env file and fill in the environment variables. linux@Docker-Host:/opt/lambda-cloudwatch-slack$ sudo vi .env linux@Docker-Host:/opt/lambda-cloudwatch-slack$ cat .env #KMS_ENCRYPTED_HOOK_URL= you can use ENCRYPTED_HOOK_URL if you want UNENCRYPTED_HOOK_URL=https://hooks.slack.com/services/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 AWS_FUNCTION_NAME=cloudwatch-to-slack AWS_REGION=us-east-2 AWS_ROLE="arn:aws:iam::386222297872:role/cloudwatch-to-slack-role" AWS_ACCESS_KEY_ID=ABCLMNXYZXYZ AWS_SECRET_ACCESS_KEY=ABCLMNXYZXYZABCLMNXYZXYZ linux@Docker-Host:/opt/lambda-cloudwatch-slack$ sudo apt install npm
  • 4. Now as we are ready to deploy, run the following command in your terminal from the folder where the repository was cloned: root@Docker-Host:/opt/lambda-cloudwatch-slack# npm run deploy > lambda-cloudwatch-slack@0.4.0 deploy /opt/lambda-cloudwatch-slack > ./scripts/deploy.sh => Moving files to temporary directory => Running npm ci --production => Zipping deployment package => Zipping repo. This might take up to 30 seconds => Reading zip file to memory => Reading event source file to memory => Uploading zip file to AWS Lambda us-east-2 with parameters: { FunctionName: 'cloudwatch-to-slack', Code: { ZipFile: <Buffer 50 4b 03 04 14 00 08 00 08 00 82 80 4c 52 00 00 00 00 00 00 00 00 00 00 00 00 04 00 00 00 2e 65 6e 76 6d 91 4b 6f a3 30 14 85 f7 fc 0a ab 59 13 12 a8 ... 5669872 more bytes> }, Handler: 'index.handler', Role: 'arn:aws:iam::386222297872:role/cloudwatch-to-slack-role', Runtime: 'nodejs12.x', Description: 'Better Slack notifications for AWS CloudWatch', MemorySize: 128,
  • 5. Timeout: 60, Publish: false, VpcConfig: { SubnetIds: [], SecurityGroupIds: [] }, Environment: { Variables: { UNENCRYPTED_HOOK_URL: 'https://hooks.slack.com/services/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' } }, KMSKeyArn: '', DeadLetterConfig: { TargetArn: null }, TracingConfig: { Mode: null }, Layers: [], Tags: {} } => Done uploading. Results follow: { FunctionName: 'cloudwatch-to-slack', FunctionArn: 'arn:aws:lambda:us-east-2:386222297872:function:cloudwatch-to-slack', Runtime: 'nodejs12.x', Role: 'arn:aws:iam::386222297872:role/cloudwatch-to-slack-role', Handler: 'index.handler', CodeSize: 5669922, Description: 'Better Slack notifications for AWS CloudWatch', Timeout: 60, MemorySize: 128, LastModified: '2021-02-12T16:04:22.752+0000', CodeSha256: 'ctOhrmjW+SK0phhGvvwVwYjqk7rY1WS6zA/hqbOKbJA=', Version: '$LATEST', VpcConfig: { SubnetIds: [], SecurityGroupIds: [], VpcId: '' }, Environment: { Variables: { UNENCRYPTED_HOOK_URL: 'https://hooks.slack.com/services/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' } }, KMSKeyArn: null, TracingConfig: { Mode: 'PassThrough' }, MasterArn: null, RevisionId: '48d25390-16cb-4580-916a-7562aac9c4ea', Layers: [], State: 'Active', StateReason: null, StateReasonCode: null, LastUpdateStatus: 'Successful',
  • 6. LastUpdateStatusReason: null, LastUpdateStatusReasonCode: null } => All tasks done. Results follow: {} root@Docker-Host:/opt/lambda-cloudwatch-slack#
  • 7. Create an SNS topic and subscription In AWS web interface, go to the Simple Notification Service.
  • 8. In the Topics, click Create New Topic, such as “cloudwatch-alarms” for the notification that will be sent. Select AWS Lambda as your Protocol and pick the endpoint with the name of your function. Create a Cloudwatch Alarm Navigate through Cloudwatch to your AWS account and click Create Alarm.
  • 9. Chose the metric you would like to monitor, define the alarm configuration and select your SNS topic name in the Send Notification To section.
  • 10. Testing AWS CloudWatch Alarm Notification to Slack Start or choose the AWS resource to monitor, as an ECS container in our case. For testing purpose, decrease the value of metric suitably.
  • 11. If everything is configured properly, you will see the message in your Slack channel. References Amazon CloudWatch Documentation https://docs.aws.amazon.com/cloudwatch/index.html AWS Lambda Documentation https://docs.aws.amazon.com/lambda/index.html