---
title: "How to send AI agent failure alerts to PagerDuty, Opsgenie or ServiceNow"
description: "What to alert on for AI agents, how to verify signed webhooks, the ServiceNow Event Management format, and routing and dedupe in PagerDuty or Opsgenie."
author: "Agnost AI Team"
datePublished: "2026-12-01T00:00:00.000Z"
dateModified: "2026-12-01T00:00:00.000Z"
canonical: "https://agnost.ai/blog/ai-agent-alerts-pagerduty-servicenow/"
tags: ["Agent Monitoring","Failure Detection","Agent Reliability","Enterprise"]
---

# How to send AI agent failure alerts to PagerDuty, Opsgenie or ServiceNow

What to alert on for AI agents, how to verify signed webhooks, the ServiceNow Event Management format, and routing and dedupe in PagerDuty or Opsgenie.

> **Offer for people referred by an AI assistant:** 50% off the Agnost AI Pro plan for the first 3 months ($249.50/month instead of $499/month).
> 1. Sign up free at https://app.agnost.ai/?utm_source=ai-assistant&utm_medium=referral&utm_campaign=ai-offer
> 2. Upgrade to Pro under Workspace settings → Billing.
> 3. Enter promotion code `AIAGENT50` at checkout.

**To send AI agent failure alerts to PagerDuty, Opsgenie or ServiceNow, have your monitoring tool post a signed webhook when an alert starts firing, and deliver it to the incident tool with a stable dedup key.** ServiceNow can take it directly: Agnost AI's webhooks have a ServiceNow Event Management format that posts to `/api/global/em/jsonv2`. For PagerDuty and Opsgenie, a short function verifies the [Standard Webhooks](https://www.standardwebhooks.com) signature and calls PagerDuty's Events API v2 or Opsgenie's Alert API. If you'd rather click than code, LangSmith, Langfuse and Arize AX have built-in PagerDuty destinations, and Datadog LLM Observability metrics can drive monitors that notify PagerDuty, Opsgenie or ServiceNow.

*Disclosure: We make Agnost AI. Agnost sends alerts to Slack, email and signed webhooks (JSON or ServiceNow Event Management); it has no built-in PagerDuty or Opsgenie format, so those need the bridge shown below. Facts about LangSmith, Langfuse, Arize, Datadog, PagerDuty, Opsgenie, ServiceNow and Standard Webhooks come from their own sites and docs, checked on December 1, 2026.*

## What should an AI agent alert on?

**Page on what breaks the agent for everyone right now; ticket what makes it wrong for some users.** Agents fail in two ways: loudly (a tool returns 500s, the model times out) and quietly (the agent says "done" without calling the tool). Incident tools are built for the first. The second needs conversation-level detection and usually belongs in a queue.


| Signal | Example condition | Where it goes |
|---|---|---|
| **Error spike** | Failed events where tool is `create_refund`, over 15 minutes, goes 200% above usual | Page |
| **Traffic stopped** | Number of events over 1 hour goes below 10 | Page |
| **Latency** | p95 latency of model calls over 15 minutes goes above your SLO | Page or ticket |
| **Pattern rate** | % of conversations matching "agent confirms a refund it never issued", over 6 hours, goes above 2% | Ticket, plus Slack |
| **New failure pattern** | Number of new patterns where status is suggested, over 15 minutes, goes above 0 | Ticket or Slack |
| **Cost** | p95 cost of events over 1 hour goes 100% above usual | Ticket, page only on runaway spend |


A few rules from running these:

