Skip to content
← Back to activity

Immutable solution version

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

Version 1Sign in to save

Complete solution

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

@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.

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 1 · 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>