Skip to main content

Slack

Notification

Synopsis

Sends alert notifications to Slack channels using incoming webhooks, supporting message attachments with customizable colors, additional fields, and branding options.

Schema

- slack:
webhook_url: <string>
title: <string>
message: <string>
username: <string>
icon_url: <string>
icon_emoji: <string>
channel: <string>
color: <string>
fields: <field[]>
description: <text>
if: <script>
ignore_failure: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>

Configuration

FieldRequiredDefaultDescription
webhook_urlN${SLACK_WEBHOOK_URL}Slack incoming webhook URL
titleY-Message title displayed prominently
messageY-Main message body text
usernameNVirtualMetricBot username displayed in Slack
icon_urlNVirtualMetric iconURL to image used as bot avatar
icon_emojiN-Emoji to use as bot avatar (overrides icon_url)
channelN-Channel to post to (overrides webhook default)
colorN#47BEFFAttachment color: good, warning, danger, info, or hex code
fieldsN-Array of field objects with title, value, and short fields
descriptionN-Explanatory note
ifN-Condition to run
ignore_failureNfalseSee Handling Failures
on_failureN-See Handling Failures
on_successN-See Handling Success
tagN-Identifier

Details

The slack processor sends notifications to Slack channels using incoming webhooks.

Webhook Setup: Create an incoming webhook in Slack:

  1. Go to your Slack workspace's App Directory
  2. Search for "Incoming Webhooks" and add it
  3. Choose a channel and create the webhook
  4. Copy the webhook URL

Colors: Visual severity indicators for the message attachment sidebar:

  • good / green / success: Green (#26A65B)
  • warning / yellow: Orange (#FFB655)
  • danger / red / error / critical: Red (#FB4946)
  • info / blue: Blue (#47BEFF) - default
  • Custom hex codes (e.g., #FF5733) for brand colors

Fields: Structured data displayed in the attachment:

fields:
- title: "Server"
value: "{{ .hostname }}"
short: true
- title: "CPU"
value: "{{ .cpu_usage }}%"
short: true

Set short: true to display fields side-by-side.

Channel Override: The channel field overrides the webhook's default channel. Use #channel-name for public channels or @username for direct messages.

Template Support: All string fields support Go template syntax with event field interpolation using {{ .field_name }}.

For integration patterns with schema validation, see Schema Drift Detection.

Examples

Basic Alert

Sending a simple alert notification...

{
"alert_name": "High CPU Usage",
"server": "prod-server-01",
"cpu_usage": "95%"
}
- slack:
webhook_url: "${SLACK_WEBHOOK_URL}"
title: "Alert: {{ .alert_name }}"
message: "CPU usage is at {{ .cpu_usage }} on server {{ .server }}"
color: "danger"

Red-colored alert posted to Slack...

With Fields

Including structured data as fields...

{
"alert_name": "Schema Drift Detected",
"schema": "ASimNetworkSessionLogs",
"missing": "3 required fields"
}
- slack:
webhook_url: "${SLACK_WEBHOOK_URL}"
title: "{{ .alert_name }}"
message: "Schema validation failed"
color: "warning"
fields:
- title: "Schema"
value: "{{ .schema }}"
short: true
- title: "Missing Fields"
value: "{{ .missing }}"
short: true

Fields displayed side-by-side in attachment...

Custom Username and Channel

Overriding bot identity and target channel...

{
"bot_name": "AlertBot",
"channel": "#alerts"
}
- slack:
webhook_url: "${SLACK_WEBHOOK_URL}"
username: "{{ .bot_name }}"
channel: "{{ .channel }}"
title: "System Alert"
message: "This is a test alert"
color: "info"

Message posted as AlertBot to #alerts channel...

Color Options

Using different severity colors...

# Success - green sidebar
- slack:
webhook_url: "${SLACK_WEBHOOK_URL}"
title: "Deployment Complete"
message: "Version 2.0 deployed successfully"
color: "good"
# Warning - orange sidebar
- slack:
webhook_url: "${SLACK_WEBHOOK_URL}"
title: "High Memory Usage"
message: "Memory usage at 85%"
color: "warning"
# Danger - red sidebar
- slack:
webhook_url: "${SLACK_WEBHOOK_URL}"
title: "Service Down"
message: "API service not responding"
color: "danger"

Colors indicate severity at a glance...

Schema Drift Alert

Alerting on schema validation failures...

processors:
- check_schema:
schema: "ASimNetworkSessionLogs"
target_field: "schema_check"
on_missing:
- slack:
webhook_url: "${SLACK_WEBHOOK_URL}"
title: "Schema Validation Failed: ASimNetworkSessionLogs"
message: "Schema validation detected missing required fields"
color: "danger"
fields:
- title: "Schema"
value: "ASimNetworkSessionLogs"
short: true
- title: "Valid"
value: "{{ .schema_check.is_valid }}"
short: true

Alert triggered automatically when schema drift detected...