nicolargo/glances · error · HTTPException

Cannot get history for plugin

Error message

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

What it means

Raised when get_raw_history(item, nb) fails for a specific item's history, returned as HTTP 404. Item-level history requires both the plugin's history buffer and the item's presence in the stats structure; failure means one of these is missing or the underlying history export raised.

Solutions

  1. Wait for several refresh cycles so the history buffer fills
  2. Confirm history is enabled on the server
  3. GET /api/4/<plugin>/history (full history) to see which items are tracked
  4. Match item names to the current version's stats output
Defensive patterns

Strategy: validation

Validate before calling

full = httpx.get(f'{BASE}/api/4/{plugin}/history/{nb}').json()
if item not in full:
    print(f'no history tracked for {item}')

Type guard

def has_history(item: str, history: dict) -> bool:
    return isinstance(history, dict) and item in history

Try / catch

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

Prevention

When it happens

Trigger: GET /api/4/<plugin>/history/<nb>/<item> with an item that is not a history-tracked field, or before any samples exist in the history buffer.

Common situations: Querying right after server start, history disabled via --disable-history, or item names that changed across glances versions.

Related errors


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

Appendix: source

Thrown at glances/outputs/glances_restful_api.py:1220

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

        Return the JSON representation of the couple plugin/history of item
        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 history
            ret = self.stats.get_plugin(plugin).get_raw_history(item, nb=nb)
        except Exception as e:
            raise HTTPException(status.HTTP_404_NOT_FOUND, f"Cannot get history for plugin {plugin} ({str(e)})")
        else:
            return GlancesJSONResponse(ret)

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

        Return the JSON representation of the couple plugin/item description
        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 description
            ret = self.stats.get_plugin(plugin).get_item_info(item, 'description')
        except Exception as e:
            raise HTTPException(

View on GitHub (pinned to a240d8dfb3)