MongoDB Stitch Analytics

Hi there,

If MongoDB Team is not planning to add Stitch analytics soon, I would like to try implementing it myself. What do I mean by analytics:

  • Request count/hour timeline
  • Errors count/hour timeline
  • User browser pie chart
  • Total time spent per function
  • Total execution count per function
  • Total error count per function
  • Current active users (users active in the last 30 min ?)

How?

  • Scheduled trigger that collects “new” stitch logs and stores the logs in a “unprocessed” collection. Because of the function execution time limit I would have to come up with some logic to remember last saved unprocessed timestamp/log id. Next trigger run should start from the lat save timestamp/log_id.
  • Another scheduled trigger that aggregates the unprocessed data and stores the result in “processed” collection.
  • Use MongoDB Charts to display different types of graphs.

Possible problems?

  • Too many logs
  • Slow log API
  • Function execution time limit

What do you think about this idea?

P.S.If others find it useful, I would happily share my code when it’s ready.

Hi Dimitar –

This actually matches up with a project that we are hoping to do later this year (exposing more of a realtime view into the usage of an application). That being said, having this integrated into the UI is still probably a few months off and if you want to build something else for your own application in the meantime, then the approach that you’ve outlined makes sense.

Another approach that we have seen folks take is polling the Logs API then then forwarding to another Logs system that they can use to monitor/alert on the load on Stitch. We are looking into a more formal process for logs forwarding for the future that might take the place of this.

1 Like

Hi Drew,
Thanks for you answer. I must admit I did not even know that there are services that do “log management”. I’ll look into these kind of systems and will probably skip implementing it myself. Looking forward to see what Stitch team will implement in the future.

1 Like