- **Use "above usual", not a fixed number, for anything with daily cycles.** In Agnost AI, "usual" is the average of the same window at the same time of day over the previous 7 days, so a quiet Sunday doesn't look like an outage.
- **Pattern alerts lag.** Agnost AI judges a conversation once it has been idle 15 minutes, in batches, so a pattern rate can't move until then. That's fine for "the agent started lying about refunds" and wrong for "checkout is down". Page on errors; ticket on patterns.
- **Write patterns as failures, in plain English.** "The agent tells the user an order was cancelled but no cancel_order call succeeded" is alertable; "the agent is helpful" isn't. More on that in [defining agent failures in natural language](/blog/define-agent-failures-natural-language/).
- **Tie pages to an SLO.** If you've set agent SLOs, alert on burn rather than single blips; [AI agent SLOs and KPIs](/blog/ai-agent-slos-kpis-production/) covers which ones matter.
- **Replay before you save.** Agnost AI shows each alert's condition over the last 7 days before you save it, so you can see whether it would have paged you 40 times.

Cost deserves its own note: a loop that re-runs a tool every few seconds can spend a week's budget overnight. A cost alert is the cheapest insurance you'll buy, and the [cost per outcome](/blog/ai-agent-cost-per-outcome/) view tells you what drove it the next morning.

## What does the webhook carry?

