Skip to main content

Overview

The AlertChannel is a cluster-scoped Custom Resource that defines alert notification destinations. It supports Slack, PagerDuty, generic webhooks, and email. API Group: guardian.illenium.net/v1alpha1 Kind: AlertChannel Scope: Cluster (not namespaced)

Basic Examples

Slack Channel

apiVersion: guardian.illenium.net/v1alpha1
kind: AlertChannel
metadata:
  name: slack-alerts
spec:
  type: slack
  slack:
    webhookSecretRef:
      name: slack-webhook
      namespace: cronjob-guardian
      key: url
    defaultChannel: "#alerts"
  rateLimiting:
    maxAlertsPerHour: 100
    burstLimit: 10

PagerDuty Channel

apiVersion: guardian.illenium.net/v1alpha1
kind: AlertChannel
metadata:
  name: pagerduty-critical
spec:
  type: pagerduty
  pagerduty:
    routingKeySecretRef:
      name: pagerduty-key
      namespace: cronjob-guardian
      key: routing-key
    severity: critical

Spec Fields

type

type
string
required
Type of alert channel.Validation: Enum slack, pagerduty, webhook, email

slack

slack
object
Slack configuration. Required when type is slack.

pagerduty

pagerduty
object
PagerDuty configuration. Required when type is pagerduty.

webhook

webhook
object
Generic webhook configuration. Required when type is webhook.

email

email
object
Email configuration. Required when type is email.

rateLimiting

rateLimiting
object
Prevents alert storms by rate limiting notifications.
rateLimiting:
  maxAlertsPerHour: 50
  burstLimit: 5

testOnSave

testOnSave
boolean
default:"false"
Sends a test alert when the AlertChannel is created or updated. Useful for validating configuration.The test result will be reflected in the status.lastTestResult field.

Status Fields

The status subresource provides operational metrics and health information.
ready
boolean
Indicates whether the channel is operational and can send alerts.
lastTestTime
timestamp
When the channel was last tested (via testOnSave or manual testing).
lastTestResult
string
Result of the last test.Values: success, failed
lastTestError
string
Error message from the last failed test.
alertsSentTotal
integer
Cumulative count of alerts successfully sent via this channel.
lastAlertTime
timestamp
When the last alert was successfully sent.
alertsFailedTotal
integer
Cumulative count of alerts that failed to send via this channel.
lastFailedTime
timestamp
When the last alert send failure occurred.
lastFailedError
string
Error message from the last failed send attempt.
consecutiveFailures
integer
Number of consecutive failed send attempts. Resets to 0 on successful send.High values may indicate channel configuration issues or external service outages.
conditions
array
Standard Kubernetes condition array. Common condition types:
  • Ready: Channel is operational and can send alerts
  • ConfigValid: Channel configuration is valid
  • SecretFound: Referenced secrets exist and are readable

Complete Examples

Slack with Custom Template

apiVersion: guardian.illenium.net/v1alpha1
kind: AlertChannel
metadata:
  name: slack-custom
spec:
  type: slack
  slack:
    webhookSecretRef:
      name: slack-webhook
      namespace: cronjob-guardian
      key: url
    defaultChannel: "#cronjob-alerts"
    messageTemplate: |
      :{\{if eq .Severity "critical"}\}rotating_light{\{else}\}warning{\{end}\}: *{\{.Type}\}*
      
      *CronJob:* `{\{.Namespace}\}/{\{.CronJobName}\}`
      *Severity:* {\{.Severity | upper}\}
      *Message:* {\{.Message}\}
      {\{if .Context.SuggestedFix}\}
      
      *Suggested Fix:* {\{.Context.SuggestedFix}\}{\{end}\}
  rateLimiting:
    maxAlertsPerHour: 200
    burstLimit: 20
  testOnSave: true

Webhook with Authentication

apiVersion: guardian.illenium.net/v1alpha1
kind: AlertChannel
metadata:
  name: webhook-authenticated
spec:
  type: webhook
  webhook:
    urlSecretRef:
      name: webhook-config
      namespace: cronjob-guardian
      key: url
    method: POST
    headers:
      Content-Type: application/json
      Authorization: Bearer ${WEBHOOK_TOKEN}
      X-Source: cronjob-guardian
    payloadTemplate: |
      {
        "event_type": "cronjob_alert",
        "severity": "{\{.Severity}\}",
        "alert": {
          "type": "{\{.Type}\}",
          "message": "{\{.Message}\}",
          "cronjob": {
            "name": "{\{.CronJobName}\}",
            "namespace": "{\{.Namespace}\}"
          },
          "timestamp": "{\{.Timestamp}\}"
        }
      }
  rateLimiting:
    maxAlertsPerHour: 100
    burstLimit: 10

Email with HTML Template

apiVersion: guardian.illenium.net/v1alpha1
kind: AlertChannel
metadata:
  name: email-html
spec:
  type: email
  email:
    smtpSecretRef:
      name: smtp-credentials
      namespace: cronjob-guardian
    from: [email protected]
    to:
      - [email protected]
      - [email protected]
    subjectTemplate: "[{\{.Severity | upper}\}] {\{.Type}\} - {\{.Namespace}\}/{\{.CronJobName}\}"
    bodyTemplate: |
      <html>
      <body>
        <h2 style="color: {\{if eq .Severity "critical"}\}red{\{else}\}orange{\{end}\};">
          {\{.Type}\}
        </h2>
        <p><strong>CronJob:</strong> {\{.Namespace}\}/{\{.CronJobName}\}</p>
        <p><strong>Severity:</strong> {\{.Severity | upper}\}</p>
        <p><strong>Message:</strong> {\{.Message}\}</p>
        <p><strong>Time:</strong> {\{.Timestamp}\}</p>
        {\{if .Context.SuggestedFix}\}
        <hr>
        <h3>Suggested Fix</h3>
        <p>{\{.Context.SuggestedFix}\}</p>
        {\{end}\}
      </body>
      </html>
  rateLimiting:
    maxAlertsPerHour: 50
    burstLimit: 5
  testOnSave: true

Referencing AlertChannels

AlertChannels are referenced in CronJobMonitor resources:
apiVersion: guardian.illenium.net/v1alpha1
kind: CronJobMonitor
metadata:
  name: production-jobs
  namespace: production
spec:
  alerting:
    enabled: true
    channelRefs:
      - name: pagerduty-critical
        severities: [critical]
      - name: slack-alerts
        severities: [critical, warning]
      - name: email-team

Build docs developers (and LLMs) love