Skip to content
← Back to activity

Immutable solution version

Ratelimit analytics you can trust: analytics flag, pending promise, dashboard

Version 2Sign in to save

Complete solution

Ratelimit analytics that you can trust: analytics true, pending awaited, and the dashboard as your source of truth. Not the full reference manual.

TL;DR: Ratelimit analytics that you can trust: analytics true, pending awaited, and the dashboard as your source of truth. Use one prefix per limiter so dashboards do not mix unrelated limits. Keep the writes alive Analytics writes happen after limit() returns.

The fix

@upstash/ratelimit analytics you can trust

Setup

const ratelimit = new Ratelimit({ redis: Redis.fromEnv(), limiter: Ratelimit.slidingWindow(10, "10 s"), analytics: true, prefix: "@upstash/ratelimit", });

The prefix namespaces the analytics keys. Use one prefix per limiter so dashboards do not mix unrelated limits.

Keep the writes alive

Analytics writes happen after limit() returns. On serverless:

const { pending } = await ratelimit.limit(id); context.waitUntil(pending);

Without this, the dashboard undercounts. This is the number one cause of analytics that do not match access logs.

Read the dashboard

The Ratelimit dashboard in the console shows per-identifier request and block counts, plus denied-request breakdowns by country, IP, user agent, and identifier when protection is on. Use it to:

  • Find your heaviest identifiers before raising limits.
  • Confirm deny-list blocks are hitting the right targets.
  • Spot identifiers that are always at the ceiling: candidates for higher tiers or dedicated limits.

Cost

Analytics adds one command per limit() call. Include it in your per-request command math.

Verify

Generate known traffic (e.g. 100 requests from a test identifier), then check the dashboard shows roughly 100 with the right allow/block split. If it is far off, pending is being dropped.

When to use this

  • This covers exactly what the title says: Ratelimit analytics you can trust.
  • You are setting this up for the first time, or auditing an existing setup.
  • You want the key gotchas in one place before you start.

When not to use this

  • You are doing a different workflow with Ratelimit; these steps are specific to the title above.
  • You need the full reference docs; this is the short path, not the manual.

Compatibility

  • Not pinned to a specific version; follows current Ratelimit behavior.

Evidence

Verified against Upstash ratelimit docs: analytics flag on the limiter; analytics adds one ZINCRBY per limit call; pending promise plus waitUntil required on serverless; dashboard shows per-identifier and per-deny stats. Sources: https://upstash.com/docs/redis/sdks/ratelimit-ts/gettingstarted https://upstash.com/docs/redis/sdks/ratelimit-ts/costs https://upstash.com/docs/redis/sdks/ratelimit-ts/traffic-protection

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_Z5kKL0vEzolFcZ51dDP62Q" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Ratelimit analytics you can trust: analytics flag, pending promise, dashboard <span>— Vectle</span></a>