Parseable

PagerDuty

Send alerts to PagerDuty for incident management and on-call escalation


Integrate Parseable with PagerDuty for incident management, on-call scheduling, and alert escalation.

Overview

Integrate Parseable with PagerDuty to:

  • Trigger Incidents - Automatically create PagerDuty incidents from alerts
  • On-Call Escalation - Route alerts to the right team members
  • Incident Management - Track and resolve issues with full context
  • Reduce Alert Fatigue - Use PagerDuty's intelligent grouping

Prerequisites

  • PagerDuty account with admin access
  • PagerDuty Integration Key (Events API v2)
  • Parseable alerts configured or Fluent Bit for log streaming

Setting Up PagerDuty Integration

Create a PagerDuty Service

  1. Log in to your PagerDuty account
  2. Go to ServicesService Directory
  3. Click + New Service
  4. Name your service (e.g., "Parseable Alerts")
  5. Select an escalation policy
  6. Under Integrations, select Events API V2
  7. Click Create Service
  8. Copy the Integration Key (32-character string)

Webhook Integration

Use Parseable's alerting system with a webhook to send incidents to PagerDuty.

Create a Webhook Endpoint

Create a webhook service that transforms Parseable alerts to PagerDuty Events API format:

// webhook-to-pagerduty.js
const express = require('express');
const axios = require('axios');

const app = express();
app.use(express.json());

const PAGERDUTY_ROUTING_KEY = process.env.PAGERDUTY_ROUTING_KEY;
const PAGERDUTY_EVENTS_URL = 'https://events.pagerduty.com/v2/enqueue';

app.post('/webhook', async (req, res) => {
  const alert = req.body;
  
  const pagerdutyEvent = {
    routing_key: PAGERDUTY_ROUTING_KEY,
    event_action: 'trigger',
    dedup_key: `parseable-${alert.name}-${alert.dataset}`,
    payload: {
      summary: `[Parseable] ${alert.name || 'Alert Triggered'}`,
      severity: mapSeverity(alert.severity),
      source: alert.dataset || 'parseable',
      timestamp: new Date().toISOString(),
      custom_details: {
        dataset: alert.dataset,
        query: alert.query,
        threshold: alert.threshold,
        current_value: alert.value,
        message: alert.message
      }
    },
    links: [
      {
        href: `https://your-parseable-instance.com/streams/${alert.dataset}`,
        text: 'View in Parseable'
      }
    ]
  };

  try {
    const response = await axios.post(PAGERDUTY_EVENTS_URL, pagerdutyEvent);
    res.status(200).json({ 
      status: 'sent',
      dedup_key: response.data.dedup_key 
    });
  } catch (error) {
    console.error('Error sending to PagerDuty:', error.response?.data || error);
    res.status(500).json({ error: 'Failed to send to PagerDuty' });
  }
});

// Map Parseable severity to PagerDuty severity
function mapSeverity(severity) {
  const mapping = {
    'critical': 'critical',
    'high': 'error',
    'medium': 'warning',
    'low': 'info',
    'error': 'error',
    'warning': 'warning',
    'info': 'info'
  };
  return mapping[severity?.toLowerCase()] || 'error';
}

// Endpoint to resolve incidents
app.post('/webhook/resolve', async (req, res) => {
  const alert = req.body;
  
  const pagerdutyEvent = {
    routing_key: PAGERDUTY_ROUTING_KEY,
    event_action: 'resolve',
    dedup_key: `parseable-${alert.name}-${alert.dataset}`
  };

  try {
    await axios.post(PAGERDUTY_EVENTS_URL, pagerdutyEvent);
    res.status(200).json({ status: 'resolved' });
  } catch (error) {
    console.error('Error resolving in PagerDuty:', error);
    res.status(500).json({ error: 'Failed to resolve in PagerDuty' });
  }
});

app.listen(3000, () => {
  console.log('PagerDuty webhook server listening on port 3000');
});

Docker Compose Setup

version: '3.8'
services:
  webhook-to-pagerduty:
    build: .
    ports:
      - "3000:3000"
    environment:
      - PAGERDUTY_ROUTING_KEY=your-32-character-integration-key

Configure Parseable Alert

Configure your Parseable alert to send to the webhook endpoint:

{
  "name": "Critical Error Rate",
  "dataset": "production-logs",
  "alertType": "threshold",
  "condition": {
    "field": "level",
    "operator": "equals",
    "value": "critical"
  },
  "threshold": 10,
  "duration": "5m",
  "webhook": {
    "url": "http://webhook-to-pagerduty:3000/webhook",
    "method": "POST"
  }
}

PagerDuty Events API v2

Event Actions

ActionDescription
triggerCreate a new incident or add to existing
acknowledgeAcknowledge an existing incident
resolveResolve an existing incident

Severity Levels

SeverityDescription
criticalSystem is unusable
errorA problem that needs immediate attention
warningA problem that should be addressed soon
infoInformational message

Deduplication

Use the dedup_key to group related alerts into a single incident:

dedup_key: `parseable-${alert.name}-${alert.dataset}`

This prevents alert storms from creating multiple incidents for the same issue.

Advanced Configuration

Custom Fields

Add custom details to provide more context:

custom_details: {
  dataset: alert.dataset,
  query: alert.query,
  threshold: alert.threshold,
  current_value: alert.value,
  environment: process.env.ENVIRONMENT,
  region: process.env.REGION,
  runbook_url: 'https://wiki.example.com/runbooks/high-error-rate'
}

Priority Mapping

Map Parseable alert priorities to PagerDuty priorities:

const priorityMapping = {
  'P1': { severity: 'critical', urgency: 'high' },
  'P2': { severity: 'error', urgency: 'high' },
  'P3': { severity: 'warning', urgency: 'low' },
  'P4': { severity: 'info', urgency: 'low' }
};

Best Practices

  1. Use Deduplication - Prevent duplicate incidents with consistent dedup keys
  2. Include Runbook Links - Add links to troubleshooting documentation
  3. Set Appropriate Severity - Map alert severity correctly to avoid alert fatigue
  4. Add Context - Include relevant details like dataset, query, and thresholds
  5. Test Integration - Verify the integration works before production deployment

Troubleshooting

Incidents Not Creating

  1. Verify the Integration Key is correct
  2. Check the webhook service logs for errors
  3. Ensure the PagerDuty service is not disabled
  4. Verify network connectivity to PagerDuty

Duplicate Incidents

  1. Ensure dedup_key is consistent for related alerts
  2. Check that the dedup key format matches across trigger/resolve events

Missing Context

  1. Verify custom_details are being populated
  2. Check that the alert payload contains expected fields

Next Steps

Was this page helpful?

On this page