Skip to content

PagerDuty

PagerDuty incidents, on-call, schedules, services, teams, changes and analytics as SQL tables

Connector software
Free and open source
Service credentials
Required
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/pagerduty/index.md to help me query PagerDuty with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

See every open incident

Uses your connected account. Set up the connector and credentials to run it with your data.

SELECT incident_number, title, service, created_at
FROM pagerduty.main.incidents()
WHERE status IN ('triggered', 'acknowledged')
ORDER BY created_at

Quick start

Choose where to run PagerDuty, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach the release directly

Downloads the latest release for your platform and caches it locally.

ATTACH 'pagerduty' AS pagerduty (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/vgi-pagerduty'
);

3. Add service credentials

After attaching, create the secret for the service you want to query in the same SQL session. Replace the placeholders with your service settings.

pagerduty credentials

A PagerDuty REST API key or OAuth access token, plus the account's region

Get these credentials →
secret.sql
CREATE SECRET pagerduty (
    TYPE pagerduty,
    api_token   '<API_TOKEN>',  -- secret
    oauth_token '<OAUTH_TOKEN>',  -- secret
    region      '<region>',
    base_url    '<base_url>'
);
Credential fields and requirements →

4. Run a query

query.sql
SELECT incident_number, title, service, created_at
FROM pagerduty.main.incidents()
WHERE status IN ('triggered', 'acknowledged')
ORDER BY created_at
More example queries →
Technical details
Verified connector release
v0.2.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach the release directly

Uses the verified release each time you attach the connector.

ATTACH 'pagerduty' AS pagerduty (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/[email protected]'
);

Overview

PagerDuty incident management as SQL: incidents and their timelines, on-call, schedules, services, teams, change events, analytics and audit records, read-only from the PagerDuty REST API.

Catalog

Everything pagerduty exposes once attached — read straight from the worker's released build.

pagerduty 1 schema
main 14 tables · 10 functions

Read-only PagerDuty REST API v2 collections: incidents, on-call, services, people, changes, analytics and audit.

Schema examples (12)
Examples (12)

High-urgency incidents and median time to resolve per service since October

SELECT service, count(*) AS incidents,
  median(time_to_resolve_seconds) / 60 AS median_minutes_to_resolve
FROM pagerduty.main.incidents(with_timeline := true)
WHERE created_at >= TIMESTAMPTZ '2026-10-01' AND urgency = 'high'
GROUP BY service
ORDER BY incidents DESC;

Every open incident (an open-only status filter reads all time)

SELECT incident_number, title, service, created_at
FROM pagerduty.main.incidents()
WHERE status IN ('triggered', 'acknowledged')
ORDER BY created_at;

The timeline of one incident

SELECT type, agent_name, created_at
FROM pagerduty.main.incident_log_entries(incident_id := 'Q2CHECKOUT500')
ORDER BY created_at;

Who acknowledges the most incidents

SELECT agent_name, count(*) AS acks
FROM pagerduty.main.incident_log_entries()
WHERE type = 'acknowledge' AND created_at >= TIMESTAMPTZ '2026-10-01'
GROUP BY agent_name
ORDER BY acks DESC;
8 more examples

Alert severities behind one incident

SELECT severity, count(*) AS alerts
FROM pagerduty.main.incident_alerts(incident_id := 'Q2CHECKOUT500')
GROUP BY severity
ORDER BY alerts DESC;

The noisiest alert keys since October

SELECT service, alert_key, count(*) AS alerts
FROM pagerduty.main.incident_alerts(since := TIMESTAMPTZ '2026-10-01')
GROUP BY ALL
ORDER BY alerts DESC
LIMIT 10;

Responder notes on one incident

SELECT user_name, created_at, content
FROM pagerduty.main.incident_notes(incident_id := 'Q2CHECKOUT500')
ORDER BY created_at;

Who is on call right now, per escalation policy and level

SELECT escalation_policy_name, escalation_level, user_name
FROM pagerduty.main.oncalls()
ORDER BY escalation_policy_name, escalation_level;

First-responder hours per person in one week

SELECT user_name, sum(epoch(end_time) - epoch(start_time)) / 3600 AS hours
FROM pagerduty.main.oncalls(since := TIMESTAMPTZ '2026-11-01', until := TIMESTAMPTZ '2026-11-08')
WHERE escalation_level = 1
GROUP BY user_name
ORDER BY hours DESC;

On-call hours per person and schedule for one week

SELECT schedule_name, user_name, sum(duration_seconds) / 3600 AS hours
FROM pagerduty.main.schedule_entries(since := TIMESTAMPTZ '2026-11-01', until := TIMESTAMPTZ '2026-11-08')
GROUP BY ALL
ORDER BY hours DESC;

Changes since November 1st, newest first

SELECT occurred_at, summary, services
FROM pagerduty.main.change_events()
WHERE occurred_at >= TIMESTAMPTZ '2026-11-01'
ORDER BY occurred_at DESC;

Changes on the same service in the hour before each incident

SELECT i.incident_number, c.summary AS change, c.occurred_at
FROM pagerduty.main.incidents(date_range := 'all') i
JOIN pagerduty.main.change_events(since := TIMESTAMPTZ '2026-11-01') c ON list_contains(c.service_ids, i.service_id) AND c.occurred_at BETWEEN i.created_at - INTERVAL 1 HOUR AND i.created_at
ORDER BY i.incident_number;
Tables
account_features 1 example5 cols

