Guides / Monitoring

Alert When Errors Spike Using Smart Actions

4 min read·Monitoring

The Problem

Error bursts rarely announce themselves. You ship a release, the error rate quietly spikes, and you find out from a support ticket 40 minutes later.

What Smart Actions Does

Smart Actions evaluates a condition every time an event is ingested:

"If event X in channel Y occurs N times in Z minutes → trigger action"

No cron job, no polling. The evaluation runs inline, fired by your own events.

Step 1: Log Your Errors

First, make sure your error events flow into a dedicated channel:

ts
// lib/logit.ts
import { init } from "logit";
export const logit = init({ token: process.env.LOGIT_API_KEY! });
ts
// In your global error handler
import { logit } from "@/lib/logit";

export async function logError(err: Error, context?: Record<string, unknown>) {
  await logit.now("errors", {
    event: "Application error",
    description: err.message,
    icon: "🚨",
    notify: false,        // don't ping on every error — Smart Action handles the threshold
    tags: { type: err.name },
    metadata: { stack: err.stack, ...context },
  });
}

Step 2: Create the Smart Action

In your LogIt dashboard, go to Smart Actions for your project and click New Rule.

Configure it like this:

FieldValue
NameError spike alert
Channelerrors
Event nameApplication error
Threshold5
Window5 minutes
Cooldown15 minutes
ActionPush notification
Push title🚨 Error spike detected
Push body5+ errors in the last 5 minutes

Step 3: Test It

Trigger 5+ errors quickly (or lower the threshold temporarily). You'll receive a push notification within seconds of the threshold being crossed.

Cooldown Explained

The cooldown period prevents alert storms. After the rule fires, it won't fire again for 15 minutes — even if errors keep coming. Adjust based on how quickly your team can act.

Tips

  • Start with a conservative threshold (e.g. 5 errors / 5 min) and tune it after a week of baseline data.
  • Use a tighter window (5 min) for transient spikes, a larger window (1 hour) for slow leaks.
  • Keep notify: false on individual events — let Smart Actions handle the signal, not the noise.

Try LogIt free

7-day trial. No credit card required.

Start free