MARK MIRCHANDANI: Juggling is hard.
STEPHANIE WONG: Yeah, this is even harder
than setting up logging and monitoring
for my cloud infrastructure.
MARK MIRCHANDANI: Actually, if you use Stackdriver,
it's a piece of cake.
STEPHANIE WONG: What's that?
MARK MIRCHANDANI: Stackdriver is a tool
that lets you monitor and get insight into your applications.
STEPHANIE WONG: Sounds useful.
How do we get started?
MARK MIRCHANDANI: Let me jump right into a demo.
OK.
To start things off, we're going to take an instance that I've
just set up here and go ahead and install
Apache and PHP into it as kind of a basic example.
So I'll go ahead and SSH into this.
And this is just a brand new small instance
I've set up that I haven't done anything with yet.
But we want to make sure that we actually
have something to monitor.
Of course, using Stackdriver, you kind of
want to monitor and log different events that
are going to come out of, in this case, the default
Linux properties.
But you can easily configure that to add additional logging.
We're just going to step through the basics here.
So I'll go ahead and install Apache and PHP.
Go ahead and let these update.
And once those are done, we'll make sure everything
looks good, and then we'll install the actual Stackdriver
agents.
So nothing special here.
Let these run through.
OK, we'll skip that 30 seconds.
And now that it's all set up, we'll
go ahead and make sure everything
looks good by bringing up this in a new tab.
And we can see, there we go, we have Apache2
successfully installed.
So now what we're going to do is actually
install the agent itself.
We're going to go ahead and look at a quick script that
basically just grabs the different agents,
the monitoring agent and the logging agent,
and then installs them.
So we'll go ahead and run those.
And while that's happening, we'll
go ahead and take a look at the Stackdriver interface.
That will probably take about a minute.
So we know that Apache works.
And in the Google Cloud console, we
can take a look for Stackdriver.
Now, if this is your first time setting up Stackdriver
or clicking on this monitoring link which takes you
to the Stackdriver interface, you
may have to go through a small set up process.
Basically, you're just going to choose
what GCP project you're using and some other small set
of steps.
That can take another couple of minutes as well.
But once you have that set up, you
can easily just come to this interface
and switch projects like you might already be familiar with.
So once we kind of have those logs installed,
we should be able to go here to resources, click on instances,
and we should see that the instance is set up right here.
You can see another instance that I had set up earlier,
but lamp instance is the one we want to take a look at.
So I'll click on that.
And you can see just by kind of running that quick command
line, we have the agent installed,
and it's already monitoring some of the more standard metrics
that you might see on an instance,
including CPU and memory usage, network throughput,
these kind of things.
So this is a great way to kind of just quickly
get that set up.
One of the other great things you can do in Stackdriver
is actually set up a dashboard.
So if you go to Dashboards and hit Create Dashboard,
you can start to add charts.
Charts are basically these metrics
that you're going to be able to select from a list here.
And kind of choosing your instance,
get a better understanding of creating a custom monitoring
dashboard for the metrics that you actually care about.
One of the other important aspects of Stackdriver
is going to be alerting.
So by setting up an alerting policy,
we can easily take a metric on an instance
and tell Stackdriver to notify us when something happens.
So if we go ahead and add an example condition,
such as our instance here--
oh, we already have an instance.
We'll pick our lamp instance, and we
can go ahead and choose something like, if the CPU load
average is above 80%--
that might be something that we're concerned about,
because maybe that means our web server is
serving too much traffic or some process is locked.
We'll go ahead and choose that.
And then we'll add the notification.
So here we can add an email, we can
add an SMS, a couple of different integration options
here.
There are tons of things we can do.
And then in documentation, we can just
add some additional texts in case
we want to set up some more advanced monitoring or just
in case we want to know what kind of flag
or what group this was set to, we
can use that for custom text.
Name the policy, and then save it.
And that way, we'll get notified in case anything happens.
Now, the next part we'll look at is the actual logging.
So if we come here and click on logging,
we can see the default logging interface which
is also using Stackdriver.
On this dropdown here, we can choose what instance
we want to look at.
In our case, we're going to look at lamp instance.
And in the subsequent filter, we're
going to go ahead and choose syslog.
Once we've set that to the filter,
we can see all the different things
that have been sent to syslog, just so that we can measure
whatever applications might be using or whatever
any other loggings--
well, anything that gets sent to syslog, really.
Just like that, you can set up logging, monitoring, and more.
STEPHANIE WONG: Great.
Now I'll have a real grip on my application in the cloud.
MARK MIRCHANDANI: Yeah.
If only it was that easy to learn how to juggle.
STEPHANIE WONG: Don't forget to comment, like, and subscribe.
MARK MIRCHANDANI: And if you want to get in contact with us,
click on the link in the description.