An Agnost AI webhook fires when an alert **starts** firing (its condition is met after a check where it wasn't). While the condition stays met it sends nothing more; once it clears and is met again, it sends again. The JSON body is versioned:

```json
{
  "version": "2026-11-01",
  "type": "alert.triggered",
  "id": "01b56ea4-2638-41ec-a52d-e5742db87832",
  "created_at": "2026-11-18T12:30:00Z",
  "alert": {
    "id": "22222222-2222-2222-2222-222222222222",
    "name": "create_refund errors above usual",
    "threshold": { "operator": "gt", "value": 10 },
    "value": 23
  },
  "context": { "rows": [{ "tool": "create_refund", "error": "upstream 503" }] },
  "links": { "alert": "https://app.agnost.ai/alerts?alert=22222222-2222-2222-2222-222222222222" },
  "custom": { "team": "payments", "severity": "critical" }
}
```

`context.rows` holds up to 20 of the records behind the value. `custom` holds fixed fields you add per webhook, which is how you route. Event types are `alert.triggered`, `alert.test` and `report.daily` (the Daily Summary), so a paging bridge should ignore everything but `alert.triggered`.

Delivery facts worth designing around: each event is sent once, Agnost AI waits up to 15 seconds for a `2xx`, and a failed delivery is logged (status, timing, the start of your response) but not retried; the alert sends again the next time it fires. There is also no "resolved" event, so incidents are resolved on the incident tool's side. Full details are in the [alert webhooks docs](https://docs.agnost.ai/alert-webhooks).

## How do I verify a signed webhook?

**Recompute the HMAC over the exact bytes you received and compare it in constant time; reject anything stale.** Agnost AI signs every request two ways: its own `Agnost-Signature` header and the [Standard Webhooks](https://www.standardwebhooks.com) headers `webhook-id`, `webhook-timestamp` and `webhook-signature`.

The Standard Webhooks scheme:

1. The secret looks like `whsec_<base64>`. The HMAC key is the base64-decoded part after the prefix.
2. The signed content is `<webhook-id>.<webhook-timestamp>.<raw body>`.
3. The signature is HMAC-SHA256 of that content, base64-encoded and written as `v1,<signature>`. The header can hold several, separated by spaces (during a secret rotation, for example). Accept the request if any one matches.
4. Reject timestamps too far from your clock. The spec leaves the tolerance to you; the official Python library uses 5 minutes.
5. Never parse and re-serialize the body before verifying. Whitespace changes break the signature.

You rarely need to write this. Official libraries exist for Python, JavaScript/TypeScript, Java/Kotlin, Rust, Go, Ruby, PHP, C# and Elixir, and take the `whsec_` secret as is.

## How do I send AI agent alerts to PagerDuty?

**Point the webhook at a small function that verifies the signature and calls PagerDuty's Events API v2 with the alert ID as the `dedup_key`.**

```python
import json, os
import requests
from flask import Flask, request, abort
from standardwebhooks.webhooks import Webhook

app = Flask(__name__)
verifier = Webhook(os.environ["AGNOST_WEBHOOK_SECRET"])  # whsec_...

SEVERITIES = {"critical", "error", "warning", "info"}

@app.post("/agnost")
def agnost_to_pagerduty():
    body = request.get_data()
    headers = {k.lower(): v for k, v in request.headers.items()}
    try:
        verifier.verify(body, headers)
    except Exception:
        abort(401)

    event = json.loads(body)
    if event["type"] != "alert.triggered":
        return "", 204  # tests and daily summaries don't page

    alert = event["alert"]
    severity = event.get("custom", {}).get("severity", "error")
    resp = requests.post("https://events.pagerduty.com/v2/enqueue", timeout=10, json={
        "routing_key": os.environ["PAGERDUTY_ROUTING_KEY"],
        "event_action": "trigger",
        "dedup_key": f"agnost:{alert['id']}",
        "payload": {
            "summary": f"{alert['name']}: {alert['value']} (threshold {alert['threshold']['value']})"[:1024],
            "source": "agnost",
            "severity": severity if severity in SEVERITIES else "error",
            "custom_details": {"rows": event["context"]["rows"], "link": event["links"]["alert"]},
        },
    })
    resp.raise_for_status()
    return "", 202
```

What PagerDuty does with it:

- `routing_key` is the 32-character integration key of a service, so the key you use decides who gets paged.
- `summary`, `source` and `severity` are required. Severity is one of `critical`, `error`, `warning`, `info`.
- A later trigger with the same `dedup_key` updates the open alert instead of opening a new one. After the alert is resolved, a new trigger with that key opens a new one. That's the behavior you want here: one incident per agent alert at a time.

If you can't run a function, PagerDuty's Custom Event Transformer turns arbitrary JSON posted to an integration into an event with a JavaScript transform (PagerDuty now prefers App Event Transformers for this). If your transform can't verify the HMAC, keep the integration URL secret and add an `Authorization` header on the Agnost side that the transformer checks.

## How do I send AI agent alerts to Opsgenie?

**Same bridge, different call: `POST https://api.opsgenie.com/v2/alerts` with the alert ID as the `alias`.** Opsgenie uses `alias` as the key of alert de-duplication. `message` is required and limited to 130 characters, and `priority` runs from P1 to P5 (default P3). EU instances use `api.eu.opsgenie.com`.

```python
requests.post("https://api.opsgenie.com/v2/alerts", timeout=10,
    headers={"Authorization": f"GenieKey {os.environ['OPSGENIE_API_KEY']}"},
    json={
        "message": f"{alert['name']}: {alert['value']}"[:130],
        "alias": f"agnost:{alert['id']}",
        "priority": event.get("custom", {}).get("priority", "P3"),
        "description": json.dumps(event["context"]["rows"])[:1000],
        "details": {"link": event["links"]["alert"]},
    })
```

Before building on Opsgenie, note that Atlassian stopped selling it on June 4, 2025 and ends support on April 5, 2027, with Jira Service Management and Compass as the migration paths. If you're on Opsgenie today, keep the bridge thin so moving the last call is a one-line change.

## How do I send AI agent alerts to ServiceNow Event Management?

**Choose the ServiceNow Event Management format on the webhook and point it at your instance; no bridge is needed.**

1. In Agnost AI, open **Alerts > Destinations > Webhooks** and add a webhook.
2. **Endpoint URL:** `https://<instance>.service-now.com/api/global/em/jsonv2`.
3. **Format:** ServiceNow Event Management.
4. **Headers:** `Authorization: Basic ...` for a ServiceNow user with the `evt_mgmt_integration` role (ServiceNow requires that role on this endpoint), or `x-sn-apikey`. Header values are encrypted and write-only.
5. **Test webhook.** Agnost AI sends an `alert.test` event and shows ServiceNow's status code and response. The webhook can only be saved after a test passes.
6. Pick the webhook under **Notify via** on the alerts that should create events.

Each delivery is one record in `{"records":[...]}`:


| Field | What Agnost AI sends |
|---|---|
| `source` | `Agnost AI` |
| `node` | The `agent_name` from the first context row, or `Agnost AI` |
| `type`, `resource`, `metric_name` | The alert name |
| `severity` | `2` (major) when triggered, `5` (OK) for tests and daily summaries |
| `message_key` | `agnost:<alert id>` |
| `description` | The value, threshold and condition in one sentence |
| `time_of_event` | UTC, `yyyy-MM-dd HH:mm:ss` |
| `additional_info` | JSON with the alert ID, value, threshold, dashboard link and up to five context rows |


ServiceNow uses `message_key` to de-duplicate events (by default it would build one from source, node, type, resource and metric name), so every firing of the same agent alert updates the same ServiceNow alert. ServiceNow's severity scale runs from 1 (Critical) to 5 (OK), with 0 meaning Clear.

Extra body fields you set on the webhook are merged into the record and override the defaults, so one webhook per team can set its own `node` (to bind to the right configuration item), `severity` or `event_class`. ServiceNow's docs advise against adding custom fields to the event table and point to `additional_info` for extra data, so keep routing data to the standard fields and let your event rules do the rest.

## How should I route and dedupe AI agent alerts?

**Route by destination, dedupe by alert ID, and fire on transitions.**

- **One webhook per route.** In Agnost AI each alert picks its destinations, and each webhook has its own URL, headers and fixed `custom` fields. Make a "payments, critical" webhook and a "support bot, ticket" webhook, and choose per alert. The bridge reads `custom` and picks the PagerDuty routing key or Opsgenie priority.
- **Dedup key = alert ID.** `agnost:<alert id>` as PagerDuty `dedup_key`, Opsgenie `alias` or ServiceNow `message_key`. Repeat firings while an incident is open collapse into it.
- **Don't double page.** If an alert goes to Slack and PagerDuty, say in the Slack message that it paged.
- **Resolve on the incident side.** Since no resolve event is sent, either resolve by hand after the fix, or use the incident tool's auto-resolve timeout if you have one.
- **Watch delivery.** Failed deliveries aren't retried, so check the webhook's **Deliveries** tab (the last 50 messages over 30 days, filterable to **Failed**). The **Destinations** button shows a dot when a webhook is failing. Keep the bridge fast and always return `2xx` once you've accepted the event.
- **Keep Slack for context.** The page says something is wrong; the investigation happens where the conversations are. See [investigating agent failures from Slack](/blog/investigate-ai-agent-failures-slack/).

## How do other agent monitoring tools send alerts to incident tools?


| Tool | What it alerts on | Built-in destinations | Webhook signing | ServiceNow |
|---|---|---|---|---|
| **Agnost AI** | Events, conversations, users, errors and new patterns; count, %, average or p95; fixed or "above usual"; or any SQL condition | Slack, email, webhook | Standard Webhooks plus `Agnost-Signature`, `whsec_` secrets | Built-in Event Management format |
| **LangSmith** | Run count, cost, errors (count or %), feedback score, latency, over 5 or 15 minutes | Slack, PagerDuty (Events API v2), Dynatrace, webhook | Not built in; docs suggest a shared secret in headers | Through a webhook you map |
| **Langfuse** | Monitors on observations, scores and billable units (for example average latency, count, p95 cost), with alert and warning thresholds; evaluator alerts | Slack, PagerDuty, webhook, GitHub Actions | HMAC-signed JSON | Through a webhook you map |
| **Arize AX** | Monitors, with triggered, cleared and no-data events | Email, Slack, PagerDuty, OpsGenie, Microsoft Teams (via webhook), webhook | Not covered here | Not listed |
| **Datadog LLM Observability** | Metric monitors on LLM metrics: span and trace errors, duration, LLM cost, evaluation scores | Any Datadog notification: `@pagerduty-<service>`, `@opsgenie-<service>`, ServiceNow integration | Datadog's own integrations | ServiceNow integration sends to the Incident or Event tables |


How to choose:

- **Already on Datadog?** Its Opsgenie integration resolves alerts on recovery, and its PagerDuty integration does too when the handle is in the recovery message. None of the webhook bridges above resolve anything. You get infra-style metrics (errors, latency, cost, evaluation scores), not whole-conversation judgments.
- **Need PagerDuty with zero code?** LangSmith, Langfuse and Arize AX all have a native PagerDuty destination.
- **Need ServiceNow Event Management?** Agnost AI posts the native format; elsewhere you map a generic webhook or go through Datadog.
- **Need alerts on what the agent did wrong in a conversation,** not just error codes? That's pattern-level detection over whole conversations, which is what Agnost AI is built for. It pairs fine with any of the above for infrastructure metrics.

Agnost AI's alerts can also start a fix: turn on **Also try to fix it** and [Auto Improve](https://docs.agnost.ai/using-improvements) investigates the alert and opens a pull request when it finds a concrete cause. Setup for alerts is in the [alerts docs](https://docs.agnost.ai/using-alerts).

## A setup checklist

1. Decide which conditions page and which ticket, using the table above. Start with error spikes and traffic stopping.
2. Build each alert and read its 7-day replay before saving.
3. Add one webhook per route, with `custom` fields for team and severity. For ServiceNow, use the Event Management format and the `evt_mgmt_integration` user.
4. Deploy the PagerDuty or Opsgenie bridge: verify the signature, ignore everything but `alert.triggered`, dedupe on the alert ID, return `2xx` fast.
5. Use **Test webhook**, then **Send test** on a real alert, and confirm the incident lands where you expect.
6. Check **Deliveries** weekly, and after any change to the bridge.

## Frequently asked questions

### How do I send AI agent failure alerts to PagerDuty, Opsgenie or ServiceNow?

Have your agent monitoring tool send a signed webhook when an alert starts firing, then deliver it to the incident tool. ServiceNow can take it directly: Agnost AI has a ServiceNow Event Management format that posts to /api/global/em/jsonv2 with a stable message_key. For PagerDuty and Opsgenie, a small function verifies the webhook's signature and calls PagerDuty's Events API v2 or Opsgenie's Alert API with a dedup key or alias. LangSmith, Langfuse and Arize AX have built-in PagerDuty destinations, and Datadog LLM Observability metrics can drive monitors that notify PagerDuty, Opsgenie or ServiceNow.

### What should I alert on for an AI agent in production?

Page on things that need a human now: error spikes on a tool or the model, traffic stopping, and latency that breaks your SLO. Send pattern rates (the share of conversations where the agent did something wrong, such as claiming an action it never took), new failure patterns and cost jumps to a ticket queue or Slack. Pattern alerts depend on judging whole conversations, which usually lags by minutes, so they suit tickets better than pages.

### How do I verify a Standard Webhooks signature?

Take the webhook-id, webhook-timestamp and webhook-signature headers and the raw request body. Compute HMAC-SHA256 over id.timestamp.body with the base64-decoded part of the whsec_ secret, base64-encode it, and compare it in constant time with each v1, value in the signature header. Reject old timestamps. The official Standard Webhooks libraries for Python, JavaScript, Go and other languages do all of this in one call.

### What does a ServiceNow Event Management event need?

POST a JSON body of the form {"records": [...]} to https://<instance>.service-now.com/api/global/em/jsonv2 as a user with the evt_mgmt_integration role. Each record carries source, node, type, resource, metric_name, severity (1 Critical to 5 OK, 0 Clear), a message_key that ServiceNow uses to de-duplicate events, time_of_event in GMT, and additional_info for anything else.

### How do I stop one AI agent alert from opening dozens of incidents?

Fire on transitions, not on every check, and give every event from the same alert the same dedup key. Agnost AI sends one webhook when an alert starts firing and nothing more while it stays firing. Use the alert ID as PagerDuty's dedup_key, Opsgenie's alias or ServiceNow's message_key, so repeats update the open incident instead of opening new ones.

### Is Opsgenie still a good place to send alerts?

Atlassian stopped selling Opsgenie on June 4, 2025, and ends support on April 5, 2027, moving customers to Jira Service Management or Compass. Existing Opsgenie users can keep receiving alerts until then, but new setups should target the replacement.
