SlideShare a Scribd company logo
1 of 11
Download to read offline
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

Reusable, composable, battle-tested Terraform modules
Reusable, composable, battle-tested Terraform modulesReusable, composable, battle-tested Terraform modules
Reusable, composable, battle-tested Terraform modulesYevgeniy 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 RelationalAmazon Web Services
 
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016
대용량 데이타 쉽고 빠르게 분석하기 :: 김일호 솔루션즈 아키텍트 :: Gaming on AWS 2016Amazon 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 Nalleybuildacloud
 
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 cloudKyle Rames
 
Hands-on Lab: Amazon ElastiCache
Hands-on Lab: Amazon ElastiCacheHands-on Lab: Amazon ElastiCache
Hands-on Lab: Amazon ElastiCacheAmazon 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 AWSFernando 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 EngineAmazon 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
 
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 AvivAmazon 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 2015Chef
 
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 moreDropsolid
 
DevOps, Microservices and Serverless Architecture
DevOps, Microservices and Serverless ArchitectureDevOps, Microservices and Serverless Architecture
DevOps, Microservices and Serverless ArchitectureMikhail 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 RelationalAmazon 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.pdfManish Chopra
 
Grafana and AWS - Implementation and Usage
Grafana and AWS - Implementation and UsageGrafana and AWS - Implementation and Usage
Grafana and AWS - Implementation and UsageManish Chopra
 
Containers Auto Scaling on AWS.pdf
Containers Auto Scaling on AWS.pdfContainers Auto Scaling on AWS.pdf
Containers Auto Scaling on AWS.pdfManish Chopra
 
OpenKM Solution Document
OpenKM Solution DocumentOpenKM Solution Document
OpenKM Solution DocumentManish Chopra
 
Alfresco Content Services - Solution Document
Alfresco Content Services - Solution DocumentAlfresco Content Services - Solution Document
Alfresco Content Services - Solution DocumentManish Chopra
 
Jenkins Study Guide ToC
Jenkins Study Guide ToCJenkins Study Guide ToC
Jenkins Study Guide ToCManish Chopra
 
Ansible Study Guide ToC
Ansible Study Guide ToCAnsible Study Guide ToC
Ansible Study Guide ToCManish Chopra
 
Microservices with Dockers and Kubernetes
Microservices with Dockers and KubernetesMicroservices with Dockers and Kubernetes
Microservices with Dockers and KubernetesManish Chopra
 
Unix and Linux Operating Systems
Unix and Linux Operating SystemsUnix and Linux Operating Systems
Unix and Linux Operating SystemsManish Chopra
 
Working with Hive Analytics
Working with Hive AnalyticsWorking with Hive Analytics
Working with Hive AnalyticsManish Chopra
 
Preparing a Dataset for Processing
Preparing a Dataset for ProcessingPreparing a Dataset for Processing
Preparing a Dataset for ProcessingManish Chopra
 
Organizations with largest hadoop clusters
Organizations with largest hadoop clustersOrganizations with largest hadoop clusters
Organizations with largest hadoop clustersManish Chopra
 
Distributed File Systems
Distributed File SystemsDistributed File Systems
Distributed File SystemsManish 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 3Manish Chopra
 
Oracle solaris 11 installation
Oracle solaris 11 installationOracle solaris 11 installation
Oracle solaris 11 installationManish Chopra
 
Big Data Analytics Course Guide TOC
Big Data Analytics Course Guide TOCBig Data Analytics Course Guide TOC
Big Data Analytics Course Guide TOCManish 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 EnterpriseManish 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 LinuxManish 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 6Manish Chopra
 
The Anatomy of GOOGLE Search Engine
The Anatomy of GOOGLE Search EngineThe Anatomy of GOOGLE Search Engine
The Anatomy of GOOGLE Search EngineManish 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

办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 

Recently uploaded (20)

办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 

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