Use Slack Alert Channels to send notifications to Slack channels when checks fail or recover. The examples below show how to configure Slack alerting for different scenarios.
Copy
import { SlackAlertChannel } from "checkly/constructs"const slackChannel = new SlackAlertChannel("slack-channel-1", { url: new URL( "https://hooks.slack.com/services/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" ), channel: "#ops",})
Slack webhook URL for incoming messages. This is the endpoint where Checkly will send alert notifications.Usage:
Copy
new SlackAlertChannel("slack-channel", { url: new URL( "https://hooks.slack.com/services/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" ), channel: "#alerts",})
Examples:
Copy
const slackChannel = new SlackAlertChannel("direct-slack", { url: new URL( "https://hooks.slack.com/services/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" ), channel: "#monitoring",})
Use cases: Team notifications, webhook integration, secure credential storage, multi-team alerting.
Target Slack channel or user for notifications. Can override the default channel configured in the webhook.Usage:
Copy
new SlackAlertChannel("channel-slack", { url: new URL(process.env.SLACK_WEBHOOK_URL!), channel: "#ops", // Send to #ops channel})
Examples:
Copy
const channelSlack = new SlackAlertChannel("channel-slack", { url: new URL(process.env.SLACK_WEBHOOK_URL!), channel: "#monitoring-alerts", // Public channel})
Use cases: Team-specific alerts, direct notifications, alert categorization, noise management.
Whether to send notifications when checks recover from failure or degraded state.Usage:
Copy
new SlackAlertChannel("recovery-slack", { url: new URL(process.env.SLACK_WEBHOOK_URL!), channel: "#alerts", sendRecovery: true, // Send recovery notifications})
Examples:
Copy
const opsSlack = new SlackAlertChannel("ops-slack", { url: new URL(process.env.SLACK_WEBHOOK_URL!), channel: "#ops", sendRecovery: true, // Get notified when issues are resolved sendFailure: true,})
Use cases: Recovery confirmation, operational awareness, noise reduction.
Whether to send notifications for SSL certificate expiry warnings.Usage:
Copy
new SlackAlertChannel("security-slack", { url: new URL(process.env.SLACK_WEBHOOK_URL!), channel: "#security", sslExpiry: true, sslExpiryThreshold: 30, // Alert 30 days before expiry})
Examples:
Copy
const securitySlack = new SlackAlertChannel("security-slack", { url: new URL(process.env.SLACK_WEBHOOK_URL!), channel: "#security", sendRecovery: false, sendFailure: true, sslExpiry: true, sslExpiryThreshold: 7, // Alert 7 days before expiry})new ApiCheck("ssl-cert-check", { name: "SSL Certificate Check", alertChannels: [securitySlack], request: { method: "GET", url: "https://secure.example.com", },})
Use cases: Certificate management, security compliance, proactive maintenance.
Number of days before SSL certificate expiry to send notifications. Only relevant when sslExpiry is enabled.Usage:
Copy
new SlackAlertChannel('ssl-monitoring', { url: new URL(process.env.SLACK_WEBHOOK_URL!), channel: '#devops', sslExpiry: true, sslExpiryThreshold: 30 // Alert 30 days before expiry})
Examples:
Copy
// Alert close to expiry for urgent actionnew SlackAlertChannel("ssl-urgent", { url: new URL(process.env.SLACK_WEBHOOK_URL!), channel: "#security", sslExpiry: true, sslExpiryThreshold: 7, // 7 days notice})
Use cases: Certificate renewal planning, compliance management, operational scheduling.
Webhook Security: Keep your Slack webhook URLs secure. Anyone with access to the URL can send messages to your Slack channels.
Channel Override: The channel parameter can override the default channel configured in your Slack webhook. Use #channel-name for channels or @username for direct messages.