Quotas

With the way Sentry works you may find yourself in a situation where you’ll see too much inbound traffic without a good way to drop excess messages. There’s a few solutions to this, and you’ll likely want to employ them all if you are faced with this problem.

Event Quotas

One of the primary mechanisms for throttling workloads in Sentry involves setting up event quotas. These can be configured per project as well as system wide and will allow you to limit the maximum number of events accepted within a 60 second period of time.

Configuration

The primary implementation uses Redis, and simply requires you to configure the connection information:

Copied
SENTRY_QUOTAS = 'sentry.quotas.redis.RedisQuota'

By default, this will use the default named Redis cluster. To use a different cluster, provide the cluster option, as such:

Copied
SENTRY_QUOTA_OPTIONS = {
    'cluster': 'quota',
}

If you have additional needs, you’re freely available to extend the base Quota class just as the Redis implementation does.

System-wide Rate Limiting

You can configure the system-wide maximum per-minute rate limit:

Copied
system.rate-limit: 500

For example, in your project's sentry.conf.py, you can do something like this:

Copied
from sentry.conf.server import SENTRY_OPTIONS


SENTRY_OPTIONS['system.rate-limit'] = 500

Alternatively, if you navigate to /manage/settings/ you will find an admin panel with an option for setting Rate Limit, which gets stored in your quota implementation described above.

User-based Rate Limiting

You can configure the user-based maximum per-minute rate limit:

Copied
auth.user-rate-limit: 100
auth.ip-rate-limit: 100

Project-based Rate Limiting

For doing project-based rate limiting, click on a project's Settings. Under the Client Keys (DSN) tab, find the key that you'd like to rate-limit, and click the corresponding Configure button. That should bring up key/project-specific rate-limiting settings.

Notification Rate Limits

In some cases there may be concerns about limiting things such as outbound email notifications. To address this Sentry provides a rate limits subsystem which supports arbitrary rate limits.

Configuration

Like event quotas, the primary implementation uses Redis:

Copied
SENTRY_RATELIMITER = 'sentry.ratelimits.redis.RedisRateLimiter'

By default, this will use the default named Redis cluster. To use a different cluster, provide the cluster option, as such:

Copied
SENTRY_RATELIMITER_OPTIONS = {
    'cluster': 'ratelimiter',
}
You can edit this page on GitHub.