SlideShare une entreprise Scribd logo
1  sur  21
Create custom
Cloudwatch metrics on
AWS cloud & New Relic
Ahmad Karawash
PhD in Technology of Information, Book Editor,
CCA, Latece, ACM & IEEE member
12/23/2015 1
Amazon Metrics
• Metrics are used to monitor various resources in Amazon Web
Services like EBS volumes, EC2 instances and RDS instances.
12/23/2015 2
AWS resources covered by
CloudWatch
 Amazon Ec2
 EBS Volumes
 AutoScaling Groups
 Elastic load Balancers
 Amazon Route 53
 RDS DB instances
 DynamoDB tables
 ElastiCache clusters
 RedShift clusters
 SQS queues
 SNS topics
 Storage Gateways
12/23/2015 3
Example of available metrics
• Memory Utilization – Memory allocated by applications and the operating
system, exclusive of caches and buffers, in percentages.
• Memory Used – Memory allocated by applications and the operating
system, exclusive of caches and buffers, in megabytes.
• Memory Available – System memory available for applications and the
operating system, in megabytes.
• Disk Space Utilization – Disk space usage as percentages.
• Disk Space Used – Disk space usage in gigabytes.
• Disk Space Available – Available disk space in gigabytes.
• Swap Space Utilization – Swap space usage as a percentage.
• Swap Space Used – Swap space usage in megabytes.
12/23/2015 4
Cloudwatch advantage
• AWS provides some additional monitoring scripts for adding custom
Cloudwatch metrics.
12/23/2015 5
Use case Example
• A user might have to take automated actions based on a particular
parameter. This parameter can be the number of active users in a
system which can be stored in an RDS instance. A script can be used
to measure this value and if the number of users is zero for a
particular time period, an alarm needs to be triggered and the EC2
instance needs to be terminated.
12/23/2015 6
Prerequisites
• Install python
• Sudo apt-get install python python dev
• Sudo apt-get install python-pip
• Install boto
• Sudo pip install boto
• Create RDS Database or local Database for the new custom metric, for
example RoomTemperatureDatabase.
12/23/2015 7
put_metric_data
• put_metric_data ( $namespace, $metric_data, $opt ): Publishes
metric data points to Amazon CloudWatch. Amazon Cloudwatch
associates the data points with the specified metric. If the specified
metric does not exist, Amazon CloudWatch creates the metric.
• If you create a metric with the PutMetricData action, allow up to
fifteen minutes for the metric to appear in calls to the ListMetrics
action.
12/23/2015 8
RoomTemperatureMeasure
Database
12/23/2015 9
Create a Custom Metric and
connect to external database
Run the python code from Ubuntu console: (how to run check:
https://www.youtube.com/watch?v=zKUu4in858A}
1. from boto.ec2.cloudwatch import connect_to_region
2. import MySQLdb
3. import boto.ec2.cloudwatch
4. db=MySQLdb.connect(“Public DNS","username","password","databasename")
5. cursor=db.cursor()
6. n=cursor.execute(" select value from Temperature ORDER BY id DESC LIMIT 1 ")
7. n1=cursor.fetchone()
12/23/2015 10
Create a Custom Metric and
connect to external database
8. s=str(n1)
9. table=string.maketrans( '', '', )
10. number=s.translate(table,"(){}<>,L")
11. numbers=int(number)
12. reg='ap-west-1'
13. conn_cw=boto.ec2.cloudwatch.connect_to_region(reg,
aws_access_key_id=’your_access_key’,aws_secret_access_key=’your_secret_k
ey’)
14. conn_cw.put_metric_data(namespace='my_namespace',name='my_metric',val
ue=numbers,dimensions={'InstanceId':‘instance-val'})
12/23/2015 11
Create a Custom Cloudwatch
Metric
• After you connect successively to the database, “put-metric-data”
method will add instance of a new custom metric into you
cloudwatch
12/23/2015 12
How to check whether the custom
metric was created
12/23/2015 13
How to check whether the custom
metric was created
12/23/2015 14
Creating a CloudWatch alarm for
the custom metric
• Now you can monitor you own metric using Cloudwatch
• For example, you can add alarm:
1. from boto.ec2.cloudwatch import connect_to_region
2. import boto.ec2.cloudwatch
3. metric=cw.list_metrics(dimensions={'InstanceId':’i-
a1b2c3d4’},metric_name='my_metric')[0]
4. metric.create_alarm(name='my_alarm', comparison='<=', threshold=0,
period=300,evaluation_periods=1, statistic='Average',
alarm_actions='arn:aws:automate:ap-northeast-1:ec2:terminate')
12/23/2015 15
Example for other proposed use
case
• For example:
• if you want to create a new custom metrics that measure the temperature of
the room, you can create your own database on the cloud to store the data
and update it and you have to create a database to be used by cloud watch.
• For that purpose, you can use the same code I have shown in slides 8-9, but
only apply changes to the database query.
12/23/2015 16
Real Implementation
• Using PHP and MySQL, I have created my own database that get
temperature value periodically from weather web service
(http://weather.yahooapis.com/forecastrss)
• Using Python, I have created a new custom metric that measure the
temperature called temperature_metric you can check it online
• I can manage this metric easily by pushing my own data to
cloudwatch and benefit from it for monitoring purpose.
• I Can add any notification system compatible with cloudwatch.
• Also, I can do my own alarm system using PHP code to forward emails
when required.
12/23/2015 17
New Relic Broadcast alert
12/23/2015 18
In order to Broadcast metric notifications, we can use New
Relic, because it is compatible with CloudWatch and use
various channels such as:
E-mail: Sends an email message to the email
address specified in the configuration.
HipChat: Sends a message to the HipChat room specified in
the configuration.
PagerDuty: Sends a notification through the NetOps
administration toolPagerDuty. This is an advanced option
for the more critical notifications that need to addressed
immediately—the alerts can even be configured to call you
on the phone!
Slack: Sends a notification to the Slack channel specified in
the configuration.
New Relic Broadcast alert
12/23/2015 19
VictorOps: Similar to PagerDuty, this option sends a
notification through the NetOps tool VictorOps. The
functionality in the two tools is quite similar, so the choice
depends mostly on what you're already using.
Webhook: Sends a notification to a URL you define. Use
this option if you want to send notifications to a channel
that isn't currently supported directly by New Relic Alerts—
or if you want to create your own custom solution...
Campfire: Sends a notification to the Campfire chat room
specified in the configuration.
OpsGenie: Sends a notification using the OpsGenie NetOps
alert system. OpsGenie is another tool similar to PagerDuty
and VictorOps that can be used to make sure your team
notices the alerts as they arise.
New Relic Broadcast alert
12/23/2015 20
There is also a plan to open more notification channels in
the future versions, they may add access to Lambda
functions
For full details about how to connect New Relic to
CloudWatch and start getting notification please read this
web article: http://code.tutsplus.com/tutorials/get-started-
with-monitoring-your-web-application-using-new-relic-
alerts--cms-24187
?? @:
Ahmad.Karawash@gmail.com
12/23/2015 21

Contenu connexe

Tendances (20)

Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Apache Kafka - Overview
Apache Kafka - OverviewApache Kafka - Overview
Apache Kafka - Overview
 
Event Hub & Kafka
Event Hub & KafkaEvent Hub & Kafka
Event Hub & Kafka
 
Multi-Cluster and Failover for Apache Kafka - Kafka Summit SF 17
Multi-Cluster and Failover for Apache Kafka - Kafka Summit SF 17Multi-Cluster and Failover for Apache Kafka - Kafka Summit SF 17
Multi-Cluster and Failover for Apache Kafka - Kafka Summit SF 17
 
Kafka Overview
Kafka OverviewKafka Overview
Kafka Overview
 
Kafka basics
Kafka basicsKafka basics
Kafka basics
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Apache Kafka
Apache KafkaApache Kafka
Apache Kafka
 
Apache Kafka
Apache KafkaApache Kafka
Apache Kafka
 
Flume vs. kafka
Flume vs. kafkaFlume vs. kafka
Flume vs. kafka
 
Overview of Message Queues
Overview of Message QueuesOverview of Message Queues
Overview of Message Queues
 
Kafka aws
Kafka awsKafka aws
Kafka aws
 
Understanding kafka
Understanding kafkaUnderstanding kafka
Understanding kafka
 
Kafka Basic For Beginners
Kafka Basic For BeginnersKafka Basic For Beginners
Kafka Basic For Beginners
 
Introduction to Apache Kafka
Introduction to Apache KafkaIntroduction to Apache Kafka
Introduction to Apache Kafka
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Apache Kafka - Free Friday
Apache Kafka - Free FridayApache Kafka - Free Friday
Apache Kafka - Free Friday
 
Kafka
KafkaKafka
Kafka
 
Kafka as Message Broker
Kafka as Message BrokerKafka as Message Broker
Kafka as Message Broker
 

Similaire à Build a custom metrics on aws cloud

오토스케일링 제대로 활용하기 (김일호) - AWS 웨비나 시리즈 2015
오토스케일링 제대로 활용하기 (김일호) - AWS 웨비나 시리즈 2015오토스케일링 제대로 활용하기 (김일호) - AWS 웨비나 시리즈 2015
오토스케일링 제대로 활용하기 (김일호) - AWS 웨비나 시리즈 2015Amazon Web Services Korea
 
Day 5 - AWS Autoscaling Master Class - The New Capacity Plan
Day 5 - AWS Autoscaling Master Class - The New Capacity PlanDay 5 - AWS Autoscaling Master Class - The New Capacity Plan
Day 5 - AWS Autoscaling Master Class - The New Capacity PlanAmazon Web Services
 
Jamcracker Cloud Management Platform: Control, Govern and Manage Enterprise C...
Jamcracker Cloud Management Platform: Control, Govern and Manage Enterprise C...Jamcracker Cloud Management Platform: Control, Govern and Manage Enterprise C...
Jamcracker Cloud Management Platform: Control, Govern and Manage Enterprise C...Jamcracker Inc
 
ENT203 Monitoring and Autoscaling, a Match Made in Heaven
ENT203 Monitoring and Autoscaling, a Match Made in HeavenENT203 Monitoring and Autoscaling, a Match Made in Heaven
ENT203 Monitoring and Autoscaling, a Match Made in HeavenAmazon Web Services
 
Server and application monitoring webinars [Applications Manager] - Part 4
Server and application monitoring webinars [Applications Manager] - Part 4Server and application monitoring webinars [Applications Manager] - Part 4
Server and application monitoring webinars [Applications Manager] - Part 4ManageEngine, Zoho Corporation
 
Kks sre book_ch10
Kks sre book_ch10Kks sre book_ch10
Kks sre book_ch10Chris Huang
 
Hybrid Cloud Management and Orchestration : The Complete Solution
Hybrid Cloud Management and Orchestration : The Complete SolutionHybrid Cloud Management and Orchestration : The Complete Solution
Hybrid Cloud Management and Orchestration : The Complete SolutionJamcracker Inc
 
Operations: Cost Optimization - Don't Overspend on Infrastructure
Operations: Cost Optimization - Don't Overspend on Infrastructure Operations: Cost Optimization - Don't Overspend on Infrastructure
Operations: Cost Optimization - Don't Overspend on Infrastructure Amazon Web Services
 
Efficient way to manage environments in AWS
Efficient way to manage environments in AWS Efficient way to manage environments in AWS
Efficient way to manage environments in AWS amii894
 
Achieve big data analytic platform with lambda architecture on cloud
Achieve big data analytic platform with lambda architecture on cloudAchieve big data analytic platform with lambda architecture on cloud
Achieve big data analytic platform with lambda architecture on cloudScott Miao
 
Google cloud certified professional cloud developer practice dumps 2020
Google cloud certified professional cloud developer practice dumps 2020Google cloud certified professional cloud developer practice dumps 2020
Google cloud certified professional cloud developer practice dumps 2020SkillCertProExams
 
Training AWS: Module 9 - CloudWatch
Training AWS: Module 9 - CloudWatchTraining AWS: Module 9 - CloudWatch
Training AWS: Module 9 - CloudWatchBùi Quang Lâm
 
Building a Just-in-Time Application Stack for Analysts
Building a Just-in-Time Application Stack for AnalystsBuilding a Just-in-Time Application Stack for Analysts
Building a Just-in-Time Application Stack for AnalystsAvere Systems
 
Private Cloud with Open Stack, Docker
Private Cloud with Open Stack, DockerPrivate Cloud with Open Stack, Docker
Private Cloud with Open Stack, DockerDavinder Kohli
 
AWS Certified Cloud Practitioner Course S7-S10
AWS Certified Cloud Practitioner Course S7-S10AWS Certified Cloud Practitioner Course S7-S10
AWS Certified Cloud Practitioner Course S7-S10Neal Davis
 
Big data application using hadoop in cloud [Smart Refrigerator]
Big data application using hadoop in cloud [Smart Refrigerator] Big data application using hadoop in cloud [Smart Refrigerator]
Big data application using hadoop in cloud [Smart Refrigerator] Pushkar Bhandari
 
Masterless Puppet Using AWS S3 Buckets and IAM Roles
Masterless Puppet Using AWS S3 Buckets and IAM RolesMasterless Puppet Using AWS S3 Buckets and IAM Roles
Masterless Puppet Using AWS S3 Buckets and IAM RolesMalcolm Duncanson, CISSP
 
Openstack Cloud Management and Automation Using Red Hat Cloudforms 4.0
Openstack Cloud  Management and Automation Using Red Hat Cloudforms 4.0Openstack Cloud  Management and Automation Using Red Hat Cloudforms 4.0
Openstack Cloud Management and Automation Using Red Hat Cloudforms 4.0Prasad Mukhedkar
 
Exact Amazon Exam DOP-C01D umps - DOP-C01 Real Exam Questions Answers
Exact Amazon Exam DOP-C01D umps - DOP-C01 Real Exam Questions AnswersExact Amazon Exam DOP-C01D umps - DOP-C01 Real Exam Questions Answers
Exact Amazon Exam DOP-C01D umps - DOP-C01 Real Exam Questions AnswersLeroySmith25
 

Similaire à Build a custom metrics on aws cloud (20)

오토스케일링 제대로 활용하기 (김일호) - AWS 웨비나 시리즈 2015
오토스케일링 제대로 활용하기 (김일호) - AWS 웨비나 시리즈 2015오토스케일링 제대로 활용하기 (김일호) - AWS 웨비나 시리즈 2015
오토스케일링 제대로 활용하기 (김일호) - AWS 웨비나 시리즈 2015
 
Day 5 - AWS Autoscaling Master Class - The New Capacity Plan
Day 5 - AWS Autoscaling Master Class - The New Capacity PlanDay 5 - AWS Autoscaling Master Class - The New Capacity Plan
Day 5 - AWS Autoscaling Master Class - The New Capacity Plan
 
Jamcracker Cloud Management Platform: Control, Govern and Manage Enterprise C...
Jamcracker Cloud Management Platform: Control, Govern and Manage Enterprise C...Jamcracker Cloud Management Platform: Control, Govern and Manage Enterprise C...
Jamcracker Cloud Management Platform: Control, Govern and Manage Enterprise C...
 
ENT203 Monitoring and Autoscaling, a Match Made in Heaven
ENT203 Monitoring and Autoscaling, a Match Made in HeavenENT203 Monitoring and Autoscaling, a Match Made in Heaven
ENT203 Monitoring and Autoscaling, a Match Made in Heaven
 
Server and application monitoring webinars [Applications Manager] - Part 4
Server and application monitoring webinars [Applications Manager] - Part 4Server and application monitoring webinars [Applications Manager] - Part 4
Server and application monitoring webinars [Applications Manager] - Part 4
 
Kks sre book_ch10
Kks sre book_ch10Kks sre book_ch10
Kks sre book_ch10
 
Hybrid Cloud Management and Orchestration : The Complete Solution
Hybrid Cloud Management and Orchestration : The Complete SolutionHybrid Cloud Management and Orchestration : The Complete Solution
Hybrid Cloud Management and Orchestration : The Complete Solution
 
Operations: Cost Optimization - Don't Overspend on Infrastructure
Operations: Cost Optimization - Don't Overspend on Infrastructure Operations: Cost Optimization - Don't Overspend on Infrastructure
Operations: Cost Optimization - Don't Overspend on Infrastructure
 
Efficient way to manage environments in AWS
Efficient way to manage environments in AWS Efficient way to manage environments in AWS
Efficient way to manage environments in AWS
 
Achieve big data analytic platform with lambda architecture on cloud
Achieve big data analytic platform with lambda architecture on cloudAchieve big data analytic platform with lambda architecture on cloud
Achieve big data analytic platform with lambda architecture on cloud
 
Bigdata meetup dwarak_realtime_score_app
Bigdata meetup dwarak_realtime_score_appBigdata meetup dwarak_realtime_score_app
Bigdata meetup dwarak_realtime_score_app
 
Google cloud certified professional cloud developer practice dumps 2020
Google cloud certified professional cloud developer practice dumps 2020Google cloud certified professional cloud developer practice dumps 2020
Google cloud certified professional cloud developer practice dumps 2020
 
Training AWS: Module 9 - CloudWatch
Training AWS: Module 9 - CloudWatchTraining AWS: Module 9 - CloudWatch
Training AWS: Module 9 - CloudWatch
 
Building a Just-in-Time Application Stack for Analysts
Building a Just-in-Time Application Stack for AnalystsBuilding a Just-in-Time Application Stack for Analysts
Building a Just-in-Time Application Stack for Analysts
 
Private Cloud with Open Stack, Docker
Private Cloud with Open Stack, DockerPrivate Cloud with Open Stack, Docker
Private Cloud with Open Stack, Docker
 
AWS Certified Cloud Practitioner Course S7-S10
AWS Certified Cloud Practitioner Course S7-S10AWS Certified Cloud Practitioner Course S7-S10
AWS Certified Cloud Practitioner Course S7-S10
 
Big data application using hadoop in cloud [Smart Refrigerator]
Big data application using hadoop in cloud [Smart Refrigerator] Big data application using hadoop in cloud [Smart Refrigerator]
Big data application using hadoop in cloud [Smart Refrigerator]
 
Masterless Puppet Using AWS S3 Buckets and IAM Roles
Masterless Puppet Using AWS S3 Buckets and IAM RolesMasterless Puppet Using AWS S3 Buckets and IAM Roles
Masterless Puppet Using AWS S3 Buckets and IAM Roles
 
Openstack Cloud Management and Automation Using Red Hat Cloudforms 4.0
Openstack Cloud  Management and Automation Using Red Hat Cloudforms 4.0Openstack Cloud  Management and Automation Using Red Hat Cloudforms 4.0
Openstack Cloud Management and Automation Using Red Hat Cloudforms 4.0
 
Exact Amazon Exam DOP-C01D umps - DOP-C01 Real Exam Questions Answers
Exact Amazon Exam DOP-C01D umps - DOP-C01 Real Exam Questions AnswersExact Amazon Exam DOP-C01D umps - DOP-C01 Real Exam Questions Answers
Exact Amazon Exam DOP-C01D umps - DOP-C01 Real Exam Questions Answers
 

Plus de Ahmad karawash

Object-Oriented Programming (OOP)
Object-Oriented Programming (OOP)Object-Oriented Programming (OOP)
Object-Oriented Programming (OOP)Ahmad karawash
 
Introduction to-data-science
Introduction to-data-scienceIntroduction to-data-science
Introduction to-data-scienceAhmad karawash
 
How to understand your data
How to understand your dataHow to understand your data
How to understand your dataAhmad karawash
 
Cloud storage with AWS
Cloud storage with AWSCloud storage with AWS
Cloud storage with AWSAhmad karawash
 
Password hashing, salting, bycrpt
Password hashing, salting, bycrptPassword hashing, salting, bycrpt
Password hashing, salting, bycrptAhmad karawash
 
Reasoning of database consistency through description logics
Reasoning of database consistency through description logicsReasoning of database consistency through description logics
Reasoning of database consistency through description logicsAhmad karawash
 
Cloud computing and Service model
Cloud computing and Service modelCloud computing and Service model
Cloud computing and Service modelAhmad karawash
 
From use case to software architecture
From use case to software architectureFrom use case to software architecture
From use case to software architectureAhmad karawash
 

Plus de Ahmad karawash (9)

Object-Oriented Programming (OOP)
Object-Oriented Programming (OOP)Object-Oriented Programming (OOP)
Object-Oriented Programming (OOP)
 
Introduction to-data-science
Introduction to-data-scienceIntroduction to-data-science
Introduction to-data-science
 
How to understand your data
How to understand your dataHow to understand your data
How to understand your data
 
Cloud storage with AWS
Cloud storage with AWSCloud storage with AWS
Cloud storage with AWS
 
Password hashing, salting, bycrpt
Password hashing, salting, bycrptPassword hashing, salting, bycrpt
Password hashing, salting, bycrpt
 
Brute Force Attack
Brute Force AttackBrute Force Attack
Brute Force Attack
 
Reasoning of database consistency through description logics
Reasoning of database consistency through description logicsReasoning of database consistency through description logics
Reasoning of database consistency through description logics
 
Cloud computing and Service model
Cloud computing and Service modelCloud computing and Service model
Cloud computing and Service model
 
From use case to software architecture
From use case to software architectureFrom use case to software architecture
From use case to software architecture
 

Dernier

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Dernier (20)

From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

Build a custom metrics on aws cloud

  • 1. Create custom Cloudwatch metrics on AWS cloud & New Relic Ahmad Karawash PhD in Technology of Information, Book Editor, CCA, Latece, ACM & IEEE member 12/23/2015 1
  • 2. Amazon Metrics • Metrics are used to monitor various resources in Amazon Web Services like EBS volumes, EC2 instances and RDS instances. 12/23/2015 2
  • 3. AWS resources covered by CloudWatch  Amazon Ec2  EBS Volumes  AutoScaling Groups  Elastic load Balancers  Amazon Route 53  RDS DB instances  DynamoDB tables  ElastiCache clusters  RedShift clusters  SQS queues  SNS topics  Storage Gateways 12/23/2015 3
  • 4. Example of available metrics • Memory Utilization – Memory allocated by applications and the operating system, exclusive of caches and buffers, in percentages. • Memory Used – Memory allocated by applications and the operating system, exclusive of caches and buffers, in megabytes. • Memory Available – System memory available for applications and the operating system, in megabytes. • Disk Space Utilization – Disk space usage as percentages. • Disk Space Used – Disk space usage in gigabytes. • Disk Space Available – Available disk space in gigabytes. • Swap Space Utilization – Swap space usage as a percentage. • Swap Space Used – Swap space usage in megabytes. 12/23/2015 4
  • 5. Cloudwatch advantage • AWS provides some additional monitoring scripts for adding custom Cloudwatch metrics. 12/23/2015 5
  • 6. Use case Example • A user might have to take automated actions based on a particular parameter. This parameter can be the number of active users in a system which can be stored in an RDS instance. A script can be used to measure this value and if the number of users is zero for a particular time period, an alarm needs to be triggered and the EC2 instance needs to be terminated. 12/23/2015 6
  • 7. Prerequisites • Install python • Sudo apt-get install python python dev • Sudo apt-get install python-pip • Install boto • Sudo pip install boto • Create RDS Database or local Database for the new custom metric, for example RoomTemperatureDatabase. 12/23/2015 7
  • 8. put_metric_data • put_metric_data ( $namespace, $metric_data, $opt ): Publishes metric data points to Amazon CloudWatch. Amazon Cloudwatch associates the data points with the specified metric. If the specified metric does not exist, Amazon CloudWatch creates the metric. • If you create a metric with the PutMetricData action, allow up to fifteen minutes for the metric to appear in calls to the ListMetrics action. 12/23/2015 8
  • 10. Create a Custom Metric and connect to external database Run the python code from Ubuntu console: (how to run check: https://www.youtube.com/watch?v=zKUu4in858A} 1. from boto.ec2.cloudwatch import connect_to_region 2. import MySQLdb 3. import boto.ec2.cloudwatch 4. db=MySQLdb.connect(“Public DNS","username","password","databasename") 5. cursor=db.cursor() 6. n=cursor.execute(" select value from Temperature ORDER BY id DESC LIMIT 1 ") 7. n1=cursor.fetchone() 12/23/2015 10
  • 11. Create a Custom Metric and connect to external database 8. s=str(n1) 9. table=string.maketrans( '', '', ) 10. number=s.translate(table,"(){}<>,L") 11. numbers=int(number) 12. reg='ap-west-1' 13. conn_cw=boto.ec2.cloudwatch.connect_to_region(reg, aws_access_key_id=’your_access_key’,aws_secret_access_key=’your_secret_k ey’) 14. conn_cw.put_metric_data(namespace='my_namespace',name='my_metric',val ue=numbers,dimensions={'InstanceId':‘instance-val'}) 12/23/2015 11
  • 12. Create a Custom Cloudwatch Metric • After you connect successively to the database, “put-metric-data” method will add instance of a new custom metric into you cloudwatch 12/23/2015 12
  • 13. How to check whether the custom metric was created 12/23/2015 13
  • 14. How to check whether the custom metric was created 12/23/2015 14
  • 15. Creating a CloudWatch alarm for the custom metric • Now you can monitor you own metric using Cloudwatch • For example, you can add alarm: 1. from boto.ec2.cloudwatch import connect_to_region 2. import boto.ec2.cloudwatch 3. metric=cw.list_metrics(dimensions={'InstanceId':’i- a1b2c3d4’},metric_name='my_metric')[0] 4. metric.create_alarm(name='my_alarm', comparison='<=', threshold=0, period=300,evaluation_periods=1, statistic='Average', alarm_actions='arn:aws:automate:ap-northeast-1:ec2:terminate') 12/23/2015 15
  • 16. Example for other proposed use case • For example: • if you want to create a new custom metrics that measure the temperature of the room, you can create your own database on the cloud to store the data and update it and you have to create a database to be used by cloud watch. • For that purpose, you can use the same code I have shown in slides 8-9, but only apply changes to the database query. 12/23/2015 16
  • 17. Real Implementation • Using PHP and MySQL, I have created my own database that get temperature value periodically from weather web service (http://weather.yahooapis.com/forecastrss) • Using Python, I have created a new custom metric that measure the temperature called temperature_metric you can check it online • I can manage this metric easily by pushing my own data to cloudwatch and benefit from it for monitoring purpose. • I Can add any notification system compatible with cloudwatch. • Also, I can do my own alarm system using PHP code to forward emails when required. 12/23/2015 17
  • 18. New Relic Broadcast alert 12/23/2015 18 In order to Broadcast metric notifications, we can use New Relic, because it is compatible with CloudWatch and use various channels such as: E-mail: Sends an email message to the email address specified in the configuration. HipChat: Sends a message to the HipChat room specified in the configuration. PagerDuty: Sends a notification through the NetOps administration toolPagerDuty. This is an advanced option for the more critical notifications that need to addressed immediately—the alerts can even be configured to call you on the phone! Slack: Sends a notification to the Slack channel specified in the configuration.
  • 19. New Relic Broadcast alert 12/23/2015 19 VictorOps: Similar to PagerDuty, this option sends a notification through the NetOps tool VictorOps. The functionality in the two tools is quite similar, so the choice depends mostly on what you're already using. Webhook: Sends a notification to a URL you define. Use this option if you want to send notifications to a channel that isn't currently supported directly by New Relic Alerts— or if you want to create your own custom solution... Campfire: Sends a notification to the Campfire chat room specified in the configuration. OpsGenie: Sends a notification using the OpsGenie NetOps alert system. OpsGenie is another tool similar to PagerDuty and VictorOps that can be used to make sure your team notices the alerts as they arise.
  • 20. New Relic Broadcast alert 12/23/2015 20 There is also a plan to open more notification channels in the future versions, they may add access to Lambda functions For full details about how to connect New Relic to CloudWatch and start getting notification please read this web article: http://code.tutsplus.com/tutorials/get-started- with-monitoring-your-web-application-using-new-relic- alerts--cms-24187