Which PagerDuty add-on APIs (Analytics, Audit Records, Status Pages, ...) this account and key can use

Columns
featurenot null VARCHAR
rest_api, analytics, audit_records, status_pages, business_services or change_events.
available BOOLEAN
True when the probe succeeded.
http_status INTEGER
HTTP status code the probe request returned (200 = available, 402/403 = not on plan or role).
detail VARCHAR
PagerDuty's error message when unavailable.
used_by VARCHAR
Functions and tables that need the feature.
ConstraintsPRIMARY KEY (feature)
Example

Which optional APIs this key can use

SELECT feature, available, used_by
FROM pagerduty.main.account_features
ORDER BY feature;
Link
business_services 1 example6 cols

PagerDuty business services: the customer-facing capabilities technical services support

Columns
business_service_idnot null VARCHAR
PagerDuty id of the business service (e.g. PBS1234).
name VARCHAR
Business service name as shown on the service graph.
description VARCHAR
Free-text summary of what the business service covers.
point_of_contact VARCHAR
Who to contact about the business service (free text, often an email or channel).
team_id VARCHAR
Owning team id.
url VARCHAR
Link in the PagerDuty web UI.
ConstraintsPRIMARY KEY (business_service_id) · FOREIGN KEY (team_id) REFERENCES teams(team_id)
Example

All business services

SELECT name, point_of_contact
FROM pagerduty.main.business_services
ORDER BY name;
Link
escalation_policies 1 example9 cols

PagerDuty escalation policies: who gets paged, in what order, for which services

Columns
escalation_policy_idnot null VARCHAR
PagerDuty id of the escalation policy (e.g. PEP1234).
name VARCHAR
Policy name.
description VARCHAR
Free-text purpose of the policy.
num_loops INTEGER
Count of extra passes through all rules after the last level (0 = no repeat).
on_call_handoff_notifications VARCHAR
if_has_services or always.
rule_count INTEGER
Number of escalation rules (levels).
service_ids VARCHAR[]
Services using the policy.
team_ids VARCHAR[]
Teams owning the policy.
url VARCHAR
Link to the policy in the PagerDuty web UI.
ConstraintsPRIMARY KEY (escalation_policy_id)
Example

Policies with their number of levels and services

SELECT name, rule_count, len(service_ids) AS services
FROM pagerduty.main.escalation_policies
ORDER BY name;
Link
escalation_rules 1 example8 cols

Escalation policy rules flattened: one row per policy level and target (user or schedule)

Columns
escalation_policy_idnot null VARCHAR
The policy this level belongs to (joins escalation_policies).
escalation_policy VARCHAR
Escalation policy name.
levelnot null INTEGER
Escalation level (1 = first).
rule_id VARCHAR
Escalation rule id.
escalation_delay_in_minutes INTEGER
Delay in minutes before an unacknowledged incident escalates past this level.
target_typenot null VARCHAR
user or schedule.
target_idnot null VARCHAR
Target user or schedule id.
target_name VARCHAR
Target user or schedule name.
ConstraintsPRIMARY KEY (escalation_policy_id, level, target_type, target_id) · FOREIGN KEY (escalation_policy_id) REFERENCES escalation_policies(escalation_policy_id)
Example

The full paging chain of every policy

SELECT escalation_policy, level, target_type, target_name
FROM pagerduty.main.escalation_rules
ORDER BY escalation_policy, level, target_name;
Link
maintenance_windows 1 example11 cols

PagerDuty maintenance windows (planned periods when services do not page)

Columns
maintenance_window_idnot null VARCHAR
PagerDuty id of the maintenance window.
sequence_number BIGINT
Account-wide ordinal of the window (1 = first created), as shown in the UI.
description VARCHAR
Why the services are in maintenance.
start_time TIMESTAMP WITH TIME ZONE
When paging is suppressed from.
end_time TIMESTAMP WITH TIME ZONE
When paging resumes.
status VARCHAR
past, ongoing or future (relative to when the query started).
created_by VARCHAR
Who created it.
service_ids VARCHAR[]
Services in maintenance.
services VARCHAR[]
Names of the services in maintenance.
team_ids VARCHAR[]
Teams.
url VARCHAR
Link in the PagerDuty web UI.
ConstraintsPRIMARY KEY (maintenance_window_id)
Example

Maintenance windows in effect right now

SELECT description, start_time, end_time, services
FROM pagerduty.main.maintenance_windows
WHERE status = 'ongoing'
ORDER BY start_time;
Link
priorities 1 example4 cols

The account's incident priorities (P1, P2, ...) in rank order

Columns
priority_idnot null VARCHAR
PagerDuty id of the priority (joins incidents.priority_id).
name VARCHAR
Priority name, e.g. P1.
description VARCHAR
What the priority level means in this account.
rank INTEGER
Position in PagerDuty's order (1 = most severe).
ConstraintsPRIMARY KEY (priority_id)
Example

Priorities in order

SELECT rank, name, description FROM pagerduty.main.priorities ORDER BY rank;
Link
schedules 1 example9 cols

PagerDuty on-call schedules with their users, teams and escalation policies

Columns
schedule_idnot null VARCHAR
PagerDuty id of the schedule (joins oncalls and schedule_entries).
name VARCHAR
Schedule name.
description VARCHAR
Free-text purpose of the rotation.
time_zone VARCHAR
The schedule's time zone.
escalation_policy_ids VARCHAR[]
Escalation policies that use the schedule.
user_ids VARCHAR[]
Users in the schedule's rotations.
users VARCHAR[]
Names of the users in the rotations.
team_ids VARCHAR[]
Teams owning the schedule.
url VARCHAR
Link to the schedule in the PagerDuty web UI.
ConstraintsPRIMARY KEY (schedule_id)
Example

Schedules and how many people rotate through each

SELECT name, time_zone, len(user_ids) AS people
FROM pagerduty.main.schedules
ORDER BY name;
Link
service_dependencies 1 example5 cols

The PagerDuty service graph: one row per dependency edge between business and technical services

Columns
relationship_idnot null VARCHAR
Dependency id.
dependent_service_id VARCHAR
The service that depends on the other.
dependent_service_type VARCHAR
business_service or service (technical).
supporting_service_id VARCHAR
The service it depends on.
supporting_service_type VARCHAR
business_service or service (technical).
ConstraintsPRIMARY KEY (relationship_id)
Example

Which technical services each business service depends on

SELECT b.name AS business_service, s.name AS supported_by
FROM pagerduty.main.service_dependencies d
JOIN pagerduty.main.business_services b ON b.business_service_id = d.dependent_service_id
JOIN pagerduty.main.services s ON s.service_id = d.supporting_service_id
ORDER BY 1, 2;
Link
services 2 examples17 cols

PagerDuty services: what can be paged, its escalation policy, teams and incident settings

Columns
service_idnot null VARCHAR
PagerDuty id of the technical service (joins incidents.service_id).
name VARCHAR
Service name.
description VARCHAR
Free-text summary of what the service is.
status VARCHAR
active, warning, critical, maintenance or disabled.
escalation_policy_id VARCHAR
The policy that pages for this service (joins escalation_policies).
escalation_policy VARCHAR
Escalation policy name.
team_ids VARCHAR[]
Owning team ids.
teams VARCHAR[]
Owning team names.
created_at TIMESTAMP WITH TIME ZONE
When the service was created.
updated_at TIMESTAMP WITH TIME ZONE
When the service last changed.
last_incident_at TIMESTAMP WITH TIME ZONE
When its last incident was triggered.
acknowledgement_timeout INTEGER
Seconds before an acknowledged incident re-triggers (NULL = never).
auto_resolve_timeout INTEGER
Seconds before an open incident auto-resolves (NULL = never).
alert_creation VARCHAR
create_incidents or create_alerts_and_incidents.
urgency_rule VARCHAR
Incident urgency rule: constant:high, constant:low, severity_based or use_support_hours.
integration_count INTEGER
Number of integrations sending events to the service.
url VARCHAR
Link to the service in the PagerDuty web UI.
ConstraintsPRIMARY KEY (service_id) · FOREIGN KEY (escalation_policy_id) REFERENCES escalation_policies(escalation_policy_id)
Examples (2)

Services that are not healthy right now

SELECT name, status, escalation_policy
FROM pagerduty.main.services
WHERE status <> 'active'
ORDER BY name;

Incident count per service

SELECT s.name, count(i.incident_id) AS incidents
FROM pagerduty.main.services s
LEFT JOIN pagerduty.main.incidents(date_range := 'all') i ON i.service_id = s.service_id
GROUP BY s.name
ORDER BY incidents DESC;
Link
status_pages 1 example5 cols

PagerDuty status pages (public and private), when the account has Status Pages

Columns
status_page_idnot null VARCHAR
PagerDuty id of the status page.
name VARCHAR
Title shown on the status page.
status_page_type VARCHAR
public or private.
url VARCHAR
The status page URL.
published_at TIMESTAMP WITH TIME ZONE
When it was published.
ConstraintsPRIMARY KEY (status_page_id)
Example

Status pages

SELECT name, status_page_type, url
FROM pagerduty.main.status_pages
ORDER BY name;
Link
tags 1 example2 cols

PagerDuty tags (labels attached to users, teams and escalation policies)

Columns
tag_idnot null VARCHAR
PagerDuty id of the tag.
label VARCHAR
Tag label.
ConstraintsPRIMARY KEY (tag_id)
Example

All tag labels

SELECT label FROM pagerduty.main.tags ORDER BY label;
Link
team_members 1 example5 cols

Members of PagerDuty teams with their team role

Columns
team_idnot null VARCHAR
The team (joins teams).
team_name VARCHAR
Name of the team (NULL when read by team_id filter).
user_idnot null VARCHAR
The member (joins users).
user_name VARCHAR
Member name.
role VARCHAR
Team role: manager, responder or observer.
ConstraintsPRIMARY KEY (team_id, user_id) · FOREIGN KEY (team_id) REFERENCES teams(team_id) · FOREIGN KEY (user_id) REFERENCES users(user_id)
Example

Team sizes and managers

SELECT team_name, count(*) FILTER (role = 'manager') AS managers,
  count(*) AS members
FROM pagerduty.main.team_members
GROUP BY team_name
ORDER BY team_name;
Link
teams 1 example5 cols

PagerDuty teams: the groups that own services, schedules and escalation policies

Columns
team_idnot null VARCHAR
PagerDuty id of the team (e.g. PT1234).
name VARCHAR
Team name.
description VARCHAR
Free-text summary of what the team owns.
parent_team_id VARCHAR
Parent team id (team hierarchies).
url VARCHAR
Link to the team in the PagerDuty web UI.
ConstraintsPRIMARY KEY (team_id)
Example

All teams

SELECT name, description FROM pagerduty.main.teams ORDER BY name;
Link
users 1 example13 cols

PagerDuty users with role, teams and which contact method types they have (never the addresses)

Columns
user_idnot null VARCHAR
PagerDuty id of the user (e.g. PU1234).
name VARCHAR
Full name.
email VARCHAR
Login email address.
role VARCHAR
Account role: owner, admin, user, limited_user, observer, restricted_access, read_only_user, ...
job_title VARCHAR
The user's job title from their profile.
time_zone VARCHAR
The user's time zone.
description VARCHAR
Bio / description.
invitation_sent BOOLEAN
True while the user has not accepted the invitation.
team_ids VARCHAR[]
Ids of the teams the user belongs to.
teams VARCHAR[]
Names of the teams the user belongs to.
contact_method_types VARCHAR[]
Distinct contact method types: email, phone, sms, push.
contact_method_count INTEGER
Number of contact methods.
url VARCHAR
Link to the user in the PagerDuty web UI.
ConstraintsPRIMARY KEY (user_id)
Example

Users with no phone contact method (pages may not wake them)

SELECT name, role, contact_method_types
FROM pagerduty.main.users
WHERE NOT list_contains(contact_method_types, 'phone')
ORDER BY name;
Link
Table functions
analytics_incident_metrics (aggregate_unit := VARCHAR, service_ids := VARCHAR[], since := TIMESTAMP WITH TIME ZONE, team_ids := VARCHAR[], until := TIMESTAMP WITH TIME ZONE, urgency := VARCHAR) 1 example

PagerDuty Analytics aggregate incident metrics (mean time to ack / resolve, interruptions), optionally per day, week or month

Named arguments
aggregate_unit := VARCHAR
day, week or month for one row per period; NULL for one row. · default null
service_ids := VARCHAR[]
Count only incidents of these services. · default null
since := TIMESTAMP WITH TIME ZONE
Start of the window (default 30 days before until). · default null
team_ids := VARCHAR[]
Count only incidents of these teams. · default null
until := TIMESTAMP WITH TIME ZONE
End of the window (default now). PagerDuty caps the since..until span; see the function docs. · default null
urgency := VARCHAR
Count only high or low urgency incidents. · default null
Returns columns
range_start TIMESTAMP WITH TIME ZONE
Start of the period (NULL without aggregate_unit).
total_incident_count INTEGER
Incidents created in the period.
mean_time_to_ack_seconds DOUBLE
Mean seconds to first acknowledgement.
mean_time_to_resolve_seconds DOUBLE
Mean seconds to resolution.
mean_seconds_to_engage DOUBLE
Mean seconds until a responder engaged.
mean_seconds_to_mobilize DOUBLE
Mean seconds until more responders were mobilized.
total_interruptions INTEGER
Interruptions.
total_business_hour_interruptions INTEGER
Interruptions in business hours.
total_off_hour_interruptions INTEGER
Interruptions off hours.
total_sleep_hour_interruptions INTEGER
Interruptions in sleep hours.
total_notifications INTEGER
Notifications.
total_escalation_count INTEGER
Escalations.
mean_assignment_count DOUBLE
Mean assignments per incident.
up_time_pct DOUBLE
Percentage of the period with no open incident.
Example

Monthly incident count and MTTA trend

SELECT range_start, total_incident_count,
  mean_time_to_ack_seconds / 60 AS mtta_minutes
FROM pagerduty.main.analytics_incident_metrics(since := TIMESTAMPTZ '2026-08-01', until := TIMESTAMPTZ '2026-11-01', aggregate_unit := 'month')
ORDER BY range_start;
Link
analytics_incidents (page_size := BIGINT, since := TIMESTAMP WITH TIME ZONE, until := TIMESTAMP WITH TIME ZONE) 1 example

PagerDuty Analytics per-incident metrics: time to ack / resolve / engage, interruptions, escalations

Named arguments
page_size := BIGINT
Rows per Analytics API page (named; at most 1000). · default 1000
since := TIMESTAMP WITH TIME ZONE
Start of the time window (inclusive). Defaults from a pushed time filter, else 30 days ago. · default null
until := TIMESTAMP WITH TIME ZONE
End of the time window (exclusive). Defaults from a pushed time filter, else now. · default null
Returns columns
incident_id VARCHAR
Incident id.
incident_number BIGINT
Incident number.
title VARCHAR
Incident title.
service VARCHAR
Service name.
service_id VARCHAR
Service id.
team VARCHAR
Team name.
team_id VARCHAR
Team id.
escalation_policy_id VARCHAR
Escalation policy id.
created_at TIMESTAMP WITH TIME ZONE
When the incident was triggered.
resolved_at TIMESTAMP WITH TIME ZONE
When it was resolved.
urgency VARCHAR
high or low.
major BOOLEAN
True for a major incident.
priority VARCHAR
Priority name.
priority_id VARCHAR
Priority id.
time_to_ack_seconds DOUBLE
Seconds to the first acknowledgement.
time_to_resolve_seconds DOUBLE
Seconds to resolution.
seconds_to_engage DOUBLE
Seconds until the first responder engaged.
seconds_to_mobilize DOUBLE
Seconds until additional responders were mobilized.
engaged_seconds DOUBLE
Total responder time spent engaged.
engaged_user_count INTEGER
Distinct responders who engaged.
escalation_count INTEGER
Escalations.
assignment_count INTEGER
Assignments.
total_notifications INTEGER
Notifications sent.
total_interruptions INTEGER
Interruptions (notifications that paged a human).
business_hour_interruptions INTEGER
Interruptions during business hours.
off_hour_interruptions INTEGER
Interruptions outside business hours.
sleep_hour_interruptions INTEGER
Interruptions during sleep hours.
Example

MTTA and sleep-hour interruptions per service since October

SELECT service, count(*) AS incidents,
  avg(time_to_ack_seconds) / 60 AS mtta_minutes,
  sum(sleep_hour_interruptions) AS sleep_interruptions
FROM pagerduty.main.analytics_incidents(since := TIMESTAMPTZ '2026-10-01')
GROUP BY service
ORDER BY incidents DESC;
Link
audit_records (page_size := BIGINT, since := TIMESTAMP WITH TIME ZONE, until := TIMESTAMP WITH TIME ZONE) 1 example

PagerDuty audit trail: who created, changed or deleted users, teams, schedules, policies and services

Named arguments
page_size := BIGINT
Rows requested per PagerDuty page (named; at most 100). · default 100
since := TIMESTAMP WITH TIME ZONE
Start of the window (inclusive). Defaults from a pushed execution_time filter, else 7 days ago. · default null
until := TIMESTAMP WITH TIME ZONE
End of the time window (exclusive). Defaults from a pushed time filter, else now. · default null
Returns columns
record_id VARCHAR
Audit record id.
execution_time TIMESTAMP WITH TIME ZONE
When the change was made.
action VARCHAR
create, update or delete.
root_resource_type VARCHAR
users, teams, schedules, escalation_policies or services.
root_resource_id VARCHAR
Id of the changed resource.
root_resource_name VARCHAR
Name of the changed resource.
actor_type VARCHAR
user_reference, api_key_reference or app_reference.
actor_id VARCHAR
Id of the actor.
actor_name VARCHAR
Name of the actor.
method_type VARCHAR
How the change was made: browser, oauth, api_token, identity_provider, other.
method_description VARCHAR
Description of the method (e.g. the API key's name).
method_truncated_token VARCHAR
Last characters of the API key used, if any.
request_id VARCHAR
PagerDuty request id.
remote_address VARCHAR
IP address the change came from.
changed_fields STRUCT of 3 fields[]
Fields the change touched, with the value before and after.
STRUCT[] 3 fields
  • nameVARCHAR
  • before_valueVARCHAR
  • valueVARCHAR
details JSON
The full change details as JSON.
Example

Everything deleted since November 1st, and by whom

SELECT execution_time, actor_name, action, root_resource_type,
  root_resource_name
FROM pagerduty.main.audit_records()
WHERE execution_time >= TIMESTAMPTZ '2026-11-01' AND action = 'delete'
ORDER BY execution_time;
Link
change_events (integration_ids := VARCHAR[], page_size := BIGINT, since := TIMESTAMP WITH TIME ZONE, team_ids := VARCHAR[], until := TIMESTAMP WITH TIME ZONE) 2 examples

Recent PagerDuty change events: deploys, config changes and other 'what changed' signals

Named arguments
integration_ids := VARCHAR[]
Only change events sent through these integrations. · default null
page_size := BIGINT
Rows requested per PagerDuty page (named; at most 100). · default 100
since := TIMESTAMP WITH TIME ZONE
Start of the time window (inclusive). Defaults from a pushed time filter, else 30 days ago. · default null
team_ids := VARCHAR[]
Only change events of these teams. · default null
until := TIMESTAMP WITH TIME ZONE
End of the time window (exclusive). Defaults from a pushed time filter, else now. · default null
Returns columns
change_event_id VARCHAR
Change event id.
summary VARCHAR
What changed.
occurred_at TIMESTAMP WITH TIME ZONE
When the change happened (the event timestamp).
source VARCHAR
The system that reported the change.
service_ids VARCHAR[]
Ids of the affected services.
services VARCHAR[]
Names of the affected services.
integration_id VARCHAR
Integration that received the event.
links STRUCT(href VARCHAR, text VARCHAR)[]
Links attached to the event (build, diff, ...).
custom_details JSON
The event's custom details as JSON.
Examples (2)

Changes since November 1st, newest first

SELECT occurred_at, summary, services
FROM pagerduty.main.change_events()
WHERE occurred_at >= TIMESTAMPTZ '2026-11-01'
ORDER BY occurred_at DESC;

Changes on the same service in the hour before each incident

SELECT i.incident_number, c.summary AS change, c.occurred_at
FROM pagerduty.main.incidents(date_range := 'all') i
JOIN pagerduty.main.change_events(since := TIMESTAMPTZ '2026-11-01') c ON list_contains(c.service_ids, i.service_id) AND c.occurred_at BETWEEN i.created_at - INTERVAL 1 HOUR AND i.created_at
ORDER BY i.incident_number;
Link
incident_alerts (incident_id := VARCHAR, page_size := BIGINT, since := TIMESTAMP WITH TIME ZONE, until := TIMESTAMP WITH TIME ZONE) 2 examples

The alerts grouped into PagerDuty incidents (the monitoring events behind each page)

Named arguments
incident_id := VARCHAR
Read only this incident's alerts. · default null
page_size := BIGINT
Rows requested per PagerDuty page (named; at most 100). · default 100
since := TIMESTAMP WITH TIME ZONE
Start of the time window (inclusive). Defaults from a pushed time filter, else 30 days ago. · default null
until := TIMESTAMP WITH TIME ZONE
End of the time window (exclusive). Defaults from a pushed time filter, else now. · default null
Returns columns
alert_id VARCHAR
Alert id.
incident_id VARCHAR
The incident the alert is grouped into.
alert_key VARCHAR
De-duplication key of the alert.
status VARCHAR
triggered or resolved.
severity VARCHAR
critical, error, warning or info.
summary VARCHAR
Alert summary.
created_at TIMESTAMP WITH TIME ZONE
When the alert was created.
service_id VARCHAR
Service id.
service VARCHAR
Service name.
integration_id VARCHAR
The integration that sent the event.
suppressed BOOLEAN
True when the alert was suppressed (did not create an incident).
url VARCHAR
Link to the alert in the PagerDuty web UI.
details JSON
The event's custom details (body.details) as JSON.
Examples (2)

Alert severities behind one incident

SELECT severity, count(*) AS alerts
FROM pagerduty.main.incident_alerts(incident_id := 'Q2CHECKOUT500')
GROUP BY severity
ORDER BY alerts DESC;

The noisiest alert keys since October

SELECT service, alert_key, count(*) AS alerts
FROM pagerduty.main.incident_alerts(since := TIMESTAMPTZ '2026-10-01')
GROUP BY ALL
ORDER BY alerts DESC
LIMIT 10;
Link
incident_log_entries (incident_id := VARCHAR, is_overview := BOOLEAN, page_size := BIGINT, since := TIMESTAMP WITH TIME ZONE, team_ids := VARCHAR[], until := TIMESTAMP WITH TIME ZONE) 2 examples

The timeline of PagerDuty incidents: trigger, acknowledge, assign, escalate, notify and resolve entries

Named arguments
incident_id := VARCHAR
Read one incident's timeline (all time) instead of the account-wide window. · default null
is_overview := BOOLEAN
Only the major entries (state changes) rather than every notification. · default false
page_size := BIGINT
Rows requested per PagerDuty page (named; at most 100). · default 100
since := TIMESTAMP WITH TIME ZONE
Start of the time window (inclusive). Defaults from a pushed time filter, else 30 days ago. · default null
team_ids := VARCHAR[]
Account-wide listing only: entries of these teams' incidents. · default null
until := TIMESTAMP WITH TIME ZONE
End of the time window (exclusive). Defaults from a pushed time filter, else now. · default null
Returns columns
log_entry_id VARCHAR
Log entry id.
incident_id VARCHAR
The incident this entry belongs to.
type VARCHAR
Entry type without the _log_entry suffix: trigger, acknowledge, unacknowledge, assign, escalate, notify, annotate, snooze, resolve, ...
raw_type VARCHAR
PagerDuty's entry type, e.g. acknowledge_log_entry.
summary VARCHAR
Human-readable summary of the entry.
created_at TIMESTAMP WITH TIME ZONE
When it happened.
agent_type VARCHAR
Who or what acted: user, service, integration, ... (the _reference suffix dropped).
agent_id VARCHAR
Id of the acting user / service / integration.
agent_name VARCHAR
Name of the acting user / service / integration.
channel_type VARCHAR
Channel the action came through: web_trigger, api, email, sms, auto, timeout, ...
service_id VARCHAR
Service of the incident.
service VARCHAR
Service name.
assignees VARCHAR[]
Users assigned by an assign/escalate entry.
assignee_ids VARCHAR[]
Ids of the users assigned by an assign/escalate entry.
user_name VARCHAR
User notified (notify entries).
notification_type VARCHAR
How a notify entry reached the user: sms, phone, email, push.
note VARCHAR
Note text of an annotate entry.
Examples (2)

The timeline of one incident

SELECT type, agent_name, created_at
FROM pagerduty.main.incident_log_entries(incident_id := 'Q2CHECKOUT500')
ORDER BY created_at;

Who acknowledges the most incidents

SELECT agent_name, count(*) AS acks
FROM pagerduty.main.incident_log_entries()
WHERE type = 'acknowledge' AND created_at >= TIMESTAMPTZ '2026-10-01'
GROUP BY agent_name
ORDER BY acks DESC;
Link
incident_notes (incident_id := VARCHAR, page_size := BIGINT, since := TIMESTAMP WITH TIME ZONE, until := TIMESTAMP WITH TIME ZONE) 1 example

Notes responders added to PagerDuty incidents

Named arguments
incident_id := VARCHAR
Read only this incident's notes. · default null
page_size := BIGINT
Page size of the parent incident listing (named; at most 100). · default 100
since := TIMESTAMP WITH TIME ZONE
Start of the time window (inclusive). Defaults from a pushed time filter, else 30 days ago. · default null
until := TIMESTAMP WITH TIME ZONE
End of the time window (exclusive). Defaults from a pushed time filter, else now. · default null
Returns columns
note_id VARCHAR
Note id.
incident_id VARCHAR
The incident the note is on.
created_at TIMESTAMP WITH TIME ZONE
When the note was added.
user_id VARCHAR
Author's user id.
user_name VARCHAR
Author's name.
channel VARCHAR
Where the note came from (e.g. The PagerDuty website or APIs).
content VARCHAR
The note text.
Example

Responder notes on one incident

SELECT user_name, created_at, content
FROM pagerduty.main.incident_notes(incident_id := 'Q2CHECKOUT500')
ORDER BY created_at;
Link
incidents (date_range := VARCHAR, page_size := BIGINT, since := TIMESTAMP WITH TIME ZONE, sort_by := VARCHAR, team_ids := VARCHAR[], until := TIMESTAMP WITH TIME ZONE, user_ids := VARCHAR[], with_timeline := BOOLEAN) 2 examples

PagerDuty incidents with status, urgency, priority, assignees and time to ack / resolve

Named arguments
date_range := VARCHAR
'all' reads incidents from all time; 'window' (or NULL) uses since/until or the default 30-day window. · default null
page_size := BIGINT
Rows requested per PagerDuty page (named; at most 100). · default 100
since := TIMESTAMP WITH TIME ZONE
Start of the time window (inclusive). Defaults from a pushed time filter, else 30 days ago. · default null
sort_by := VARCHAR
Order PagerDuty returns rows in: created_at, incident_number, resolved_at or urgency, with :asc or :desc. · default null
team_ids := VARCHAR[]
Only incidents of these team ids (PagerDuty team_ids[]). · default null
until := TIMESTAMP WITH TIME ZONE
End of the time window (exclusive). Defaults from a pushed time filter, else now. · default null
user_ids := VARCHAR[]
Only incidents currently assigned to these user ids (PagerDuty user_ids[]). · default null
with_timeline := BOOLEAN
Read each incident's log entries for exact acknowledged_at / resolved_at / escalation_count. · default false
Returns columns
incident_id VARCHAR
PagerDuty incident id (e.g. Q1ABCDEF2GHIJK).
incident_number BIGINT
The account-wide incident number shown in the PagerDuty UI.
title VARCHAR
Incident title.
status VARCHAR
Normalized status: triggered, acknowledged or resolved.
raw_status VARCHAR
The status exactly as PagerDuty returned it.
urgency VARCHAR
Urgency: high or low.
priority VARCHAR
Priority name (e.g. P1), or NULL when none is set.
priority_id VARCHAR
Priority id.
service VARCHAR
Name of the service the incident is on.
service_id VARCHAR
Service id.
escalation_policy VARCHAR
Escalation policy name.
escalation_policy_id VARCHAR
Escalation policy id.
team_ids VARCHAR[]
Ids of the teams the incident belongs to.
teams VARCHAR[]
Names of the teams the incident belongs to.
created_at TIMESTAMP WITH TIME ZONE
When the incident was triggered.
updated_at TIMESTAMP WITH TIME ZONE
When the incident last changed.
acknowledged_at TIMESTAMP WITH TIME ZONE
First acknowledgement: from the log entries with with_timeline := true, else the current acknowledgements (cleared once resolved).
resolved_at TIMESTAMP WITH TIME ZONE
When the incident was resolved (NULL while open).
time_to_ack_seconds DOUBLE
Seconds from created_at to acknowledged_at.
time_to_resolve_seconds DOUBLE
Seconds from created_at to resolved_at.
acknowledged_by VARCHAR
Who acknowledged first (log entries with with_timeline := true, else current acknowledgers).
resolved_by VARCHAR
Who resolved it (with_timeline := true), else the last status changer of a resolved incident.
escalation_count INTEGER
Escalations in the log entries (with_timeline := true only, else NULL).
assignees VARCHAR[]
Names of the users currently assigned.
assignee_ids VARCHAR[]
Ids of the users currently assigned.
alert_count INTEGER
Alerts grouped into the incident.
incident_key VARCHAR
De-duplication key of the incident.
last_status_change_at TIMESTAMP WITH TIME ZONE
When the status last changed.
timeline_source VARCHAR
Where acknowledged_at / resolved_at came from: log_entries or incident.
url VARCHAR
Link to the incident in the PagerDuty web UI.
Examples (2)

High-urgency incidents and median time to resolve per service since October

SELECT service, count(*) AS incidents,
  median(time_to_resolve_seconds) / 60 AS median_minutes_to_resolve
FROM pagerduty.main.incidents(with_timeline := true)
WHERE created_at >= TIMESTAMPTZ '2026-10-01' AND urgency = 'high'
GROUP BY service
ORDER BY incidents DESC;

Every open incident (an open-only status filter reads all time)

SELECT incident_number, title, service, created_at
FROM pagerduty.main.incidents()
WHERE status IN ('triggered', 'acknowledged')
ORDER BY created_at;
Link
oncalls (earliest := BOOLEAN, page_size := BIGINT, since := TIMESTAMP WITH TIME ZONE, until := TIMESTAMP WITH TIME ZONE) 2 examples

Who is (or was) on call: one row per user, escalation policy level and schedule

Named arguments
earliest := BOOLEAN
Only the earliest on-call shift per user, escalation policy and level. · default false
page_size := BIGINT
Rows requested per PagerDuty page (named; at most 100). · default 100
since := TIMESTAMP WITH TIME ZONE
Start of the window to report on-call shifts for (default: now). · default null
until := TIMESTAMP WITH TIME ZONE
End of the window (default: now). PagerDuty caps the since..until span; see the function docs. · default null
Returns columns
user_id VARCHAR
On-call user id.
user_name VARCHAR
On-call user name.
schedule_id VARCHAR
Schedule that put the user on call (NULL for a direct escalation target).
schedule_name VARCHAR
Schedule name.
escalation_policy_id VARCHAR
Escalation policy id.
escalation_policy_name VARCHAR
Escalation policy name.
escalation_level INTEGER
Escalation level (1 = first responder).
start_time TIMESTAMP WITH TIME ZONE
Shift start (NULL for a permanent on-call).
end_time TIMESTAMP WITH TIME ZONE
Shift end (NULL for a permanent on-call).
Examples (2)

Who is on call right now, per escalation policy and level

SELECT escalation_policy_name, escalation_level, user_name
FROM pagerduty.main.oncalls()
ORDER BY escalation_policy_name, escalation_level;

First-responder hours per person in one week

SELECT user_name, sum(epoch(end_time) - epoch(start_time)) / 3600 AS hours
FROM pagerduty.main.oncalls(since := TIMESTAMPTZ '2026-11-01', until := TIMESTAMPTZ '2026-11-08')
WHERE escalation_level = 1
GROUP BY user_name
ORDER BY hours DESC;
Link
schedule_entries (schedule_id := VARCHAR, since := TIMESTAMP WITH TIME ZONE, until := TIMESTAMP WITH TIME ZONE) 1 example

Rendered on-call shifts of PagerDuty schedules: who was on call when

Named arguments
schedule_id := VARCHAR
Read only this schedule. · default null
since := TIMESTAMP WITH TIME ZONE
Start of the window (default: 7 days ago). · default null
until := TIMESTAMP WITH TIME ZONE
End of the window (default: 14 days after since). · default null
Returns columns
schedule_id VARCHAR
Schedule id.
schedule_name VARCHAR
Schedule name.
user_id VARCHAR
On-call user id.
user_name VARCHAR
On-call user name.
start_time TIMESTAMP WITH TIME ZONE
Shift start (clipped to the window).
end_time TIMESTAMP WITH TIME ZONE
Shift end (clipped to the window).
duration_seconds DOUBLE
Shift length in seconds.
Example

On-call hours per person and schedule for one week

SELECT schedule_name, user_name, sum(duration_seconds) / 3600 AS hours
FROM pagerduty.main.schedule_entries(since := TIMESTAMPTZ '2026-11-01', until := TIMESTAMPTZ '2026-11-08')
GROUP BY ALL
ORDER BY hours DESC;
Link

Credentials

The secret type pagerduty declares, as reported by the worker itself.

pagerduty

How to get these credentials

A PagerDuty REST API key or OAuth access token, plus the account's region

secret.sql
CREATE SECRET pagerduty (
    TYPE pagerduty,
    api_token   '<API_TOKEN>',  -- secret
    oauth_token '<OAUTH_TOKEN>',  -- secret
    region      '<region>',
    base_url    '<base_url>'
);
Key Type Required Description
api_token secret VARCHAR — REST API key (Integrations > API Access Keys), sent as 'Token token=<key>'. Use this or OAUTH_TOKEN.
oauth_token secret VARCHAR — OAuth 2.0 access token (sent as 'Bearer <token>') instead of a key.
region VARCHAR — 'us' (default, api.pagerduty.com) or 'eu' (api.eu.pagerduty.com).
base_url VARCHAR — Overrides the region's API URL (https only; http:// is accepted for 127.0.0.1/localhost).

The worker doesn't mark which keys are required.

Create the secret in the same session, after attaching pagerduty — the worker registers its secret types at ATTACH. Keys marked secret are masked in duckdb_secrets(); angle-bracket values are placeholders. Read credentials from your environment or secret store in your application and pass them through your SQL client’s parameter bindings. Keep real values out of saved SQL and history. Native DuckDB and Haybarn do not provide a SQL getenv() function.

Try these queries

incidents_columns — The incidents() result columns (binds only; create a pagerduty secret and drop LIMIT 0 for rows)

SELECT incident_id, title, status, urgency, time_to_ack_seconds
FROM pagerduty.main.incidents()
LIMIT 0;

Uses incidents

oncalls_columns — The oncalls() result columns (binds only; create a pagerduty secret and drop LIMIT 0 for rows)

SELECT user_name, escalation_policy_name, escalation_level
FROM pagerduty.main.oncalls()
LIMIT 0;

Uses oncalls

The timeline of one incident

SELECT type, agent_name, created_at
FROM pagerduty.main.incident_log_entries(incident_id := 'Q2CHECKOUT500')
ORDER BY created_at

Uses incident_log_entries

Alert severities behind one incident

SELECT severity, count(*) AS alerts
FROM pagerduty.main.incident_alerts(incident_id := 'Q2CHECKOUT500')
GROUP BY severity
ORDER BY alerts DESC

Uses incident_alerts

Responder notes on one incident

SELECT user_name, created_at, content
FROM pagerduty.main.incident_notes(incident_id := 'Q2CHECKOUT500')
ORDER BY created_at

Uses incident_notes

On-call hours per person and schedule for one week

SELECT schedule_name, user_name, sum(duration_seconds) / 3600 AS hours
FROM pagerduty.main.schedule_entries(since := TIMESTAMPTZ '2026-11-01', until := TIMESTAMPTZ '2026-11-08')
GROUP BY ALL
ORDER BY hours DESC

Uses schedule_entries

25 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • Which PagerDuty incidents are still open (not resolved)? Give their numbers and titles.
  • How many PagerDuty incidents has each service had in total, across all time?
  • What was the time to acknowledge, in seconds, of PagerDuty incident number 1042?
  • Who acknowledged PagerDuty incident Q2CHECKOUT500?
  • How many alerts does incident Q2CHECKOUT500 have, by severity?
  • Who is the first-level on-call for the Checkout escalation policy right now?

PagerDuty is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.