Cloudwatch For Aws
Cloudwatch For Aws
CLOUD WATCH:
It is used for various purposes like MONITORING, ALARMS, DASHBOARDS, LOGS AND
SCALING
It is used to monitor various AWS services.
It allows us to record metrics for aws services like EC2, EBS, ELB AND Amazon S3.
We can setup alarms for our EC2 Instances
HOW IT WORKS:
Once we launch an instance if the CPU utilisation of instance is above 80% then alarm
will be triggered
Once alarm is triggered you will get notified by SNS service
HOW TO SETUP:
HERE OUR ULTIMATE AIM IS TO MONITOR THE INSTANCE, WHEN CPU UTILISATION IS MORE
THAN 50% THEN WE HAVE TO GET A MAIL. SO WE CAN PERFORM THE ACTION AS PER THE
REQUIREMENT.
select EC2
select Pre-Instance Metrics and then you will get a lot of instances like this
i have entered the topic name and my email id and click on create topic
This will send a notification to our mail, we have to confirm the subscription on our mail.
click on next
open the second session and use following command to increase cpu utilization
stress -c 40 -t 500 -v
-c : cpu
-t : time
-v : verbose
by this command we are giving some load to cpu, after performing the command
meanwhile you can watch this in cloud watch also, open cloud watch and open your alarm
After waiting few minutes, by graph reached to 62% above in cloud watch
Enter
acces_key : enter
secret_key : enter
default_region : enter
O/p_format : enter
vim /var/awslogs/etc/awslogs.conf ——> this is the path where we can store all the log files
paths
First lets check these files are storing in cloud watch or not, if its working fine then we can
start store our app log files.
AFTER DEPLOYED THE APPLICATION, WE HAVE TO CHECK THE APP LOGS IN (vim
/var/log/apache2/access.log file
TO DO THAT
Go to the last line of the file and copy the data as it is (change path)
But now a days most of the companies are moving to cloud, if your choice is AWS
They will take care each and everything about these databases and maintenance
username: admin
password: mypassword
In this instance configuration step select db.t2.micro which is completely free tier
Finally click on create database it will take atleast 5 minutes to create our database.
INSTALL MYSQL:
Go to security groups >> select MY-RDS security groups and click on edit inbound rules >>>
You will find a database schema/query (db_backup.sql) that you have to deploy on database.
TRY TO CREATE AN ACCOUNT INTO THE APPLICATION YOU WILL GET HTTP 500 ERROR
username : admin
pasword : mypassword
endpoint : database-1.ccrlrczntuiv.ap-south-1.rds.amazonaws.com
jdbc.url=jdbc:mysql://database-1.ccrlrczntuiv.ap-south-
1.rds.amazonaws.com:3306/accounts?useUnicode=true&characterEncoding=UTF-
8&zeroDateTimeBehavior=convertToNull
jdbc.username=admin
jdbc.password=mypassword