Skip to content

Feat/implement cache stats endpoint#1950

Open
gauravshinde1729 wants to merge 2 commits into
l3montree-dev:mainfrom
gauravshinde1729:feat/implement-cache-stats-endpoint
Open

Feat/implement cache stats endpoint#1950
gauravshinde1729 wants to merge 2 commits into
l3montree-dev:mainfrom
gauravshinde1729:feat/implement-cache-stats-endpoint

Conversation

@gauravshinde1729
Copy link
Copy Markdown
Contributor

#1915

Adds a new admin endpoint to inspect on-disk consumption of the dependency and OCI proxy cache.

GET /api/v1/organizations/:organization/dependency-proxy/cache-stats/

Gated to org admins (manage scope + ActionUpdate on the organization), matching the existing org-stats endpoint. Walks the configured cache directory once and returns aggregate storage usage — overall, per ecosystem (npm, go, pypi, oci), and an OCI manifest-vs-blob split.

Companion files written by the proxy (.sha256, .releasetime, .contenttype, .digest) count toward sizeBytes but not toward entries, so the entry count reflects real cached payloads only. Ecosystems that have never been hit don't appear in byEcosystem. A missing cache directory returns zeroed stats rather than an error.

Example response:

{
  "cacheDir": "/tmp/devguard-dependency-proxy-cache",
  "totalSizeBytes": 825215,
  "totalEntries": 4,
  "oldestEntry": "2026-05-10T10:02:44Z",
  "newestEntry": "2026-05-10T22:19:52Z",
  "byEcosystem": {
    "npm": {
      "sizeBytes": 801366,
      "entries": 1,
      "oldestEntry": "2026-05-10T22:09:26Z",
      "newestEntry": "2026-05-10T22:09:26Z"
    },
    "oci": {
      "sizeBytes": 23849,
      "entries": 3,
      "oldestEntry": "2026-05-10T10:02:44Z",
      "newestEntry": "2026-05-10T22:19:52Z"
    }
  },
  "ociBreakdown": {
    "manifests": { "sizeBytes": 23849, "entries": 3 },
    "blobs":     { "sizeBytes": 0,     "entries": 0 }
  }
}

Signed-off-by: gauravshinde1729 <shindegauravpict@gmail.com>
Signed-off-by: gauravshinde1729 <shindegauravpict@gmail.com>
@timbastin
Copy link
Copy Markdown
Member

I really like this! The only concern I have is, that currently we don't have a separate cache per Organisation. There is just a single global dependency proxy cache. We should either:

  • make the cache org scoped, so that we can iterate over a subdirectory
  • wait until the instance admin feature is fully implemented (you can find an open pr for this) and let only instance admin see the total cache for all created organizations

In the end, it would be great to have both. So for you to start straight away maybe you can work on creating separate sub folders for the cache directory for each Organisation. We have to watch out for cache poisoning. Maybe we can use the org id as folder name. What do you think?

@gauravshinde1729
Copy link
Copy Markdown
Contributor Author

Sure Thanks @timbastin , That's a great idea !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants