Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat(pki): add pagerduty channel to PKI alerting and split alerting docs (#5433)

Saif Ur Rahmanbbf0d79b98a2
diff --git a/backend/src/services/pki-alert-v2/pki-alert-v2-channel-email-fns.ts b/backend/src/services/pki-alert-v2/pki-alert-v2-channel-email-fns.ts
index 81f8e69432..f3bbb25e9f 100644
--- a/backend/src/services/pki-alert-v2/pki-alert-v2-channel-email-fns.ts
+++ b/backend/src/services/pki-alert-v2/pki-alert-v2-channel-email-fns.ts
@@ -46,7 +46,7 @@ export const sendEmailNotificationWithRetry = async (
alertBeforeDays: number,
projectId: string,
matchingCertificates: TCertificatePreview[],
- alertId: string
+ channelId: string
): Promise<TChannelResult> => {
const { maxRetries, delayMs } = PKI_ALERT_RETRY_CONFIG;
let lastError: Error | undefined;
@@ -60,15 +60,12 @@ export const sendEmailNotificationWithRetry = async (
lastError = err instanceof Error ? err : new Error(String(err));
if (!isEmailErrorRetryable(lastError)) {
- logger.info(
- { alertId, recipients: config.recipients, error: lastError.message },
- "PKI email error is not retryable (permanent SMTP error)"
- );
+ logger.info({ channelId, error: lastError.message }, "PKI email error is not retryable (permanent SMTP error)");
return { success: false, error: lastError.message };
}
logger.info(
- { alertId, recipients: config.recipients, attempt, maxRetries, error: lastError.message },
+ { channelId, attempt, maxRetries, error: lastError.message },
`PKI email failed, ${attempt < maxRetries ? `retrying in ${delayMs}ms` : "no more retries"}`
);
diff --git a/backend/src/services/pki-alert-v2/pki-alert-v2-channel-pagerduty-fns.ts b/backend/src/services/pki-alert-v2/pki-alert-v2-channel-pagerduty-fns.ts
new file mode 100644
index 0000000000..4f40246626
--- /dev/null
+++ b/backend/src/services/pki-alert-v2/pki-alert-v2-channel-pagerduty-fns.ts
@@ -0,0 +1,211 @@
+import { AxiosError } from "axios";
+
+import { getConfig } from "@app/lib/config/env";
+import { request } from "@app/lib/config/request";
+import { delay } from "@app/lib/delay";
+import { logger } from "@app/lib/logger";
+
+import { PKI_ALERT_RETRY_CONFIG, RETRYABLE_NETWORK_ERRORS } from "./pki-alert-v2-constants";
+import {
+ pagerDutyIntegrationKeyRegex,
+ TAlertInfo,
+ TBuildPagerDutyPayloadParams,
+ TCertificatePreview,
+ TChannelResult,
+ TPagerDutyChannelConfig,
+ TPagerDutyPayload
+} from "./pki-alert-v2-types";
+
+const PAGERDUTY_EVENTS_URL = "https://events.pagerduty.com/v2/enqueue";
+const PAGERDUTY_TIMEOUT = 7 * 1000;
+const MAX_CERTIFICATES_IN_PAYLOAD = 10;
+
+/**
+ * Validates that the integration key is a valid 32-character hex string.
+ */
+export const validatePagerDutyIntegrationKey = (integrationKey: string): boolean => {
+ return pagerDutyIntegrationKeyRegex.test(integrationKey);
+};
+
+/**
+ * Determines PagerDuty severity based on the most urgent certificate's days until expiry.
+ *
+ * <=7 days -> critical
+ * <=14 days -> error
+ * <=30 days -> warning
+ * >30 days -> info
+ */
+const getSeverity = (certificates: TCertificatePreview[]): "critical" | "error" | "warning" | "info" => {
+ const now = new Date();
+ let minDays = Infinity;
+
+ for (const cert of certificates) {
+ const notAfter = new Date(cert.notAfter);
+ const daysUntilExpiry = Math.ceil((notAfter.getTime() - now.getTime()) / (1000 * 60 * 60 * 24));
+ if (daysUntilExpiry < minDays) {
+ minDays = daysUntilExpiry;
+ }
+ }
+
+ if (minDays <= 7) return "critical";
+ if (minDays <= 14) return "error";
+ if (minDays <= 30) return "warning";
+ return "info";
+};
+
+/**
+ * Builds a PagerDuty Events API v2 payload (PD-CEF format).
+ *
+ * - Uses alertId as dedup_key to group related events into the same incident
+ * - Caps certificates at 10 to stay under the 512KB payload limit
+ * - Severity is auto-mapped from the most urgent certificate
+ */
+export const buildPagerDutyPayload = ({
+ alert,
+ certificates,
+ integrationKey,
+ appUrl = "https://app.infisical.com"
+}: TBuildPagerDutyPayloadParams): TPagerDutyPayload => {
+ const now = new Date();
+ const totalCertificates = certificates.length;
+ const severity = getSeverity(certificates);
+
+ const sortedCertificates = [...certificates].sort((a, b) => {
+ const aExpiry = new Date(a.notAfter).getTime();
+ const bExpiry = new Date(b.notAfter).getTime();
+ return aExpiry - bExpiry;
+ });
+
+ const displayCertificates = sortedCertificates.slice(0, MAX_CERTIFICATES_IN_PAYLOAD);
+
+ const viewUrl = `${appUrl}/projects/cert-manager/${alert.projectId}/policies`;
+
+ return {
+ routing_key: integrationKey,
+ event_action: "trigger",
+ dedup_key: alert.id,
+ payload: {
+ summary: `Infisical: ${totalCertificates} certificate(s) expiring within ${alert.alertBefore} - Alert: ${alert.name}`,
+ severity,
+ source: "infisical-pki-alerts",
+ timestamp: now.toISOString(),
+ component: "certificate-manager",
+ group: alert.projectId,
+ class: "certificate-expiration",
+ custom_details: {
+ alert_name: alert.name,
+ alert_before: alert.alertBefore,
+ total_certificates: totalCertificates,
+ certificates: displayCertificates.map((cert) => {
+ const notAfter = new Date(cert.notAfter);
+ const daysUntilExpiry = Math.ceil((notAfter.getTime() - now.getTime()) / (1000 * 60 * 60 * 24));
+ return {
+ common_name: cert.commonName || "N/A",
+ serial_number: cert.serialNumber,
+ expires_at: notAfter.toISOString(),
+ days_until_expiry: daysUntilExpiry
+ };
+ }),
+ view_url: viewUrl
+ }
+ },
+ links: [{ href: viewUrl, text: "View certificates in Infisical" }]
+ };
+};
+
+const isPagerDutyErrorRetryable = (err: AxiosError): boolean => {
+ const status = err.response?.status;
+ // 400 Bad Request is not retryable
+ if (status === 400) return false;
+ // 429 Rate Limit and 5xx are retryable
+ if (status === 429) return true;
+ if (status && status >= 500) return true;
+ if (err.code && RETRYABLE_NETWORK_ERRORS.includes(err.code)) return true;
+ if (err.message?.toLowerCase().includes("timeout")) return true;
+ return false;
+};
+
+const triggerPagerDutyEvent = async (payload: TPagerDutyPayload): Promise<void> => {
+ await request.post(PAGERDUTY_EVENTS_URL, payload, {
+ headers: {
+ "Content-Type": "application/json"
+ },
+ timeout: PAGERDUTY_TIMEOUT,
+ signal: AbortSignal.timeout(PAGERDUTY_TIMEOUT)
+ });
+};
+
+const triggerPagerDutyEventWithRetry = async (
+ payload: TPagerDutyPayload,
+ channelId: string
+): Promise<TChannelResult> => {
+ const { maxRetries, delayMs } = PKI_ALERT_RETRY_CONFIG;
+ let lastError: AxiosError | undefined;
+
+ for (let attempt = 1; attempt <= maxRetries; attempt += 1) {
+ try {
+ // eslint-disable-next-line no-await-in-loop
+ await triggerPagerDutyEvent(payload);
+ return { success: true };
+ } catch (err) {
+ lastError = err as AxiosError;
+
+ if (!isPagerDutyErrorRetryable(lastError)) {
+ logger.info(
+ {
+ channelId,
+ statusCode: lastError.response?.status,
+ error: lastError.message
+ },
+ "PagerDuty event error is not retryable (4xx or non-transient error)"
+ );
+ return { success: false, error: lastError.message };
+ }
+
+ logger.info(
+ {
+ channelId,
+ attempt,
+ maxRetries,
+ statusCode: lastError.response?.status,
+ error: lastError.message
+ },
+ `PagerDuty event failed, ${attempt < maxRetries ? `retrying in ${delayMs}ms` : "no more retries"}`
+ );
+
+ if (attempt < maxRetries) {
+ // eslint-disable-next-line no-await-in-loop
+ await delay(delayMs);
+ }
+ }
+ }
+
+ return { success: false, error: lastError?.message };
+};
+
+/**
+ * Sends a PagerDuty notification with validation and retry logic.
+ *
+ * Posts to the fixed PagerDuty Events API v2 endpoint.
+ * No SSRF check needed since the endpoint is hardcoded.
+ */
+export const sendPagerDutyNotificationWithRetry = async (
+ config: TPagerDutyChannelConfig,
+ alertData: TAlertInfo,
+ matchingCertificates: TCertificatePreview[],
+ channelId: string
+): Promise<TChannelResult> => {
+ if (!config.integrationKey || !validatePagerDutyIntegrationKey(config.integrationKey)) {
+ return { success: false, error: "Invalid PagerDuty integration key" };
+ }
+
+ const appCfg = getConfig();
+ const payload = buildPagerDutyPayload({
+ alert: alertData,
+ certificates: matchingCertificates,
+ integrationKey: config.integrationKey,
+ appUrl: appCfg.SITE_URL
+ });
+
+ return triggerPagerDutyEventWithRetry(payload, channelId);
+};
diff --git a/backend/src/services/pki-alert-v2/pki-alert-v2-channel-slack-fns.ts b/backend/src/services/pki-alert-v2/pki-alert-v2-channel-slack-fns.ts
index 0247bc7536..471198df68 100644
--- a/backend/src/services/pki-alert-v2/pki-alert-v2-channel-slack-fns.ts
+++ b/backend/src/services/pki-alert-v2/pki-alert-v2-channel-slack-fns.ts
@@ -48,21 +48,6 @@ export const validateSlackWebhookUrl = async (url: string): Promise<void> => {
await blockLocalAndPrivateIpAddresses(url);
};
-/**
- * Masks the Slack webhook URL path to hide the token in logs.
- * The path contains the webhook token which should not be exposed.
- *
- * Example: https://hooks.slack.com/services/T00/B00/XXX -> https://hooks.slack.com/services/***
- */
-export const maskSlackWebhookUrl = (url: string): string => {
- try {
- const parsed = new URL(url);
- return `${parsed.protocol}//${parsed.hostname}/services/***`;
- } catch {
- return "***";
- }
-};
-
/**
* Builds a Slack Block Kit payload for certificate expiration alerts.
*
@@ -205,7 +190,11 @@ const triggerSlackWebhook = async (url: string, payload: TSlackPayload): Promise
});
};
-const triggerSlackWebhookWithRetry = async (url: string, payload: TSlackPayload): Promise<TChannelResult> => {
+const triggerSlackWebhookWithRetry = async (
+ url: string,
+ payload: TSlackPayload,
+ channelId: string
+): Promise<TChannelResult> => {
const { maxRetries, delayMs } = PKI_ALERT_RETRY_CONFIG;
let lastError: AxiosError | undefined;
@@ -219,7 +208,7 @@ const triggerSlackWebhookWithRetry = async (url: string, payload: TSlackPayload)
if (!isSlackErrorRetryable(lastError)) {
logger.info(
- { url: maskSlackWebhookUrl(url), statusCode: lastError.response?.status, error: lastError.message },
+ { channelId, statusCode: lastError.response?.status, error: lastError.message },
"Slack webhook error is not retryable (4xx or non-transient error)"
);
return { success: false, error: lastError.message };
@@ -227,7 +216,7 @@ const triggerSlackWebhookWithRetry = async (url: string, payload: TSlackPayload)
logger.info(
{
- url: maskSlackWebhookUrl(url),
+ channelId,
attempt,
maxRetries,
statusCode: lastError.response?.status,
@@ -257,7 +246,8 @@ const triggerSlackWebhookWithRetry = async (url: string, payload: TSlackPayload)
export const sendSlackNotificationWithRetry = async (
config: TSlackChannelConfig,
alertData: TAlertInfo,
- matchingCertificates: TCertificatePreview[]
+ matchingCertificates: TCertificatePreview[],
+ channelId: string
): Promise<TChannelResult> => {
await validateSlackWebhookUrl(config.webhookUrl);
@@ -268,5 +258,5 @@ export const sendSlackNotificationWithRetry = async (
appUrl: appCfg.SITE_URL
});
- return triggerSlackWebhookWithRetry(config.webhookUrl, payload);
+ return triggerSlackWebhookWithRetry(config.webhookUrl, payload, channelId);
};
diff --git a/backend/src/services/pki-alert-v2/pki-alert-v2-channel-webhook-fns.ts b/backend/src/services/pki-alert-v2/pki-alert-v2-channel-webhook-fns.ts
index 52198a5d00..1cdd4276a2 100644
--- a/backend/src/services/pki-alert-v2/pki-alert-v2-channel-webhook-fns.ts
+++ b/backend/src/services/pki-alert-v2/pki-alert-v2-channel-webhook-fns.ts
@@ -183,6 +183,7 @@ const triggerPkiWebhookWithRetry = async (params: {
url: string;
payload: TPkiWebhookPayload;
signingSecret?: string;
+ channelId: string;
}): Promise<TChannelResult> => {
const { maxRetries, delayMs } = PKI_ALERT_RETRY_CONFIG;
let lastError: AxiosError | undefined;
@@ -197,14 +198,20 @@ const triggerPkiWebhookWithRetry = async (params: {
if (!isWebhookErrorRetryable(lastError)) {
logger.info(
- { url: params.url, statusCode: lastError.response?.status, error: lastError.message },
+ { channelId: params.channelId, statusCode: lastError.response?.status, error: lastError.message },
"PKI webhook error is not retryable (4xx or non-transient error)"
);
return { success: false, error: lastError.message };
}
logger.info(
- { url: params.url, attempt, maxRetries, statusCode: lastError.response?.status, error: lastError.message },
+ {
+ channelId: params.channelId,
+ attempt,
+ maxRetries,
+ statusCode: lastError.response?.status,
+ error: lastError.message
+ },
`PKI webhook failed, ${attempt < maxRetries ? `retrying in ${delayMs}ms` : "no more retries"}`
);
@@ -222,7 +229,8 @@ export const sendWebhookNotification = async (
config: TWebhookChannelConfig,
alertData: TAlertInfo,
matchingCertificates: TCertificatePreview[],
- eventType: PkiWebhookEventType
+ eventType: PkiWebhookEventType,
+ channelId: string
): Promise<TChannelResult> => {
await blockLocalAndPrivateIpAddresses(config.url);
@@ -237,6 +245,7 @@ export const sendWebhookNotification = async (
return triggerPkiWebhookWithRetry({
url: config.url,
payload,
- signingSecret: config.signingSecret ?? undefined
+ signingSecret: config.signingSecret ?? undefined,
+ channelId
});
};
diff --git a/backend/src/services/pki-alert-v2/pki-alert-v2-service.ts b/backend/src/services/pki-alert-v2/pki-alert-v2-service.ts
index f314575522..0e125fd054 100644
--- a/backend/src/services/pki-alert-v2/pki-alert-v2-service.ts
+++ b/backend/src/services/pki-alert-v2/pki-alert-v2-service.ts
@@ -17,11 +17,8 @@ import { TSmtpService } from "@app/services/smtp/smtp-service";
import { TPkiAlertChannelDALFactory } from "./pki-alert-channel-dal";
import { TPkiAlertHistoryDALFactory } from "./pki-alert-history-dal";
import { sendEmailNotificationWithRetry } from "./pki-alert-v2-channel-email-fns";
-import {
- maskSlackWebhookUrl,
- sendSlackNotificationWithRetry,
- validateSlackWebhookUrl
-} from "./pki-alert-v2-channel-slack-fns";
+import { sendPagerDutyNotificationWithRetry } from "./pki-alert-v2-channel-pagerduty-fns";
+import { sendSlackNotificationWithRetry, validateSlackWebhookUrl } from "./pki-alert-v2-channel-slack-fns";
import { sendWebhookNotification } from "./pki-alert-v2-channel-webhook-fns";
import { TAlertWithChannels, TPkiAlertV2DALFactory } from "./pki-alert-v2-dal";
import { parseTimeToDays, parseTimeToPostgresInterval } from "./pki-alert-v2-filter-utils";
@@ -44,6 +41,7 @@ import {
TListCurrentMatchingCertificatesDTO,
TListMatchingCertificatesDTO,
TListMatchingCertificatesResponse,
+ TPagerDutyChannelConfig,
TPkiFilterRule,
TSlackChannelConfig,
TTestWebhookConfigDTO,
@@ -134,7 +132,7 @@ export const pkiAlertV2ServiceFactory = ({
hasSigningSecret: Boolean(webhookConfig.signingSecret)
};
} else {
- // For email and slack channels, the config is the same in request and response
+ // For email, slack, and pagerduty channels, the config is the same in request and response
responseConfig = config as TEmailChannelConfig;
}
@@ -388,7 +386,7 @@ export const pkiAlertV2ServiceFactory = ({
alert = await pkiAlertV2DAL.updateById(alertId, updateData, tx);
if (channels) {
- // Get existing channels to preserve signing secrets if needed
+ // Get existing channels to preserve signing secrets / integration keys if needed
const existingChannels = await pkiAlertChannelDAL.findByAlertId(alertId, tx);
const existingWebhookConfigs = new Map<string, TWebhookChannelConfig>();
@@ -630,9 +628,9 @@ export const pkiAlertV2ServiceFactory = ({
alertBeforeDays,
projectId,
matchingCertificates,
- alertId
+ channel.id
);
- return { ...result, channelType: channel.channelType, recipients: config.recipients };
+ return { ...result, channelType: channel.channelType };
}
case PkiAlertChannelType.WEBHOOK: {
const config = decryptChannelConfig<TWebhookChannelConfig>(channel, decryptor);
@@ -640,18 +638,25 @@ export const pkiAlertV2ServiceFactory = ({
config,
alertData,
matchingCertificates,
- PkiWebhookEventType.CERTIFICATE_EXPIRATION
+ PkiWebhookEventType.CERTIFICATE_EXPIRATION,
+ channel.id
);
- return { ...result, channelType: channel.channelType, url: config.url };
+ return { ...result, channelType: channel.channelType };
}
case PkiAlertChannelType.SLACK: {
const config = decryptChannelConfig<TSlackChannelConfig>(channel, decryptor);
- const result = await sendSlackNotificationWithRetry(config, alertData, matchingCertificates);
- return {
- ...result,
- channelType: channel.channelType,
- webhookUrl: maskSlackWebhookUrl(config.webhookUrl)
- };
+ const result = await sendSlackNotificationWithRetry(config, alertData, matchingCertificates, channel.id);
+ return { ...result, channelType: channel.channelType };
+ }
+ case PkiAlertChannelType.PAGERDUTY: {
+ const config = decryptChannelConfig<TPagerDutyChannelConfig>(channel, decryptor);
+ const result = await sendPagerDutyNotificationWithRetry(
+ config,
+ alertData,
+ matchingCertificates,
+ channel.id
+ );
+ return { ...result, channelType: channel.channelType };
}
default:
return { success: false, channelType: channel.channelType, error: "Unknown channel type" };
@@ -660,21 +665,6 @@ export const pkiAlertV2ServiceFactory = ({
const errorMessage = err instanceof Error ? err.message : "Unknown error";
logger.error(err, `Failed to send ${channel.channelType} notification for alert ${alertId}`);
- // Include context info in error result based on channel type
- if (channel.channelType === PkiAlertChannelType.EMAIL) {
- const config = decryptChannelConfig<TEmailChannelConfig>(channel, decryptor);
- return {
- success: false,
- channelType: channel.channelType,
- error: errorMessage,
- recipients: config.recipients
- };
- }
- if (channel.channelType === PkiAlertChannelType.WEBHOOK) {
- const config = decryptChannelConfig<TWebhookChannelConfig>(channel, decryptor);
- return { success: false, channelType: channel.channelType, error: errorMessage, url: config.url };
- }
-
return { success: false, channelType: channel.channelType, error: errorMessage };
}
});
@@ -686,18 +676,10 @@ export const pkiAlertV2ServiceFactory = ({
// Error details are still captured and shown to admins via in-app notifications
hasNotificationSent = true;
- // Collect errors from failed channels with context info
+ // Collect errors from failed channels
results.forEach((r) => {
if (!r.success && r.error) {
- if (r.channelType === PkiAlertChannelType.EMAIL && "recipients" in r && r.recipients) {
- errors.push(`EMAIL (recipients: ${r.recipients.join(", ")}): ${r.error}`);
- } else if (r.channelType === PkiAlertChannelType.WEBHOOK && "url" in r && r.url) {
- errors.push(`WEBHOOK (url: ${r.url}): ${r.error}`);
- } else if (r.channelType === PkiAlertChannelType.SLACK && "webhookUrl" in r && r.webhookUrl) {
- errors.push(`SLACK (url: ${r.webhookUrl}): ${r.error}`);
- } else {
- errors.push(`${r.channelType}: ${r.error}`);
- }
+ errors.push(`${r.channelType}: ${r.error}`);
}
});
@@ -791,7 +773,8 @@ export const pkiAlertV2ServiceFactory = ({
config,
alertData,
testCertificates,
- PkiWebhookEventType.CERTIFICATE_TEST
+ PkiWebhookEventType.CERTIFICATE_TEST,
+ "test"
);
if (!result.success) {
diff --git a/backend/src/services/pki-alert-v2/pki-alert-v2-types.ts b/backend/src/services/pki-alert-v2/pki-alert-v2-types.ts
index 569b328d1b..2d7a5dc262 100644
--- a/backend/src/services/pki-alert-v2/pki-alert-v2-types.ts
+++ b/backend/src/services/pki-alert-v2/pki-alert-v2-types.ts
@@ -32,7 +32,8 @@ export enum PkiAlertEventType {
export enum PkiAlertChannelType {
EMAIL = "email",
WEBHOOK = "webhook",
- SLACK = "slack"
+ SLACK = "slack",
+ PAGERDUTY = "pagerduty"
}
export enum PkiFilterOperator {
@@ -155,10 +156,21 @@ export const SlackChannelConfigSchema = z.object({
}, "Slack webhook URL must be from hooks.slack.com")
});
+export const pagerDutyIntegrationKeyRegex = new RE2("^[a-f0-9]{32}$", "i");
+
+export const PagerDutyChannelConfigSchema = z.object({
+ integrationKey: z
+ .string()
+ .refine((val) => pagerDutyIntegrationKeyRegex.test(val), "Integration key must be a 32-character hex string")
+});
+
+export type TPagerDutyChannelConfig = z.infer<typeof PagerDutyChannelConfigSchema>;
+
export const ChannelConfigSchema = z.union([
EmailChannelConfigSchema,
WebhookChannelConfigSchema,
- SlackChannelConfigSchema
+ SlackChannelConfigSchema,
+ PagerDutyChannelConfigSchema
]);
export type TEmailChannelConfig = z.infer<typeof EmailChannelConfigSchema>;
@@ -250,7 +262,11 @@ export type TCertificatePreview = {
};
// Channel config type for responses (webhook has hasSigningSecret instead of signingSecret)
-export type TChannelConfigResponse = TEmailChannelConfig | TWebhookChannelConfigResponse | TSlackChannelConfig;
+export type TChannelConfigResponse =
+ | TEmailChannelConfig
+ | TWebhookChannelConfigResponse
+ | TSlackChannelConfig
+ | TPagerDutyChannelConfig;
export type TLastRun = {
timestamp: Date;
@@ -329,3 +345,38 @@ export type TBuildSlackPayloadParams = {
certificates: TCertificatePreview[];
appUrl?: string;
};
+
+export type TPagerDutyPayload = {
+ routing_key: string;
+ event_action: "trigger";
+ dedup_key: string;
+ payload: {
+ summary: string;
+ severity: "critical" | "error" | "warning" | "info";
+ source: string;
+ timestamp: string;
+ component: string;
+ group: string;
+ class: string;
+ custom_details: {
+ alert_name: string;
+ alert_before: string;
+ total_certificates: number;
+ certificates: Array<{
+ common_name: string;
+ serial_number: string;
+ expires_at: string;
+ days_until_expiry: number;
+ }>;
+ view_url: string;
+ };
+ };
+ links: Array<{ href: string; text: string }>;
+};
+
+export type TBuildPagerDutyPayloadParams = {
+ alert: TAlertInfo;
+ certificates: TCertificatePreview[];
+ integrationKey: string;
+ appUrl?: string;
+};
diff --git a/docs/docs.json b/docs/docs.json
index 407ead234f..2ab8b86519 100644
--- a/docs/docs.json
+++ b/docs/docs.json
@@ -732,7 +732,15 @@
"documentation/platform/pki/enrollment-methods/est"
]
},
- "documentation/platform/pki/alerting",
+ {
+ "group": "Alerting",
+ "pages": [
+ "documentation/platform/pki/alerting/overview",
+ "documentation/platform/pki/alerting/webhook-alerts",
+ "documentation/platform/pki/alerting/slack-alerts",
+ "documentation/platform/pki/alerting/pagerduty-alerts"
+ ]
+ },
"documentation/platform/pki/approvals"
]
},
@@ -3273,6 +3281,10 @@
"source": "/documentation/platform/pki/est",
"destination": "/documentation/platform/pki/enrollment-methods/est"
},
+ {
+ "source": "/documentation/platform/pki/alerting",
+ "destination": "/documentation/platform/pki/alerting/overview"
+ },
{
"source": "/api-reference/endpoints/integrations/create-auth",
"destination": "/integrations/secret-syncs"
diff --git a/docs/documentation/platform/pki/alerting/overview.mdx b/docs/documentation/platform/pki/alerting/overview.mdx
new file mode 100644
index 0000000000..120654fad9
--- /dev/null
+++ b/docs/documentation/platform/pki/alerting/overview.mdx
@@ -0,0 +1,40 @@
+---
+title: "Alerting"
+sidebarTitle: "Overview"
+description: "Learn how to set up alerting for expiring certificates with Infisical"
+---
+
+## Concept
+
+In order to ensure that your certificates are always up-to-date and not expired, you can set up alerting in Infisical for expiring CA and leaf certificates based on customizable filters.
+
+## Guide to Creating an Alert
+
+To create an alert, head to your Certificate Management Project > Alerting and press **Create Certificate Alert**.
+
+![pki alerting](/images/platform/pki/alerting/alert-create.png)
+
+![pki alerting modal](/images/platform/pki/alerting/alert-create-modal.png)
+
+### Field Descriptions
+
+Here's some guidance for each field in the alert configuration sequence:
+
+- **Alert Type**: The type of alert to create such as **Certificate Expiration**.
+- **Alert Name**: A slug-friendly name for the alert such as `tls-expiry-alert`.
+- **Description**: An optional description for the alert.
+- **Alert Before**: The time before certificate expiration to trigger the alert such as 30 days denoted by `30d`.
+- **Filters**: A list of filters that determine which certificates the alert applies to. Each row includes a **Field**, **Operator**, and **Value** to match against. For example, you can filter for certificates with a common name containing `example.com` by setting the field to **Common Name**, the operator to **Contains**, and the value to `example.com`.
+
+### Notification Channels
+
+Alerts can be delivered through one or more notification channels:
+
+- **Email**: Send alert notifications to a list of email recipients. Enter one or more email addresses to notify when the alert triggers.
+- **Webhook**: Send alert notifications to a webhook URL. The URL must use HTTPS. Optionally configure a signing secret to verify the authenticity of webhook payloads. See [Webhook Alerts](/documentation/platform/pki/alerting/webhook-alerts) for payload format and signature verification details.
+- **Slack**: Send alert notifications to a Slack channel via an Incoming Webhook. See [Slack Alerts](/documentation/platform/pki/alerting/slack-alerts) for detailed setup steps.
+- **PagerDuty**: Send alert notifications to PagerDuty via the Events API v2. See [PagerDuty Alerts](/documentation/platform/pki/alerting/pagerduty-alerts) for setup instructions.
+
+You can configure up to 10 notification channels per alert.
+
+![pki alerting channels](/images/platform/pki/alerting/alert-create-channels.png)
\ No newline at end of file
diff --git a/docs/documentation/platform/pki/alerting/pagerduty-alerts.mdx b/docs/documentation/platform/pki/alerting/pagerduty-alerts.mdx
new file mode 100644
index 0000000000..67413c4de5
--- /dev/null
+++ b/docs/documentation/platform/pki/alerting/pagerduty-alerts.mdx
@@ -0,0 +1,67 @@
+---
+title: "PagerDuty Alerts"
+sidebarTitle: "PagerDuty Alerts"
+description: "Learn how to set up PagerDuty notifications for PKI certificate alerts"
+---
+
+Infisical can send PKI certificate alert notifications to PagerDuty using the [Events API v2](https://developer.pagerduty.com/docs/events-api-v2-overview). This guide walks through creating a PagerDuty service and configuring a PagerDuty alert.
+
+## Guide to Creating a PagerDuty Alert
+
+<Steps>
+ <Step title="Create a PagerDuty Service (or use an existing one)">
+ 1. Go to **PagerDuty** → **Services** → **Service Directory** → **New Service**
+ 2. Give the service a name (e.g., "Infisical PKI Alerts")
+ 3. Select **Events API v2** as the integration
+
+ ![pagerduty events api v2](/images/platform/pki/alerting/pagerduty-events-api-v2.png)
+
+ 4. Click **Create Service**
+
+ If you want to use an existing service, go to the service's **Integrations** tab → **Add an Integration** → select **Events API v2**.
+ </Step>
+ <Step title="Copy the Integration Key">
+ After creating the service (or adding the integration), copy the 32-character **Integration Key** from the **Integrations** tab. You'll need this key to configure the alert in Infisical.
+
+ ![pagerduty integration key](/images/platform/pki/alerting/pagerduty-integration-key.png)
+ </Step>
+ <Step title="Create the Alert in Infisical">
+ Head to your Certificate Management Project > Alerting and press **Create Certificate Alert**.
+
+ ![pki alerting](/images/platform/pki/alerting/alert-create.png)
+
+ ![pki alerting modal](/images/platform/pki/alerting/alert-create-modal.png)
+
+ Here's some guidance for each field in the alert configuration sequence:
+
+ - **Alert Type**: The type of alert to create such as **Certificate Expiration**.
+ - **Alert Name**: A slug-friendly name for the alert such as `tls-expiry-alert`.
+ - **Description**: An optional description for the alert.
+ - **Alert Before**: The time before certificate expiration to trigger the alert such as 30 days denoted by `30d`.
+ - **Filters**: A list of filters that determine which certificates the alert applies to. Each row includes a **Field**, **Operator**, and **Value** to match against. For example, you can filter for certificates with a common name containing `example.com` by setting the field to **Common Name**, the operator to **Contains**, and the value to `example.com`.
+ </Step>
+ <Step title="Add a PagerDuty Notification Channel">
+ Add a **PagerDuty** notification channel from the "Add Channel" dropdown and paste the integration key you copied from PagerDuty.
+
+ ![pagerduty configure alert](/images/platform/pki/alerting/pagerduty-configure-alert.png)
+ </Step>
+</Steps>
+
+<Note>
+Keep your integration key secure. Anyone with access to it can send events to your PagerDuty service.
+</Note>
+
+## Severity Mapping
+
+Infisical automatically maps the time remaining until certificate expiry to a PagerDuty event severity:
+
+| Time Until Expiry | PagerDuty Severity |
+| --- | --- |
+| ≤ 7 days | `critical` |
+| ≤ 14 days | `error` |
+| ≤ 30 days | `warning` |
+| > 30 days | `info` |
+
+## Incident Grouping
+
+Alerts with the same alert ID are grouped into the same PagerDuty incident via `dedup_key`. This means repeated triggers update the existing incident rather than creating duplicates.
diff --git a/docs/documentation/platform/pki/alerting/slack-alerts.mdx b/docs/documentation/platform/pki/alerting/slack-alerts.mdx
new file mode 100644
index 0000000000..7c357d7348
--- /dev/null
+++ b/docs/documentation/platform/pki/alerting/slack-alerts.mdx
@@ -0,0 +1,55 @@
+---
+title: "Slack Alerts"
+sidebarTitle: "Slack Alerts"
+description: "Learn how to set up Slack notifications for PKI certificate alerts"
+---
+
+Infisical can send PKI certificate alert notifications to a Slack channel using [Incoming Webhooks](https://api.slack.com/messaging/webhooks). This guide walks through creating a Slack app and configuring a Slack alert.
+
+## Guide to Creating a Slack Alert
+
+<Steps>
+ <Step title="Create a Slack App">
+ 1. Go to the [Slack API Apps page](https://api.slack.com/apps) and click **Create New App**
+ 2. Select **From scratch**
+ 3. Give your app a name (e.g., "Infisical PKI Alerts") and select the Slack workspace where you want to receive notifications
+ 4. Click **Create App**
+
+ ![slack create app](/images/platform/pki/alerting/slack-create-app.png)
+ </Step>
+ <Step title="Enable Incoming Webhooks">
+ 1. In your app settings, navigate to **Incoming Webhooks** in the left sidebar under "Features"
+ 2. Toggle **Activate Incoming Webhooks** to **On**
+ 3. Click **Add New Webhook** at the bottom of the page
+ 4. Select the channel where you want to receive alerts and click **Allow**
+ 5. Copy the generated **Webhook URL** (it will look like `https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX`)
+
+ ![slack enable webhooks](/images/platform/pki/alerting/slack-enable-webhooks.png)
+ </Step>
+ <Step title="Create the Alert in Infisical">
+ Head to your Certificate Management Project > Alerting and press **Create Certificate Alert**.
+
+ ![pki alerting](/images/platform/pki/alerting/alert-create.png)
+
+ ![pki alerting modal](/images/platform/pki/alerting/alert-create-modal.png)
+
+ Here's some guidance for each field in the alert configuration sequence:
+
+ - **Alert Type**: The type of alert to create such as **Certificate Expiration**.
+ - **Alert Name**: A slug-friendly name for the alert such as `tls-expiry-alert`.
+ - **Description**: An optional description for the alert.
+ - **Alert Before**: The time before certificate expiration to trigger the alert such as 30 days denoted by `30d`.
+ - **Filters**: A list of filters that determine which certificates the alert applies to. Each row includes a **Field**, **Operator**, and **Value** to match against. For example, you can filter for certificates with a common name containing `example.com` by setting the field to **Common Name**, the operator to **Contains**, and the value to `example.com`.
+ </Step>
+ <Step title="Add a Slack Notification Channel">
+ Add a **Slack** notification channel and paste the webhook URL you copied from Slack.
+
+ ![slack configure alert](/images/platform/pki/alerting/slack-configure-alert.png)
+ </Step>
+</Steps>
+
+<Note>
+Keep your webhook URL secure. Anyone with access to it can post messages to your Slack channel.
+</Note>
+
+Slack messages include alert details and the two most urgent expiring certificates, with a link to view all certificates in Infisical.
diff --git a/docs/documentation/platform/pki/alerting.mdx b/docs/documentation/platform/pki/alerting/webhook-alerts.mdx
similarity index 56%
rename from docs/documentation/platform/pki/alerting.mdx
rename to docs/documentation/platform/pki/alerting/webhook-alerts.mdx
index ba6903d954..aed27e3432 100644
--- a/docs/documentation/platform/pki/alerting.mdx
+++ b/docs/documentation/platform/pki/alerting/webhook-alerts.mdx
@@ -1,13 +1,12 @@
---
-title: "Alerting"
-description: "Learn how to set up alerting for expiring certificates with Infisical"
+title: "Webhook Alerts"
+sidebarTitle: "Webhook Alerts"
+description: "Learn how to set up webhook notifications for PKI certificate alerts"
---
-## Concept
+Infisical can send PKI certificate alert notifications to a webhook URL. This guide walks through creating a webhook alert, the payload format, and how to verify webhook signatures.
-In order to ensure that your certificates are always up-to-date and not expired, you can set up alerting in Infisical for expiring CA and leaf certificates based on customizable filters.
-
-## Guide to Creating an Alert
+## Guide to Creating a Webhook Alert
To create an alert, head to your Certificate Management Project > Alerting and press **Create Certificate Alert**.
@@ -15,8 +14,6 @@ To create an alert, head to your Certificate Management Project > Alerting and p
![pki alerting modal](/images/platform/pki/alerting/alert-create-modal.png)
-### Field Descriptions
-
Here's some guidance for each field in the alert configuration sequence:
- **Alert Type**: The type of alert to create such as **Certificate Expiration**.
@@ -25,22 +22,10 @@ Here's some guidance for each field in the alert configuration sequence:
- **Alert Before**: The time before certificate expiration to trigger the alert such as 30 days denoted by `30d`.
- **Filters**: A list of filters that determine which certificates the alert applies to. Each row includes a **Field**, **Operator**, and **Value** to match against. For example, you can filter for certificates with a common name containing `example.com` by setting the field to **Common Name**, the operator to **Contains**, and the value to `example.com`.
-### Notification Channels
-
-Alerts can be delivered through one or more notification channels:
-
-- **Email**: Send alert notifications to a list of email recipients. Enter one or more email addresses to notify when the alert triggers.
-- **Webhook**: Send alert notifications to a webhook URL. The URL must use HTTPS. Optionally configure a signing secret to verify the authenticity of webhook payloads.
-- **Slack**: Send alert notifications to a Slack channel via an Incoming Webhook. See [detailed setup steps](#slack-notifications).
-
-You can configure up to 10 notification channels per alert.
+Next, add a **Webhook** notification channel. The URL must use HTTPS. Optionally configure a signing secret to verify the authenticity of webhook payloads.
![pki alerting channels](/images/platform/pki/alerting/alert-create-channels.png)
-<Note>
-All configured channels must successfully deliver for an alert to be marked as complete. If any channel fails, the alert will retry until all channels succeed. Make sure all channels are working correctly to avoid repeated notifications.
-</Note>
-
## Webhook Payload Format
Webhook notifications are sent as HTTP POST requests with a [CloudEvents](https://cloudevents.io/)-compliant JSON payload.
@@ -127,39 +112,3 @@ function verifyWebhookSignature(header, body, secret) {
);
}
```
-
-## Slack Notifications
-
-PKI alerts can be sent to Slack channels using [Incoming Webhooks](https://api.slack.com/messaging/webhooks). Follow these steps to set up Slack notifications:
-
-<Steps>
- <Step title="Create a Slack App">
- 1. Go to the [Slack API Apps page](https://api.slack.com/apps) and click **Create New App**
- 2. Select **From scratch**
- 3. Give your app a name (e.g., "Infisical PKI Alerts") and select the Slack workspace where you want to receive notifications
- 4. Click **Create App**
-
- ![slack create app](/images/platform/pki/alerting/slack-create-app.png)
- </Step>
- <Step title="Enable Incoming Webhooks">
- 1. In your app settings, navigate to **Incoming Webhooks** in the left sidebar under "Features"
- 2. Toggle **Activate Incoming Webhooks** to **On**
- 3. Click **Add New Webhook** at the bottom of the page
- 4. Select the channel where you want to receive alerts and click **Allow**
- 5. Copy the generated **Webhook URL** (it will look like `https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX`)
-
- ![slack enable webhooks](/images/platform/pki/alerting/slack-enable-webhooks.png)
- </Step>
- <Step title="Configure the Alert in Infisical">
- 1. When creating or editing a PKI alert, add a **Slack** notification channel
- 2. Paste the webhook URL you copied from Slack
-
- ![slack configure alert](/images/platform/pki/alerting/slack-configure-alert.png)
- </Step>
-</Steps>
-
-<Note>
-Keep your webhook URL secure. Anyone with access to it can post messages to your Slack channel.
-</Note>
-
-Slack messages include alert details and the two most urgent expiring certificates, with a link to view all certificates in Infisical.
diff --git a/docs/documentation/platform/pki/overview.mdx b/docs/documentation/platform/pki/overview.mdx
index 9d208039b5..ab0f56b9c0 100644
--- a/docs/documentation/platform/pki/overview.mdx
+++ b/docs/documentation/platform/pki/overview.mdx
@@ -16,4 +16,4 @@ Core capabilities include:
- Certificate Inventory: Track and monitor issued X.509 certificates, maintaining a comprehensive inventory of all active and expired certificates.
- Certificate Lifecycle Automation: Automate issuance, [renewal](/documentation/platform/pki/certificates/certificates#guide-to-renewing-certificates), and [revocation](/documentation/platform/pki/certificates/certificates#guide-to-revoking-certificates) with policy-based workflows, ensuring certificates remain valid, compliant, and up to date across your infrastructure.
- [Certificate Syncs](/documentation/platform/pki/certificate-syncs/overview): Push certificates to cloud certificate managers like [AWS Certificate Manager](/documentation/platform/pki/certificate-syncs/aws-certificate-manager) and [Azure Key Vault](/documentation/platform/pki/certificate-syncs/azure-key-vault).
-- [Certificate Alerts](/documentation/platform/pki/alerting): Receive alerts and webhook events for certificate lifecycle changes such as certificate expiration.
+- [Certificate Alerts](/documentation/platform/pki/alerting/overview): Receive alerts and webhook events for certificate lifecycle changes such as certificate expiration.
diff --git a/docs/images/platform/pki/alerting/pagerduty-configure-alert.png b/docs/images/platform/pki/alerting/pagerduty-configure-alert.png
new file mode 100644
index 0000000000..7560fb9aa8
Binary files /dev/null and b/docs/images/platform/pki/alerting/pagerduty-configure-alert.png differ
diff --git a/docs/images/platform/pki/alerting/pagerduty-events-api-v2.png b/docs/images/platform/pki/alerting/pagerduty-events-api-v2.png
new file mode 100644
index 0000000000..d62f85aaa9
Binary files /dev/null and b/docs/images/platform/pki/alerting/pagerduty-events-api-v2.png differ
diff --git a/docs/images/platform/pki/alerting/pagerduty-integration-key.png b/docs/images/platform/pki/alerting/pagerduty-integration-key.png
new file mode 100644
index 0000000000..393317fe42
Binary files /dev/null and b/docs/images/platform/pki/alerting/pagerduty-integration-key.png differ
diff --git a/frontend/src/hooks/api/pkiAlertsV2/index.ts b/frontend/src/hooks/api/pkiAlertsV2/index.ts
index 9d598b49fd..227496462c 100644
--- a/frontend/src/hooks/api/pkiAlertsV2/index.ts
+++ b/frontend/src/hooks/api/pkiAlertsV2/index.ts
@@ -20,6 +20,7 @@ export type {
TGetPkiAlertV2CurrentMatchingCertificatesResponse,
TGetPkiAlertV2MatchingCertificates,
TPkiAlertChannelConfigEmail,
+ TPkiAlertChannelConfigPagerDuty,
TPkiAlertChannelConfigSlack,
TPkiAlertChannelConfigWebhook,
TPkiAlertChannelConfigWebhookResponse,
@@ -34,6 +35,6 @@ export {
PkiAlertEventTypeV2,
PkiFilterFieldV2,
PkiFilterOperatorV2,
- SIGNING_SECRET_MASK,
+ SECRET_MASK,
updatePkiAlertV2Schema
} from "./types";
diff --git a/frontend/src/hooks/api/pkiAlertsV2/types.ts b/frontend/src/hooks/api/pkiAlertsV2/types.ts
index 8a40ee4a70..5226b54501 100644
--- a/frontend/src/hooks/api/pkiAlertsV2/types.ts
+++ b/frontend/src/hooks/api/pkiAlertsV2/types.ts
@@ -1,7 +1,7 @@
import { z } from "zod";
-// Sentinel value for masked signing secret display in edit mode
-export const SIGNING_SECRET_MASK = "*****";
+// Sentinel value for masked secrets in edit mode (signing secret, integration key, etc.)
+export const SECRET_MASK = "*****";
export enum PkiAlertEventTypeV2 {
EXPIRATION = "expiration",
@@ -13,7 +13,8 @@ export enum PkiAlertEventTypeV2 {
export enum PkiAlertChannelTypeV2 {
EMAIL = "email",
WEBHOOK = "webhook",
- SLACK = "slack"
+ SLACK = "slack",
+ PAGERDUTY = "pagerduty"
}
export enum PkiFilterFieldV2 {
@@ -56,10 +57,15 @@ export interface TPkiAlertChannelConfigSlack {
webhookUrl: string;
}
+export interface TPkiAlertChannelConfigPagerDuty {
+ integrationKey: string;
+}
+
export type TPkiAlertChannelConfig =
| TPkiAlertChannelConfigEmail
| TPkiAlertChannelConfigWebhook
- | TPkiAlertChannelConfigSlack;
+ | TPkiAlertChannelConfigSlack
+ | TPkiAlertChannelConfigPagerDuty;
export interface TPkiAlertChannelV2 {
id: string;
@@ -245,10 +251,27 @@ const slackChannelSchema = z.object({
enabled: z.boolean().default(true)
});
+const pagerdutyChannelConfigSchema = z.object({
+ integrationKey: z
+ .string()
+ .refine(
+ (val) => /^[a-f0-9]{32}$/i.test(val),
+ "Integration key must be a 32-character hex string"
+ )
+});
+
+const pagerdutyChannelSchema = z.object({
+ id: z.string().uuid().optional(),
+ channelType: z.literal(PkiAlertChannelTypeV2.PAGERDUTY),
+ config: pagerdutyChannelConfigSchema,
+ enabled: z.boolean().default(true)
+});
+
export const pkiAlertChannelV2Schema = z.discriminatedUnion("channelType", [
emailChannelSchema,
webhookChannelSchema,
- slackChannelSchema
+ slackChannelSchema,
+ pagerdutyChannelSchema
]);
export const createPkiAlertV2Schema = z.object({
diff --git a/frontend/src/views/PkiAlertsV2Page/components/CreatePkiAlertV2FormSteps.tsx b/frontend/src/views/PkiAlertsV2Page/components/CreatePkiAlertV2FormSteps.tsx
index 38f215e9e8..668fb470a1 100644
--- a/frontend/src/views/PkiAlertsV2Page/components/CreatePkiAlertV2FormSteps.tsx
+++ b/frontend/src/views/PkiAlertsV2Page/components/CreatePkiAlertV2FormSteps.tsx
@@ -3,6 +3,7 @@ import { useEffect, useRef, useState } from "react";
import { Controller, useFieldArray, useFormContext } from "react-hook-form";
import { faSlack } from "@fortawesome/free-brands-svg-icons";
import {
+ faBell,
faCheck,
faChevronDown,
faEnvelope,
@@ -58,6 +59,7 @@ import {
PkiFilterOperatorV2,
TCreatePkiAlertV2,
TPkiAlertChannelConfigEmail,
+ TPkiAlertChannelConfigPagerDuty,
TPkiAlertChannelConfigSlack,
TPkiAlertChannelConfigWebhook,
TPkiFilterRuleV2,
@@ -68,6 +70,7 @@ import {
import {
formatAlertBefore,
formatEventType,
+ getChannelDisplayName,
getChannelIcon,
getChannelSummary
} from "../utils/pki-alert-formatters";
@@ -97,6 +100,7 @@ export const CreatePkiAlertV2FormSteps = ({
watch,
setValue,
trigger,
+ clearErrors,
formState: { errors }
} = useFormContext<TCreatePkiAlertV2>();
const { currentProject } = useProject();
@@ -175,7 +179,8 @@ export const CreatePkiAlertV2FormSteps = ({
let config:
| TPkiAlertChannelConfigEmail
| TPkiAlertChannelConfigWebhook
- | TPkiAlertChannelConfigSlack;
+ | TPkiAlertChannelConfigSlack
+ | TPkiAlertChannelConfigPagerDuty;
switch (type) {
case PkiAlertChannelTypeV2.EMAIL:
config = { recipients: [] };
@@ -186,6 +191,9 @@ export const CreatePkiAlertV2FormSteps = ({
case PkiAlertChannelTypeV2.SLACK:
config = { webhookUrl: "" };
break;
+ case PkiAlertChannelTypeV2.PAGERDUTY:
+ config = { integrationKey: "" };
+ break;
default:
config = { recipients: [] };
}
@@ -195,7 +203,7 @@ export const CreatePkiAlertV2FormSteps = ({
config,
enabled: true
});
- trigger("channels");
+ clearErrors("channels");
};
// Auto-expand newly added channel (prepended at index 0)
@@ -673,6 +681,10 @@ export const CreatePkiAlertV2FormSteps = ({
<FontAwesomeIcon icon={faSlack} className="mr-2" />
Slack
</DropdownMenuItem>
+ <DropdownMenuItem onClick={() => addChannel(PkiAlertChannelTypeV2.PAGERDUTY)}>
+ <FontAwesomeIcon icon={faBell} className="mr-2" />
+ PagerDuty
+ </DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
@@ -697,8 +709,8 @@ export const CreatePkiAlertV2FormSteps = ({
icon={getChannelIcon(channel?.channelType)}
className="shrink-0 text-mineshaft-300"
/>
- <span className="shrink-0 text-sm font-medium capitalize">
- {channel?.channelType}
+ <span className="shrink-0 text-sm font-medium">
+ {channel?.channelType && getChannelDisplayName(channel.channelType)}
</span>
<span className="truncate text-xs text-mineshaft-400 group-data-[state=open]:hidden">
{channel && getChannelSummary(channel)}
@@ -872,6 +884,29 @@ export const CreatePkiAlertV2FormSteps = ({
)}
/>
)}
+
+ {channel?.channelType === PkiAlertChannelTypeV2.PAGERDUTY && (
+ <Controller
+ control={control}
+ name={`channels.${index}.config.integrationKey`}
+ render={({ field: keyField, fieldState: { error } }) => (
+ <FormControl
+ label="Integration Key"
+ isRequired
+ isError={Boolean(error)}
+ errorText={error?.message}
+ helperText="Find this in PagerDuty under Services → Integrations → Events API v2"
+ >
+ <Input
+ value={keyField.value || ""}
+ onChange={keyField.onChange}
+ onBlur={keyField.onBlur}
+ placeholder="32-character hex integration key"
+ />
+ </FormControl>
+ )}
+ />
+ )}
</AccordionContent>
</AccordionItem>
);
@@ -976,8 +1011,8 @@ export const CreatePkiAlertV2FormSteps = ({
/>
<div className="flex min-w-0 flex-1 flex-col">
<div className="flex items-center gap-2">
- <span className="text-sm font-medium text-mineshaft-100 capitalize">
- {channel.channelType}
+ <span className="text-sm font-medium text-mineshaft-100">
+ {getChannelDisplayName(channel.channelType)}
</span>
{channel.channelType === PkiAlertChannelTypeV2.WEBHOOK &&
((channel.config as TPkiAlertChannelConfigWebhook).signingSecret ? (
@@ -1035,6 +1070,9 @@ export const CreatePkiAlertV2FormSteps = ({
? "Slack webhook configured"
: "Not configured";
}
+ if (channel.channelType === PkiAlertChannelTypeV2.PAGERDUTY) {
+ return "PagerDuty integration configured";
+ }
return "";
})()}
</span>
diff --git a/frontend/src/views/PkiAlertsV2Page/components/CreatePkiAlertV2Modal.tsx b/frontend/src/views/PkiAlertsV2Page/components/CreatePkiAlertV2Modal.tsx
index 959ed27d93..4151a0d804 100644
--- a/frontend/src/views/PkiAlertsV2Page/components/CreatePkiAlertV2Modal.tsx
+++ b/frontend/src/views/PkiAlertsV2Page/components/CreatePkiAlertV2Modal.tsx
@@ -11,7 +11,7 @@ import {
createPkiAlertV2Schema,
PkiAlertChannelTypeV2,
PkiAlertEventTypeV2,
- SIGNING_SECRET_MASK,
+ SECRET_MASK,
TCreatePkiAlertV2,
TPkiAlertChannelConfigEmail,
TPkiAlertChannelConfigWebhook,
@@ -122,7 +122,7 @@ export const CreatePkiAlertV2Modal = ({ isOpen, onOpenChange, alertToEdit, alert
config: {
url: webhookConfig.url,
// Show mask if secret exists, otherwise undefined
- signingSecret: webhookConfig.hasSigningSecret ? SIGNING_SECRET_MASK : undefined
+ signingSecret: webhookConfig.hasSigningSecret ? SECRET_MASK : undefined
}
};
}
@@ -163,7 +163,7 @@ export const CreatePkiAlertV2Modal = ({ isOpen, onOpenChange, alertToEdit, alert
// Determine what to send for signingSecret
let signingSecret: string | null | undefined;
- if (webhookConfig.signingSecret === SIGNING_SECRET_MASK) {
+ if (webhookConfig.signingSecret === SECRET_MASK) {
// User didn't change it - send undefined to preserve existing
signingSecret = undefined;
} else if (!webhookConfig.signingSecret) {
diff --git a/frontend/src/views/PkiAlertsV2Page/components/ViewPkiAlertV2Modal.tsx b/frontend/src/views/PkiAlertsV2Page/components/ViewPkiAlertV2Modal.tsx
index 2d5aad41ac..65b87155e4 100644
--- a/frontend/src/views/PkiAlertsV2Page/components/ViewPkiAlertV2Modal.tsx
+++ b/frontend/src/views/PkiAlertsV2Page/components/ViewPkiAlertV2Modal.tsx
@@ -33,6 +33,7 @@ import {
import {
formatAlertBefore,
formatEventType,
+ getChannelDisplayName,
getChannelIcon,
getWebhookHostname
} from "../utils/pki-alert-formatters";
@@ -202,8 +203,8 @@ export const ViewPkiAlertV2Modal = ({ isOpen, onOpenChange, alertId }: Props) =>
/>
<div className="min-w-0 flex-1">
<div className="flex items-center gap-2">
- <span className="font-medium text-mineshaft-100 capitalize">
- {channel.channelType}
+ <span className="font-medium text-mineshaft-100">
+ {getChannelDisplayName(channel.channelType)}
</span>
{channel.channelType === PkiAlertChannelTypeV2.WEBHOOK &&
(channel.config as TPkiAlertChannelConfigWebhookResponse)
@@ -257,6 +258,11 @@ export const ViewPkiAlertV2Modal = ({ isOpen, onOpenChange, alertId }: Props) =>
Slack webhook configured
</div>
)}
+ {channel.channelType === PkiAlertChannelTypeV2.PAGERDUTY && (
+ <div className="mt-1 truncate text-sm text-mineshaft-400">
+ PagerDuty integration configured
+ </div>
+ )}
</div>
</div>
))}
diff --git a/frontend/src/views/PkiAlertsV2Page/utils/pki-alert-formatters.ts b/frontend/src/views/PkiAlertsV2Page/utils/pki-alert-formatters.ts
index e97bb65105..62b0ecd31f 100644
--- a/frontend/src/views/PkiAlertsV2Page/utils/pki-alert-formatters.ts
+++ b/frontend/src/views/PkiAlertsV2Page/utils/pki-alert-formatters.ts
@@ -1,11 +1,12 @@
import { IconDefinition } from "@fortawesome/fontawesome-svg-core";
import { faSlack } from "@fortawesome/free-brands-svg-icons";
-import { faEnvelope, faLink } from "@fortawesome/free-solid-svg-icons";
+import { faBell, faEnvelope, faLink } from "@fortawesome/free-solid-svg-icons";
import {
PkiAlertChannelTypeV2,
PkiAlertEventTypeV2,
TPkiAlertChannelConfigEmail,
+ TPkiAlertChannelConfigPagerDuty,
TPkiAlertChannelConfigSlack,
TPkiAlertChannelConfigWebhook
} from "@app/hooks/api/pkiAlertsV2";
@@ -60,6 +61,8 @@ export const getChannelIcon = (type: PkiAlertChannelTypeV2): IconDefinition => {
return faLink;
case PkiAlertChannelTypeV2.SLACK:
return faSlack;
+ case PkiAlertChannelTypeV2.PAGERDUTY:
+ return faBell;
default:
return faEnvelope;
}
@@ -89,7 +92,11 @@ export const getWebhookHostname = (url: string): string => {
*/
export const getChannelSummary = (channel: {
channelType: PkiAlertChannelTypeV2;
- config: TPkiAlertChannelConfigEmail | TPkiAlertChannelConfigWebhook | TPkiAlertChannelConfigSlack;
+ config:
+ | TPkiAlertChannelConfigEmail
+ | TPkiAlertChannelConfigWebhook
+ | TPkiAlertChannelConfigSlack
+ | TPkiAlertChannelConfigPagerDuty;
}): string => {
if (channel.channelType === PkiAlertChannelTypeV2.EMAIL) {
const config = channel.config as TPkiAlertChannelConfigEmail;
@@ -106,5 +113,27 @@ export const getChannelSummary = (channel: {
const config = channel.config as TPkiAlertChannelConfigSlack;
return config.webhookUrl ? "Slack webhook configured" : "Not configured";
}
+ if (channel.channelType === PkiAlertChannelTypeV2.PAGERDUTY) {
+ return "PagerDuty integration configured";
+ }
return "";
};
+
+/**
+ * Returns the proper display name for a channel type.
+ * Handles special casing like "PagerDuty".
+ */
+export const getChannelDisplayName = (type: PkiAlertChannelTypeV2): string => {
+ switch (type) {
+ case PkiAlertChannelTypeV2.EMAIL:
+ return "Email";
+ case PkiAlertChannelTypeV2.WEBHOOK:
+ return "Webhook";
+ case PkiAlertChannelTypeV2.SLACK:
+ return "Slack";
+ case PkiAlertChannelTypeV2.PAGERDUTY:
+ return "PagerDuty";
+ default:
+ return type;
+ }
+};