Commit a764f90
committed
Add a /metrics endpoint for Prometheus Metrics
[Prometheus](https://prometheus.io/) provides a standard
metrics format that can be collected and used in many contexts.
- From the browser
to drive 'current resource usage' displays, such
as https://github.com/yuvipanda/nbresuse
- From a prometheus server
to collect historical data for operational analysis and
performance monitoring
Example: https://grafana.mybinder.org/dashboard/db/1-overview?refresh=1m&orgId=1
for mybinder.org metrics from JupyterHub and BinderHub,
via prometheus server at https://prometheus.mybinder.org
The JupyterHub and BinderHub projects already expose Prometheus
metrics natively. Adding this to the Jupyter notebook server
allows us to instrument the code easily and in
a standard format that has lots of 3rd party tooling for it.
This commit does the following:
- Introduce the `prometheus_client` library as a dependency.
This library has no dependencies of its own and is pure python.
- Add an authenticated `/metrics` endpoint to the server,
which returns metrics in Prometheus Text Format
- Expose the default process metrics from `prometheus_client`,
which include memory usage and CPU usage info (for just the
notebook process)1 parent faa0cab commit a764f90
2 files changed
+14
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
809 | 810 | | |
810 | 811 | | |
811 | 812 | | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
812 | 823 | | |
813 | 824 | | |
814 | 825 | | |
| |||
825 | 836 | | |
826 | 837 | | |
827 | 838 | | |
| 839 | + | |
828 | 840 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
| 91 | + | |
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| |||
0 commit comments