Skip to content

Allow users to opt out of prometheus metrics #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ As a command line argument:
jupyter notebook --ResourceUseDisplay.track_cpu_percent=True
```

### Disable Prometheus Metrics

There is a [known bug](https://github.com/jupyter-server/jupyter-resource-usage/issues/123) with Prometheus metrics which
causes "lag"/pauses in the UI. To workaround this you can disable Prometheus metric reporting using:

```
--ResourceUseDisplay.enable_prometheus_metrics=False
```

## Resources Displayed

Currently the server extension only reports memory usage (just RSS) and CPU usage. Other metrics will be
Expand Down
7 changes: 7 additions & 0 deletions jupyter_resource_usage/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,10 @@ def _mem_limit_default(self):
@default("cpu_limit")
def _cpu_limit_default(self):
return float(os.environ.get("CPU_LIMIT", 0))

enable_prometheus_metrics = Bool(
default_value=True,
help="""
Set to False in order to disable reporting of Prometheus style metrics.
""",
).tag(config=True)
13 changes: 9 additions & 4 deletions jupyter_resource_usage/server_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ def load_jupyter_server_extension(server_app):
".*", [(url_path_join(base_url, "/api/metrics/v1"), ApiHandler)]
)

callback = ioloop.PeriodicCallback(
PrometheusHandler(PSUtilMetricsLoader(server_app)), 1000
)
callback.start()
if resuseconfig.enable_prometheus_metrics:
callback = ioloop.PeriodicCallback(
PrometheusHandler(PSUtilMetricsLoader(server_app)), 1000
)
callback.start()
else:
server_app.log.info(
"Prometheus metrics reporting disabled in jupyter_resource_usage."
)