Guides / Monitoring

Post to Slack When a Threshold Is Crossed

4 min read·Monitoring

How It Works

Smart Actions supports a Webhook action type. When the threshold is crossed, LogIt sends a POST request to any URL you configure — including Slack's incoming webhook endpoint.

Step 1: Create a Slack Incoming Webhook

  1. Go to api.slack.com/apps → Create New App → From scratch
  2. Enable Incoming Webhooks and click Add New Webhook to Workspace
  3. Select your channel (e.g. #alerts) and copy the webhook URL: https://hooks.slack.com/services/T.../B.../...

Step 2: Log Events with the Right Event Name

Make sure you're logging events with a consistent name that the Smart Action will match:

ts
await logit.now("payments", {
  event: "Payment failed",
  description: `${customer.email}${error.message}`,
  icon: "❌",
  notify: false,
  tags: { currency: charge.currency },
  metadata: { customerId: customer.id, amount: charge.amount },
});

Step 3: Create the Smart Action

In Dashboard → Smart Actions, create a new rule:

FieldValue
NamePayment failure spike → Slack
Channelpayments
Event namePayment failed
Threshold3
Window10 minutes
Cooldown30 minutes
ActionWebhook
URLYour Slack webhook URL

LogIt sends a POST with a JSON body that Slack renders as a message in your channel.

What the Slack Message Looks Like

json
{
  "text": "🔔 Smart Action triggered: Payment failure spike → Slack",
  "attachments": [{
    "color": "#e53e3e",
    "fields": [
      { "title": "Rule", "value": "Payment failure spike → Slack", "short": true },
      { "title": "Event count", "value": "3", "short": true },
      { "title": "Channel", "value": "payments", "short": true },
      { "title": "Window", "value": "10 minutes", "short": true }
    ]
  }]
}

Tips

  • Create one Smart Action per team channel — #payments, #ops, #oncall.
  • Use a low threshold (2-3) for high-severity events like payment failures.
  • Pair with a 30-minute cooldown so Slack doesn't flood when an outage hits.

Try LogIt free

7-day trial. No credit card required.

Start free