Safeguard
Developer Tools•

Should you log rate limit and throttling events? What to record

Yes, log rate limit hits as structured, deduplicated events with actor, route and limit. Avoid flooding your own logs by pairing summaries with counters.

Safeguard Security Team
4 min read

Yes, but log them carefully. Record the first hit and the periodic summary for each actor and route, with the limit that fired. Keep a counter for total volume. Logging every rejected request can flood your log store and turn the control into a cost and availability problem.

What a rate limit event tells you

A rate limit trips for three reasons: a broken client, a heavy but legitimate user, or abuse. The log entry is how you tell them apart later. It also proves the control works, which matters when a customer or auditor asks.

The OWASP Logging Cheat Sheet lists excessive use as an optional event class, and its Logging Vocabulary has example names such as excess_rate_limit_exceeded and excess_sessions_exceeded. The OWASP REST Security Cheat Sheet says to return 429 Too Many Requests when requests are coming in too quickly.

Fields to capture

  • Actor: user, API key ID or source address.
  • Route template, not the raw URL.
  • Which limit fired, such as per minute per key.
  • The configured limit and the observed count.
  • Window start and end.
  • Action taken: rejected, delayed, or temporarily blocked.
  • Request ID of the first rejected request.

Avoiding a flood

The OWASP Logging Cheat Sheet asks teams to make sure logging cannot be used to exhaust resources. A rate limiter that writes one log line per rejected request lets an attacker fill your log pipeline by sending more requests. See log pipeline flooding and disk fill.

TechniqueHow it worksTrade off
First hit eventLog the first rejection per actor and windowLoses count of the rest
Periodic summaryEvery minute, log a count per actor and routeSlight delay
Metric counterIncrement a counter on every rejectionNo per request detail
Escalation eventLog again when an actor crosses a higher tierNeeds state

A good default is first hit plus a summary plus a counter. The counter feeds dashboards and alerts cheaply. The events give you the detail for investigation.

What to alert on

  1. A sustained climb in total rejections, from the counter.
  2. One actor hitting limits across many routes.
  3. Many different actors hitting the same route, which may mean a campaign or a release bug.
  4. A limit that never fires on a login route, which may mean it is not working.

Rate limits are also a credential attack control, so connect them to your credential stuffing detection. The OWASP credential stuffing guidance recommends graduated responses and temporary blocks over a single fixed limit.

Steps

  1. Emit a structured event from the limiter, with the fields above.
  2. Add deduplication by actor, route and window.
  3. Add a counter metric with a low cardinality label set, route and limit name only.
  4. Test by exceeding a limit in staging and checking one event and one counter increment appear.
  5. Review limits every quarter against real traffic.

Quick check

Should the 429 response include details?

Keep it simple. A retry hint is helpful, but do not reveal internal limit logic to an attacker.

Why not log every rejected request?

Under attack that creates the flood you are trying to survive. Summaries and counters give you the picture at lower cost.

Safeguard's SBOM and dependency scanning helps you track the gateway and framework versions that enforce limits. Try a free scan at gold.safeguard.sh/scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.