ServiceNow Scripted REST APIs: Part 20 – Reports and logs
foreign with our API development it's time to now monitor the performance of our API so let's take a look at some of the reports and logs in the servicenow platform that allow us to do this in service now there's a module called rest and soap API analytics it contains four sub-modules with a usage overview by API by requester and also an inclusion list so if we have a look at the first one usage overview you can see here as the name suggests it contains an overview of the use of all your apis in your instance okay in the last 30 days if we scroll down we can see the API usage by individual resource for each day and then the total values for the last 30 days and same to with the type of the API itself okay if we go over to usage by API then we can actually see how our particular API is performing so in our drop down list over here we can just select our vehicles API down the bottom there and apply that and similar to the overview page that we just came from you can see now the Usage Now for our particular vehicles API in the last 30 days by resource by the method that was used and so forth and if you actually drill down into one of these bars here you can actually see essentially a summary of how many transactions or requests were made to that particular resource so you don't actually see the details of the request itself we'll get to that in a little bit but you see a summary of how many transactions were performed okay so if we come back we can see again API usage by method by version and API usage in the month all right let's go to the third module here usage by requester so here we can see for our integration users that we're permitting to connect to our instance our API we can just filter this list here according to our vehicle integration user and apply that and if we come here to the actual API we see here we don't see our vehicles API yep okay we only see the table API so what you'll need to do here is come over to the inclusion list and then search for your API and then set the value of collect API request to Stats to true because by default it's set to false okay so we do that and then we come back to our usage by requester here and we go ahead and reselect our vehicle integration user and if we go to the API drop down list here we can see our API it may actually take a few minutes for it to appear there so we can now select that and now we can see here we've just made one request in the last 30 days but that's only because we've just enabled the analytics for this API for the requester so even though we actually have made more requests it's only starting to capture data right now so if we go back to post band we could actually just generate another request here send that along come back refresh the page and then we can see we've actually got uh two calls now to two different resources and we can also see the usage by Method again similar to the other Pages we've just looked at the usage by version and so forth all right so really helpful information about your API to see what version of your API is being used what resources and who's using your API so let's have a look now at some of the logs in other words have a more granular look at our API and the requests that are being made to it so in this case we'll go to our transactions application here so under system logs there are various links to transaction logs there so what we need to click on here is just transactions so not the user ones not the background jobs that are being executed not client interactions but just the general transactions so here we can see all the transactions that have been made recently if you scroll across a little bit you can actually see the UI role that's being caught here so that will actually be the clue to our API course here to see which course or which transactions have hit our API so we need to actually create a filter here it's a filter according to our API and what we need to enter here is basically the namespace of our API and I've actually taken the liberty of creating a filter here already for our vehicles API and if you have a look at the conditions in the filter you can see where the URL starts with Slash API slash xsnc VH demo okay which is my application scope okay so this will tell us all the transactions that I've hit our API irrespective of version and resource and because there is a lot of information in here what I've also done is just created a separate list view also called vehicles to show us more pertinent information such as the user that connected to our API the IP address that they came from the agent that they were using when the process actually started the response time SQL time and the URL itself which will actually tell us the resource that was here so if you need a little bit more information about who's hitting your API what resource what IP address they're coming from you can take a look at that transaction log so now you can pass off your API and the documentation the tests and the reports to your local Friendly system administrator and move on to your next task oh
https://www.youtube.com/watch?v=I3RIRlK-W4Q