okay so I'm just now in the ec2 console I've created an ec2 instance here and I've 2
just called it cloud watch test and 3
we can see here it's got out we click on monitoring and we've got our cloud watch 4
metrics set up here so the first thing I would like to do is to enable detail 5
monitoring so I'll just click on that and there we go we have no alarms 6
configured that's fine we already know how to create an alarm we've already 7
done that in the highly available and fault tolerant lip so we want to do that 8
again so let's have a look at our cloud what make cloud watch some metrics so we 9
just click on here view all cloud watch metrics okay so we can see here we've 10
got a number of metrics available but it's not going to be the same as what's 11
available in US East so I'm in asia-pacific you see me here so I'm just going to 12
jump into US East and see what it looks like so you can 13
see here we've got a lot more available in the north virginia or the US - 14
east region so that's something to be aware of that when you're when you're 15
setting up your infrastructure you know one of those things you need to consider 16
is if you're going to take advantage of cloud watch make sure that the metrics 17
you want to monitor are available in the in the region you're looking at so I'll 18
just jump back into into the asia-pacific region ok so let's have a 19
look at some ec2 metrics so we can see here we've got our I've only got one 20
instance set up in this account there in this region and so we can see here here 21
is our instance cloud watch test so let's have a look at CPU utilization so 22
just click on and select that we can see our CPU utilization there and so there 23
to cut the spikes here so I did a bit of load testing on it and just to see if it 24
would work you can see we're down quite low here so what I'm going to do now is 25
I'm going to go get back into the ec2 console and I'm going to grab the public 26
IP from this 27
okay so I'm just going to jump into a web app called loadimpact.com so they 28
allow you to do some load testing on on a server so it's pretty quick and quick 29
and easy way to go so you can create a free account in which I've just done not 30
Normally I wouldn't use this service but I just think it's if 31
you're not conversant with testing software then it's a great thing to do 32
you can just jump online here and put in your your URL of your server and where 33
you go so I'm just going to do that I've already put it in there and then I'm 34
going to rerun that test a lot of that I've already set up so I just scroll 35
down here and we can see that this is starting to happen so testing progress 36
okay so just fast forward along here the test is now finished and we can see here 37
that we've got our be used now the user virtual users you can see here we just 38
it's the service is continually adding on virtual users and there we can see as 39
our response time is getting higher and higher so it's getting up to two minutes 40
here at one stage and then it's getting to the point where it's just not not 41
getting a response back in time so you can see very very quick and easy to do a 42
very quick load test on server so it's um and it's a free service for just one 43
server so if you're not conversant with with testing software and have a 44
look at this so just jumping back into the ec2 management console and we'll 45
click on monitoring again and here you can see we've got our spike and our CPU 46
utilization here and so that corresponds with with what we're seeing over over on 47
here so that's pretty good so let's a little bit cloud watch and so here we 48
can see and we'll just refresh this and 49
there we can see we've got our big spike from the tests we done so that's coming 50
in at one-minute intervals and so that's that's looking really good so what we 51
can do now is we can look at creating a dashboard so 52
into dashboards now and they're pretty good because they allow you to put in a 53
number of different metrics for all different resources and display them on 54
a screen there so which you can which you can share with others so let's just 55
put a dashboard name in here ok so just click create dashboard so we can we just 56
do a metric graph now and then we'll look at text widgets in a sec so we're 57
just going to put metric graph on it which is going to monitor our so let's 58
have a look at our ec2 metrics and there's our CPU utilization for our 59
cloud watch test so we're going to put that on there as a widget and there it 60
is so there's our widget we can resize it we can we can do whatever you want 61
with it so it's pretty good so we can put a number of these on here so you can 62
also put different types we can put a text widget so it's a look at that okay 63
so what we've got here is is text that is being formatted with markdown so 64
markdown is just a formatting language that you use to put your text into into 65
something nice you know a little bit like HTML that puts puts a web page into 66
a nice format if you have you get up before and you've had to have the the 67
readme for the github you know the front page for your GitHub repository 68
then that will be done normally in markdown so so you'd be conversant with 69
that if you're a developer or use github so we're just going to use it as is you 70
can see here it's putting a heading and then a subheading so the the the way of 71
doing that is that hash signal followed by two of those for a 72
subheading and so that's how you create a markdown tick so just going to click 73
on create widget and you can see that it's put a nicely formatted bit of text 74
there and so they could be anything that we want to put in there and could be 75
some help screen or something like that so it's a pretty handy thing so we can 76
also get rid of it if we look on here we go delete we can 77
get rid of it and we can also get rid of this one as well a good one or two so 78
easy to put on easy to take off and then we can save our dashboard so the next 79
thing I want to look at now is events so reasonably its marked in new so reasonably 80
new service for 2016 so again we know that we have to create a rule for our 81
event to occur so this is so we got determine events of interest in the 82
cloud watch event stream create rules to select those events of interests and 83
then specify our actions to take when a rule matches an event so it's create a 84
rule okay so here we have our step one which is create rule so we can select an 85
event source so it could be an instance state change notification it could be on 86
a schedule it or it could be an AWS API call so to 87
do that you would have to implement cloud trail to make that happen we could 88
be an auto scaling event that has occurred so auto scaling invoking an 89
instance for example so they're the kind of event sources that we can use so if I 90
just click on here on on API call you can see it's not going to work because 91
we haven't got cloud trail logging turn on for this account so in the cloud 92
cloud trial lesson we'll we'll look at implementing cloud trail and then 93
setting up cloud watch to monitor those cloud cloud trail logs so in this one 94
we're just going to confine it to cloud watch we won't get involved in cloud 95
trail we'll do that in the next lesson so I just click on OK for that so I'm 96
just going to select and into the East Sea to instance change notification so 97
we can select any state let's select a specific state say something that 98
happens so when it's terminated okay so when something is terminated we want to 99
get a notification or no we want an event to occur it doesn't have to be a 100
notification it could be invoking a lambda function or something so any 101
instance or we could specify a single instance so we could specify our cloud 102
test for example we could put that in there and then we look at our targets so 103
again what our targets so they can be an SNS topic they can be an sqs queue they 104
can be a Kinesis stream or they can be a built-in target so one thing you'll 105
notice here is that there is not a lambda selection okay, so if I went into 106
because I'm in the Sydney region if I went into u.s. East there'd be another 107
another target therefore land to say something again to consider if you're 108
going to take advantage of of events make sure that the the target and 109
everything that you need is available in your region that you're using or else 110
change regions so maybe we want to put in a built in target so what do we want 111
to happen so we can create a step shop when the winner test is so so when an 112
instance is terminated we can create a snapshot of that volume and we can 113
select the volume that we're going to select a take a snapshot off okay we can 114
add additional targets and we can keep adding them in there so I just delete 115
that okay so maybe we just give the rule a name and a description and then 116
permissions so we can use a basic built-in targets role and then we do 117
allow and not allow that to happen so I'm not going to do that now but that's 118
how we can do a role and then we can click on create rule which will create 119
our rule for us so we're not going to do that I think I've gone far enough that 120
you get the the idea of how this works so what I want to do is jump into the 121
u.s. east region, so I'm just going to go back and now if we look at, and 122
then see here we've got our Lambda function so there we go so we can 123
actually have a function so we need to create the function first and then we 124
can select that function here and we can have it so when this particular event 125
occurs for anybody we could have it scheduled for every five minutes or 126
something or we can have it on a cron expression we can put in here for a 127
schedule or we could have it you know if we know auto-scaling event occurs we can 128
run this Lambda function okay so that brings us to the end of our 129
hands-on of using cloud watch as an administration tool and I'll see you in 130
the next lesson