---
title: Sampling events
description: Send a percentage of events from your JavaScript application to Honeybadger Insights to manage quota consumption.
url: https://docs.honeybadger.io/lib/javascript/insights/sampling-events/
---

If you’d like to report fewer events in order to minimize your quota consumption, set `events.sampleRatePercentage` when configuring Honeybadger:

```javascript
Honeybadger.configure({
  events: {
    sampleRatePercentage: 10,
  },
});
```

This sends approximately 10% of events. When an event carries a `request_id` (for example, from [automatic HTTP instrumentation](https://docs.honeybadger.io/lib/javascript/insights/automatic-instrumentation/)), sampling is deterministic per request: all events from the same request are kept or dropped together. Events without a `request_id` are sampled randomly.

## Per-event sampling override

You can override the configured sample rate for a single event by setting `_hb.sampleRate` (a number from 0 to 100) on the event data or in a `beforeEvent` handler. The `_hb` key is stripped before the event is sent.

```javascript
Honeybadger.event("debug.trace", {
  detail: "noisy",
  _hb: { sampleRate: 1 },
});
```

Or via a handler:

```javascript
Honeybadger.beforeEvent((event) => {
  if (event.event_type === "request.handled" && event.status < 400) {
    event._hb = { sampleRate: 5 };
  }
});
```

To ignore specific events instead of sampling across the board, see [Filtering events](https://docs.honeybadger.io/lib/javascript/insights/filtering-events/).

---

## Try Honeybadger for FREE

Intelligent logging, error tracking, and Just Enough APM™ in one dev-friendly platform. Find and fix problems before users notice.

[Start free trial](https://app.honeybadger.io/users/sign_up)

[See plans and pricing](https://www.honeybadger.io/plans/)
