question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not showing (caused by 404 on Endpoint /api/metrics/v1?)

See original GitHub issue

I have the installed this package via pip, yet no memory usage is shown in the jupyter GUI.

I have the following:

jupyter-client            6.1.7
jupyter-console           6.2.0
jupyter-core              4.6.3
jupyter-packaging         0.7.12
jupyter-resource-usage    0.5.1
jupyter-server            1.4.1
jupyterlab                3.0.10
jupyterlab-execute-time   2.0.2
jupyterlab-git            0.23.3
jupyterlab-latex          2.0.0
jupyterlab-pygments       0.1.2
jupyterlab-server         2.3.0
jupyterlab-system-monitor 0.8.0
jupyterlab-topbar         0.6.1
jupyterlab-vim            0.13.4
JupyterLab v3.0.10
/home/jooa/.local/share/jupyter/labextensions
        jupyterlab-execute-time v2.0.2 enabled OK (python, jupyterlab_execute_time)
        jupyterlab-topbar-extension v0.6.1 enabled OK (python, jupyterlab-topbar)
        jupyterlab-system-monitor v0.8.0 enabled OK (python, jupyterlab-system-monitor)
        @axlair/jupyterlab_vim v0.13.4 enabled OK (python, jupyterlab_vim)
        @jupyter-server/resource-usage v0.5.0 enabled OK (python, jupyter-resource-usage)

Other labextensions (built into JupyterLab)
   app dir: /home/jooa/.local/share/jupyter/lab
        @jupyterlab/debugger v3.0.7 enabled OK
        @jupyterlab/git v0.23.3 enabled  X
        @jupyterlab/toc v5.0.6 enabled OK
        jupyterlab-theme-toggle v0.6.1 enabled OK
        nbdime-jupyterlab v2.0.1 enabled  X

   The following extension are outdated:
        @jupyterlab/git
        nbdime-jupyterlab

Yet,

Mar 23 18:59:00 vm-129-69 jupyter[1806765]: [W 2021-03-23 18:59:00.435 ServerApp] 404 GET /jupyter/api/metrics/v1?1616522340417 (193.174.53.84) 1.03ms referer=[snip]

appears in the logs.

Why is the endpoint returning a 404? What am I missing?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
joekohlsdorfcommented, Apr 5, 2021

I was able to fix it, if you start Lab with --log-level DEBUG flag you can see that the configuration path ~/.local/etc/jupyter is not searched. I don’t know how to adjust the search paths but symlinking it to ~/.jupyter works.

FROM python:3

RUN groupadd -g 1000 python
RUN useradd -m -d /opt/python -u 1000 -g python python

USER python
ENV PATH /opt/python/.local/bin:$PATH
RUN pip install --user --no-cache-dir jupyterlab jupyter-resource-usage
RUN ln -snf /opt/python/.local/etc/jupyter /opt/python/.jupyter

EXPOSE 8888
CMD [ "jupyter", "lab", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--ServerApp.token=''", "--ServerApp.password=''" ]
docker build -t jupyter-resource-usage-91-ln . 
docker run -it --rm -p8888:8888 jupyter-resource-usage-91-ln
1reaction
casparvlcommented, Jul 8, 2022

I had the same problem, but it was not resolved by the symlinking solution suggested above. I traced it down to what is probably a version conflict between the version of jupyter (or probably more specifically: of notebook) I’m using, and the jupyter-resource-usage package. My versions are:

$ jupyter --version
jupyter core     : 4.7.1
jupyter-notebook : 6.4.0
qtconsole        : not installed
ipython          : 7.25.0
ipykernel        : 6.0.0
jupyter client   : 6.1.12
jupyter lab      : not installed
nbconvert        : 6.4.0
ipywidgets       : 7.6.3
nbformat         : 5.1.3
traitlets        : 5.0.5

My original issue was as reported here: memory usage wasn’t showing, and the debugging console of my browser showed a 404 on /api/metrics/v1.

I ran a jupyter serverextension list, but that showed up empty. While my notebook version should be new enough to find and enable extensions by default, I tried to run

jupyter nbextension enable --py jupyter_resource_usage
jupyter serverextension enable --py jupyter_resource_usage

just to be sure. The second command gave me an error:

  File "/sw/arch/Debian10/EB_production/2021/software/IPython/7.25.0-GCCcore-10.3.0/lib/python3.9/site-packages/notebook/serverextensions.py", line 327, in _get_server_extension_metadata
    raise KeyError(u'The Python module {} does not include any valid server extensions'.format(module))
KeyError: 'The Python module jupyter_resource_usage does not include any valid server extensions

Inspecting the code snippet that threw the error (serverextensions.py, around line 327):

def _get_server_extension_metadata(module):
    """Load server extension metadata from a module.

    Returns a tuple of (
        the package as loaded
        a list of server extension specs: [
            {
                "module": "mockextension"
            }
        ]
    )

    Parameters
    ----------

    module : str
        Importable Python module exposing the
        magic-named `_jupyter_server_extension_paths` function
    """
    m = import_item(module)
    if not hasattr(m, '_jupyter_server_extension_paths'):
        raise KeyError(u'The Python module {} does not include any valid server extensions'.format(module))
    return m, m._jupyter_server_extension_paths()

I had another notebook server extension around that was working, and it had the following code snippet in its __init__.py:

# For backward compatibility
load_jupyter_server_extension = _load_jupyter_server_extension
_jupyter_server_extension_paths = _jupyter_server_extension_points

Aha, that comment seems to suggest that it used to be called _jupyter_server_extension_paths (and clearly that was the case in my serverextension.py, and is now called _jupyter_server_extension_points. However, jupyter-resource-usage only sets the latter, and thus is (I think) not backwards compatible with my version of notebook.

The dead simple solution was to add _jupyter_server_extension_paths = _jupyter_server_extension_points to the end of the __init__.py file of jupyter-resource-usage. After that, my issue was fixed. I’ll make a PR for this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Boot: Cannot access REST Controller on localhost (404)
@AjayTakur the server is up and running, the requests are sent but there is no endpoint to process them. In order for the...
Read more >
Solved: ANC Endpoint API gives a HTTP 404 - Cisco Community
Solved: I'm trying to apply an ANC policy using the ERS API URI of " /ers/config/ancendpoint/apply " but ISE only returns an HTTP...
Read more >
404 Unable to identify proxy for host: <virtual host name> and url
If the ProxyEndpoint is configured to accept the requests on the default VirtualHost , go to the next cause - Path not associated...
Read more >
Error 404: 4 Ways to Fix It - Hostinger
Error 404 is a response code, meaning the server could not locate the requested content. Check this article to learn 4 steps to...
Read more >
Troubleshooting Azure CDN endpoints - 404 status code
Cause. There are several possible causes, including: The file's origin isn't visible to the CDN. The endpoint is misconfigured, causing ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found