Skip to content
This repository has been archived by the owner on Jan 24, 2018. It is now read-only.

Updates to JSON-based API for stats #162

Merged
merged 8 commits into from
Sep 3, 2015

Conversation

captainsafia
Copy link
Member

I think I'll do this specific issue in two chunks. First will be purely the JSON API at /api/stats and second will be the visual page at /stats/.

Let me know how it looks.

'version': '0.1.0',
'container_image': self.pool.container_config.image,
'docker_version': self.spawner.docker_client._docker_client.version(),
'docker_containers': self.spawner.docker_client._docker_client.containers()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to be a long-blocking call that won't hold up well in quick calls for stats on e.g. try.jupyter.org. As much as I'd want to see it, this isn't practical in current Docker and Go versions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto. I got too excited thinking about all the cool things I was gonna do with D3 and this to think about performance.

I'll take it out for now, but I'll give it more thought in a future iteration of the stats page perhaps?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's ok. It's only this call to the number of containers and likely only affects the larger deployments (>500 users/containers in the pool). This number is also likely to be redundant as the number of containers equals the capacity + is tmpnb containerized + is the proxy containerized + any another containers.

I'd keep the capacity and available metrics instead.

@rgbkrk
Copy link
Member

rgbkrk commented Aug 31, 2015

All in all, awesome! I'm looking forward to this.

@@ -232,7 +233,7 @@ def main():
(r"/spawn/?(/user/\w+(?:/.*)?)?", SpawnHandler),
(r"/api/spawn/", APISpawnHandler),
(r"/(user/\w+)(?:/.*)?", LoadingHandler),
(r"/stats", StatsHandler),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I'm thinking about it, we should probably have both /stats and /api/stats use the APIStatsHandler while also changing the tmpnb redirector.

Then folks can do migrations (ourselves included). After the deployments we know about have migrated (if they want to), then we'll change /stats to the new page you're working on.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new human page can be at /statistics or /info rather than re-using the URL.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that better! Then we can keep /stats as a redirect and /api/stats as the canonical. Thanks as always @minrk. We could use /status as well for the user view.

@captainsafia
Copy link
Member Author

Ditto — updates coming later tonight.

I'll go ahead and include the visualizations on this PR as well.

@@ -69,13 +69,14 @@ def get(self, path=None):
self.render("loading.html", path=path)


class StatsHandler(BaseHandler):
class APIStatsHandler(BaseHandler):
def get(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're at it, can you add self.set_header("Content-Type", 'application/json') to the APIHandler?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sir!

effbd25aa080b73d6ccd1a37487a2850

@rgbkrk
Copy link
Member

rgbkrk commented Sep 3, 2015

@captainsafia
Copy link
Member Author

@rgbkrk — This is not 100% what I was aiming for, but I think this should be good enough for an initial stats page.

In the future, I'd like to make the plot area-based to better show the proportionally between used and unused containers.

Not sure if you want to merge this and make an initial release or have me modify the visuals on this PR.

@rgbkrk
Copy link
Member

rgbkrk commented Sep 3, 2015

I'd like to see capacity in here too, but we can follow on.

In the future, I'd like to make the plot area-based to better show the proportionally between used and unused containers.

Yeah, that would be nice. Still in a time series view, but area based (as a proportion of capacity).

We can always merge this and follow on right after. This hits exactly what we need for the time being.

rgbkrk added a commit that referenced this pull request Sep 3, 2015
Updates to JSON-based API for stats
@rgbkrk rgbkrk merged commit cb5fff7 into jupyter:master Sep 3, 2015
@captainsafia
Copy link
Member Author

Yep! A wise man once said "Let's merge and iterate" 😉

@rgbkrk
Copy link
Member

rgbkrk commented Sep 3, 2015

Looking good!

screenshot 2015-09-03 16 56 15

@rgbkrk
Copy link
Member

rgbkrk commented Sep 3, 2015

(on my 4 node system 😉)

@rgbkrk
Copy link
Member

rgbkrk commented Sep 4, 2015

The more I thought about it, the more I realized that showing the volume relationship is a matter of using capacity and available containers, where the labels are adjusted...

@captainsafia
Copy link
Member Author

@rgbkrk — What do you mean by that? The way I imagined the final product looking was a stacked area chart (see awful drawing below).

20150904_114322

@rgbkrk
Copy link
Member

rgbkrk commented Sep 4, 2015

You and I are talking about the same thing, yours has the right terminology though. 😄 We definitely want a stacked area chart.

What I'm trying to say is algebraic in manipulation. 😉 The area between available and capacity is the used curve. If we plot capacity and available, used is the space between. It's the labels that change (and axes).

@captainsafia
Copy link
Member Author

Yep yep yep. Opening up an issue for this. Thinking it might be in the 0.2.0 release.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants