nicolargo/glances · error · HTTPException

Cannot get plugin history {plugin} ({str(e)})

Error message

Cannot get plugin history {plugin} ({str(e)})

What it means

Raised when get_raw_history(nb) fails on the history endpoint, returned as HTTP 404. History requires the plugin's stats history buffer; failure usually means history is not available for that plugin or the export history feature is disabled/unpopulated.

Source

Thrown at glances/outputs/glances_restful_api.py:1061

    def _api_history(self, plugin: str, nb: int = 0):
        """Glances API RESTful implementation.

        Return the JSON representation of a given plugin history
        Limit to the last nb items (all if nb=0)
        HTTP/200 if OK
        HTTP/400 if plugin is not found
        HTTP/404 if others error
        """
        self._check_if_plugin_available(plugin)

        # Update the stat
        self.__update_stats(get_plugin_dependencies(plugin))

        try:
            # Get the RAW value of the stat ID
            statval = self.stats.get_plugin(plugin).get_raw_history(nb=int(nb))
        except Exception as e:
            raise HTTPException(status.HTTP_404_NOT_FOUND, f"Cannot get plugin history {plugin} ({str(e)})")

        return statval

    def _api_limits(self, plugin: str):
        """Glances API RESTful implementation.

        Return the JSON limits of a given plugin
        HTTP/200 if OK
        HTTP/400 if plugin is not found
        HTTP/404 if others error
        """
        self._check_if_plugin_available(plugin)

        try:
            # Get the RAW value of the stat limits
            ret = self.stats.get_plugin(plugin).get_limits()
        except Exception as e:
            raise HTTPException(status.HTTP_404_NOT_FOUND, f"Cannot get limits for plugin {plugin} ({str(e)})")

View on GitHub (pinned to a240d8dfb3)

Solutions

  1. Wait a few refresh cycles so the history buffer accumulates samples before querying
  2. Ensure history is not disabled on the server (--disable-history absent)
  3. Request a smaller nb within the configured history size
  4. Verify the plugin supports history (most stats plugins do; some like help do not)
Defensive patterns

Strategy: validation

Validate before calling

if time_since_server_start < 3 * refresh_interval:
    print('history buffer not yet populated; wait before querying')

Try / catch

try:
    hist = httpx.get(f'{BASE}/api/4/{plugin}/history/{nb}').json()
except httpx.HTTPStatusError as e:
    if e.response.status_code == 404:
        hist = []  # no history yet
    else:
        raise

Prevention

When it happens

Trigger: GET /api/4/<plugin>/history/<nb> when get_raw_history() raises — e.g., requesting history for a plugin without history support, or before any samples have been collected.

Common situations: Querying history immediately after server start (empty buffer), or running with --disable-history which removes the history backend.

Related errors


AI-assisted analysis of nicolargo/glances@a240d8dfb3 (2026-08-27). Data as JSON: /api/errors/9b2d3d7c781afae9. Report an issue: GitHub.