Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.devin.ai/llms.txt

Use this file to discover all available pages before exploring further.

概要

PagerDuty は、アラートをルーティングする仕組みとして Devin と連携できます。PagerDuty でインシデントが発生すると、軽量な Webhook ブリッジを介して Devin API 経由で Devin のセッションがトリガーされます。すると Devin が自動的にインシデントを調査し、テレメトリーを収集して根本原因を特定し、必要に応じて修正用の PR を作成します。 このパターンは、Datadog MCP 連携 と組み合わせると特に効果的です。この場合、PagerDuty がアラートを Devin にルーティングし、Devin は Datadog を利用してログとメトリクスを調査します。

セットアップ

1

Webhook ブリッジサービスをデプロイする

PagerDuty のインシデントペイロードを受信し、Devin API を呼び出して調査セッションを開始する小規模なハンドラーを作成します。ManageOrgSessions 権限を持つサービスユーザーSettings > Service Users で作成します。API トークンは DEVIN_API_KEY、組織 ID は DEVIN_ORG_ID、共有シークレットは WEBHOOK_SECRET としてブリッジサービスに保存してください。次のステップでは、この同じシークレットを PagerDuty の webhook の Custom Headers に設定します。
const express = require('express');
const crypto = require('crypto');
const app = express();
app.use(express.json());

function verifySignature(req) {
  const secret = Buffer.from(req.headers['x-webhook-secret'] || '');
  const expected = Buffer.from(process.env.WEBHOOK_SECRET || '');
  if (!expected.length) throw new Error('WEBHOOK_SECRET environment variable is not set');
  if (secret.length !== expected.length) return false;
  return crypto.timingSafeEqual(secret, expected);
}

app.post('/pagerduty-alert', async (req, res) => {
  if (!verifySignature(req)) return res.status(401).send('Bad signature');

  const event = req.body?.event;
  if (!event || event.event_type !== 'incident.triggered') {
    return res.sendStatus(200);
  }

  const incident = event.data;
  const title = incident.title || 'Unknown incident';
  const service = incident.service?.summary || 'unknown-service';
  const urgency = incident.urgency || 'high';
  const incidentUrl = incident.html_url || '';

  const orgId = process.env.DEVIN_ORG_ID;
  const response = await fetch(
    `https://api.devin.ai/v3/organizations/${orgId}/sessions`, {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.DEVIN_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      prompt: [
        `PagerDuty incident triggered: "${title}"`,
        `Service: ${service}`,
        `Urgency: ${urgency}`,
        `Incident URL: ${incidentUrl}`,
        ``,
        `Investigate this incident:`,
        `1. Check recent logs and metrics for ${service}`,
        `2. Identify the root cause of the issue`,
        `3. If the root cause is a code issue, open a hotfix PR`,
        `4. Post your findings to #incidents on Slack`,
      ].join('\n'),
      tags: ['pagerduty-triage', `service:${service}`],
    }),
  });

  const { session_id } = await response.json();
  console.log(`Started Devin session ${session_id} for: ${title}`);
  res.sendStatus(200);
});

app.listen(3000);
HTTPS トラフィックを受信できる環境であれば、どこにでもデプロイできます。たとえば、Cloudflare Worker、AWS Lambda、小規模なコンテナなどです。
2

PagerDuty に webhook 連携を追加する

  1. PagerDuty で Services > [your service] > Integrations に移動します
  2. Add Integration をクリックし、Generic Webhooks (v3) を選択します
  3. Webhook URL にブリッジサービスのエンドポイントを設定します (例: https://your-bridge.example.com/pagerduty-alert)
  4. Custom HeadersX-Webhook-Secret を追加し、値にはブリッジサービスで WEBHOOK_SECRET として保存したものと同じ値を指定します
  5. Event Subscription でイベントタイプ incident.triggered を指定してフィルタリングし、新しいインシデントでのみ送信されるようにします
3

パイプラインを検証する

PagerDuty でテスト用のインシデントをトリガーするか、テストサービスを利用して、次の点を確認します。
  1. ブリッジが webhook ペイロードを受信する
  2. 新しい Devin セッションが app.devin.ai に作成される
  3. Devin がインシデントの調査を開始する

ベストプラクティス

  • まずは警告レベルのモニターから始めましょう。 本番環境の P1 アラートを Devin にルーティングする前に、重要度の低いインシデントでパイプラインをテストしてください。
  • サービスや重大度でフィルタリングしましょう。 PagerDuty の webhook イベントサブスクリプションを利用するか、ブリッジにロジックを追加して、優先度の低いサービスやノイズの多いサービスを除外します。これにより、価値の低いアラートによって Devin が過負荷になるのを防げます。
  • 重大度ごとに異なる playbook を利用しましょう。 P1 アラートは即時調査とホットフィックス向けにルーティングします。P3 アラートは根本原因の分析のみにルーティングします。緊急度に応じて、Devin API リクエストで異なる playbook_id の値を渡してください。
  • 追跡しやすいようにセッションにタグを付けましょう。 サンプルコードでは、各セッションに pagerduty-triage とサービス名のタグを付けているため、Devin ダッシュボードで簡単にフィルタリングして確認できます。

Datadogとの併用

PagerDuty は、Datadog MCP 連携 とあわせて利用されることがよくあります。この構成では、次のように動作します。
  1. PagerDuty がアラートを Devin にルーティングし、調査セッションをトリガーします
  2. DevinDatadog MCP を利用して、影響を受けたサービスのログ、メトリクス、トレースを照会します
これにより、Devin は PagerDuty のアラートコンテキストと Datadog の詳細な可観測性データの両方を利用でき、より網羅的な調査を行えます。
Add Knowledge about your service architecture and on-call runbooks so Devin can follow your team’s investigation procedures automatically.