Using the API to create an audit log

46 views
Skip to first unread message

Bob Edmison

unread,
Jul 15, 2016, 9:25:54 AM7/15/16
to Canvas LMS API Users
Hi all.
My school is creating a central logging service for all of our systems on campus. All of the systems we host locally we can just send the syslog, etc directly to the logging service. But for hosted systems like Canvas, we are looking at other ways to get hold of things like login requests. 

I've looked through the API docs, and I think the endpoint /audit/authentication/accounts gets me what I need. I should be able to pass our institutional account id, and a date range, and get back the records I need. I know the API limits returns to 100 records per call, and I also know that if there are other records to be returned, there should be a paging parameter set in the response indicating that there are more records, or that I have found the last page. 

When calling this API, I get behavior that does not match what the docs say I can expect. First, there are no paging indicators. I know there have been more than one hundred login attempts for our account in a single day. Canvas' analytics tell me as much. Second, it appears that it is caching the results, but there is no discussion of caching behavior in the docs. Does it cache? Even without the paging, I can sometimes get a second page (page=2 URL param) of results, but when I go back to the first page, i still get the page 2 results.

Has anyone had any success using this endpoint to build an audit tool?

Thanks in advance,
Bob

Cody Cutrer

unread,
Jul 18, 2016, 1:13:09 PM7/18/16
to canvas-lms...@googlegroups.com
Bob,

It sounds like you're just blindly using page=2. You need to look for and use the Link header, as described at https://canvas.instructure.com/doc/api/file.pagination.html. The pagination links for this endpoint in particular are an opaque data structure so that you can efficiently continue getting older records, without gaps, even though newer ones are constantly being added.

Cody Cutrer
Software Engineer
Instructure

--
You received this message because you are subscribed to the Google Groups "Canvas LMS API Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to canvas-lms-api-u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bob Edmison

unread,
Jul 18, 2016, 5:54:24 PM7/18/16
to canvas-lms...@googlegroups.com
Thanks Cody.

I had read the docs, but the link header wasn't being returned when I was trying this. Is there a setting I missed that will insure the link header is returned, or was this a transient thing? 

Bob 

Sent from my iPad
Reply all
Reply to author
Forward
0 new messages