Instructor: So for our demo,
we'll use again our loyal Beeceptor
this time in a slightly different domain.
So the domain we will monitor is apicourse1,
and if we will take a look at the mocking rules
we will see we have our regular URL of api v1 order.
This is the endpoint we would like to monitor.
Now the monitoring engine, we will use
is the Application Insights of Azure, Microsoft Azure,
which is the public cloud of Microsoft.
And it has a very good monitoring engine.
Of course, it is not the only monitoring engine out there.
There are a few, but I personally always prefer
the Application Insights.
Now, if you don't have an Azure account,
you can always sign up for a free account with $200 credit.
And the Application Insights is basically free.
So you can use it as much as you want.
So we are in the Azure portal
and let's build the monitoring.
So we will go here and write application insights
and let's add a new monitor,
select Resource Group,
and let's give it a name
and I'll call it Beeceptor-monitor,
and let's create this monitor.
And in a few seconds,
we will have a monitoring engine ready to use.
The deployment is going through,
and the deployment is ready.
So let's go to the resource, which is the monitor.
And we have a lot of chart here
that right now naturally displays nothing.
Now let's click the availability.
and let's add test.
So what we are going to do here in the test
is to define the kind of monitoring
we would like to perform on our website.
Now we want to keep the monitoring in this demo
as basic as possible without modifying
and without writing any code.
So this monitoring will be only external,
meaning we will ask the Application Insights
to ping our website periodically
and collect data about its availability.
So the test name will be Beeceptor-availability.
We would like to perform ping test.
And the URL we would like to ping is,
let's copy it from here,
and paste here.
V1, sorry, api-v1 order.
This test will be performed every five minutes.
It'll be performed from five locations
which is great, because our API should be global
and we would like it to be tested
from as many locations as possible,
and in this case, five are great.
From the United States, in its West, South,
North Central, East, Central US.
Let's also add Japan East, UK West,
and West Europe.
Great. Now, what is a success criteria for this test?
If the endpoint returns 200,
which is as you probably remember, an okay status
then the test succeeded.
Great, so let's create it.
And now let's let it run.
So I'll pose the recording and I'll come back
in a few minutes when we will already
have some results to look at.
Okay, so we are back.
So what we see here is
that the monitor made 23 successful request
and not a single request failed.
And if you will look at the chart here,
let's just focus on the time slice
that is interesting for us.
Then you can see the data here,
we have a 100% overall availability, which is great.
Now let's go back here to the Beeceptor
and let's modify the rule that instead of returning 200
let's return 400, which is bad request.
And let's go back to the monitor,
and again, I'll pose the recording
and let's come back in a few minutes.
And we are back, and look what we have here.
We can see here clearly there is a problem
with the availability of our website,
and if you will hover above this point in the chart
we can see that the availability right now is 0%.
And we can see here there will four failed requests.
And if you will click here,
we can see that we have four requests
that have failed which is actually exactly
what we wanted to happen.
Again because we modified the response code of our request,
and as you probably remember, we defined the test
that only a 200 status code designates a successful test.
So that concludes our demonstration on monitoring.
Again, this monitoring is extremely basic
and we can achieve a lot more using
this tool as well as other tools.
But the bottom line is the same.
Always make sure to monitor your API
so that you will know when there is a problem
or a developing problem with the API
that might harm your user's experience.