Is there a Google Analytics-like solution to track REST calls to a web service? [closed]

﹥>﹥吖頭↗ 提交于 2019-11-30 01:18:08

There seem to be a few solutions out there, though they mostly seem to involve changing your API architecture.

You could potentially use one of the Google Analytics server-side tracking libraries.

I see you're using AppEngine; I also run an API using AppEngine, and recently have been playing with using a Google Analytics Library for App Engine. It's not a perfect solution, but there's a decent amount of quality data.

Be warned that Google Analytics data modeling really isn't that analagous to that of an API; depending on your API, the notion of a "visit" is somewhat meaningless.

I think Keen IO would be a great fit here. It's an API-only analytics platform (meaning that you both send data and consume analysis via a REST API).

Full disclosure: I'm the CEO. I'm not writing this answer to self-promote, but because honestly, our product was purpose-built for use cases like yours.

Several Keen IO users are API companies who use it to do analytics on how their users are using their APIs.

At the risk of being a bit too meta: We use the Keen IO API internally to collect events and perform analysis of how our customers use the Keen IO API externally, and by way of example, our two-event data model looks something like this:*

  • analysis_call
    • request (object)
      • client_library_version (string)
      • API_version (number)
      • query_parameters (key-value object)
      • post_parameters (key-value object)
      • origin_ip (ip address)
      • URI (string)
    • num_events (integer)
    • includes_geolocation (boolean)
    • user_agent (string)
    • response (object)
      • HTTP_code (number)
      • latency (number)
      • headers (object)
      • body (object: the actual full JSON response object, if under 1K)
  • events_added_call
    • client_library_version (string)
    • API_version (number)
    • origin_ip (ip address)
    • request (object)
    • response (object: the actual full JSON response object)

*We actually use a lot more properties than this, I've stripped them out to make this more clear

Well, you could use...google analytics

On the server, in a REST API handler function, make an HTTP GET request to http://www.google-analytics.com/__utm.gif with the right parameters, and you're done. Preferably async.

https://developers.google.com/analytics/resources/concepts/gaConceptsTrackingOverview

You could do this now with GA using the new Measurement Protocol the is currently in public beta.

I think what you're looking for is something like apigee: http://apigee.com

What information are you looking for specifically? You might be able to get what you need from http access logs.

I don't think google analytics can track rest calls, because it's activated by a snippet of JavaScript that you embed in your HTML.

To view the logs, you can go to the appengine console, choose your application and select Logs.

To access your logs programmatically, you've to download them (with Java, with Python), but it seems that up to now you can't do it within your app engine, so you've to do it either on your workstation or maybe on an Amazon EC2 (maybe micro) instance.

On the other hand, if you decide to store records in the DataStore, do the update within a task queue, so you don't slow down your API (Task Queues with Java, Task Queues with Python).

I think this solution might be a really good choice if you're interested in specifically tracking REST calls: http://apianalytics.com It looks like it has everything you'd need. A bit like the Mixpanel of APIs.

Disclaimer: A good friend of mine has built this

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!