RESTful and HTTP APIs in Pyramid Transcripts
Chapter: Logging and monitoring
Lecture: Why you want monitoring and logging

Login or purchase this course to watch this video and the rest of the course contents.
0:01 In this chapter we're going to add both logging and error monitoring to our web api. First of all you might ask why do we care about monitoring, right,
0:11 just our clients let us know, yeah they probably will, but there's a couple of things we kind of want to look for; we want to have extra information
0:19 so that we can be sure we know what happened, and we like to get notified before people start complaining.
0:25 This is a pretty common thing on the internet, ooh our web application is crashed, boom 500 sorry and it's cool to have like a fun error page
0:33 so at least it doesn't feel so bad, right, but when our application crashes, we want to have all the information that led up to this,
0:40 what browser were they using, what exactly set of steps did they take what was the url, was there a query string, where they logged in
0:48 who were they longed in as, all these things are super important, so having that in the log file is great, getting that notification exactly
0:54 when this error happens like maybe to our Slack channel or to our email would be even better. So, eventually when the user comes back in contact us
1:02 about the error and says hey I had this problem, we can say yeah we're already researching it we know what happened, we're going to fix it shortly.
1:09 That's the perfect answer if something goes wrong, right. So, in this chapter we'll see how to do that.
1:13 All right, first of all let's look at the log file, so here's the log file from Talk Python training
1:18 and there's a number of interesting things to see about it I've actually cleaned up some of the data
1:25 so that we don't have like personal email addresses or the other things like that that maybe shouldn't appear in a public course,
1:31 but just pulling up this log file shows us some really interesting things. So, for example, we can see user actions, like here our user is logged in,
1:40 here's another user action, somebody subscribed to the mailing list, and here's another, this person has logged out at this ip address.
1:48 So this is standard application operations, right and we issue this to the log files a notice
1:54 like these are kind of significant events in the application life cycle, but they're not highly important, right they're just stuff going on.
2:02 Now, we also have other things that maybe you wouldn't have expected search engines, so down here you can see the search engines are trying
2:08 to dig into the actual course videos themselves, they shouldn't be doing that, I don't know why they're trying to go here
2:15 I don't really care but you can see that there is some four or four type stuff happening around googlebot or something compatible with googlebot,
2:23 but I'm not sure what the heck that is; there's also other interesting stuff that shows up, for example here's somebody trying to hack the website
2:29 so they're looking for the wp login php page which is what wordpress uses as its backend to give you an admin access to the site
2:39 as you probably know, this site is built with Python, IT's a custom site there is no wp login so those hackers can just take off right,
2:45 nothing really important happened here, but it's interesting to know that someone was actually trying to hack us
2:51 in fact this happens all the time, it's happening here, and also down here. So the log file lets us know what's going on in our application
2:58 and we'll even discover certain things like why are the search engines trying to get to the private videos, I don't know,
3:06 but having a log file turns out to be really helpful just in understanding how your apps are being used as well.
3:11 So this equally applies to web applications as it does to web apis. Now, if something goes wrong, we want to know about it as soon as possible
3:19 so we'll briefly talk about setting up Rollbar which is what I use for my web applications you can really easily integrate Rollbar into Pyramid
3:29 and it will automatically capture all these errors and send them your way.


Talk Python's Mastodon Michael Kennedy's Mastodon