Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(logs): add Microsoft Teams as a log alert notification destination (#62144)

Christiaan Hendriksene699429f2903
diff --git a/posthog/settings/web.py b/posthog/settings/web.py
index 56f1760074ad..46e14dfc6f52 100644
--- a/posthog/settings/web.py
+++ b/posthog/settings/web.py
@@ -533,7 +533,7 @@ SPECTACULAR_SETTINGS = {
"HogFunctionTemplatingEnum": ["hog", "liquid"],
"HogFlowEdgeTypeEnum": ["continue", "branch"],
"SourceMatchEnum": ["none", "auto", "mapped"],
- "NotificationDestinationTypeEnum": ["slack", "webhook"],
+ "NotificationDestinationTypeEnum": ["slack", "webhook", "teams"],
"TaskRunArtifactTypeEnum": [
"plan",
"context",
diff --git a/products/logs/backend/alert_destinations.py b/products/logs/backend/alert_destinations.py
index d12af0958f1a..09923e26f0f6 100644
--- a/products/logs/backend/alert_destinations.py
+++ b/products/logs/backend/alert_destinations.py
@@ -15,7 +15,8 @@ class EventKindSpec:
event_id: str
display_kind: str
header: str
- body: str
+ # Plain-text (label, value) pairs; each destination renders these in its own markup.
+ details: tuple[tuple[str, str], ...]
button_url: str
button_label: str
webhook_body: dict[str, Any]
@@ -52,10 +53,12 @@ EVENT_KIND_CONFIG: dict[EventKind, EventKindSpec] = {
event_id="$logs_alert_firing",
display_kind="firing",
header="🔴 Log alert '{event.properties.alert_name}' is firing",
- body=(
- "*Threshold breached:* {event.properties.result_count} logs in "
- "{event.properties.window_minutes}m "
- "(threshold: {event.properties.threshold_operator} {event.properties.threshold_count})"
+ details=(
+ (
+ "Threshold breached",
+ "{event.properties.result_count} logs in {event.properties.window_minutes}m "
+ "(threshold: {event.properties.threshold_operator} {event.properties.threshold_count})",
+ ),
),
button_url="{project.url}/logs?{event.properties.logs_url_params}",
button_label="View logs",
@@ -70,10 +73,12 @@ EVENT_KIND_CONFIG: dict[EventKind, EventKindSpec] = {
event_id="$logs_alert_resolved",
display_kind="resolved",
header="🟢 Log alert '{event.properties.alert_name}' has resolved",
- body=(
- "*Current count:* {event.properties.result_count} logs in "
- "{event.properties.window_minutes}m "
- "(threshold: {event.properties.threshold_operator} {event.properties.threshold_count})"
+ details=(
+ (
+ "Current count",
+ "{event.properties.result_count} logs in {event.properties.window_minutes}m "
+ "(threshold: {event.properties.threshold_operator} {event.properties.threshold_count})",
+ ),
),
button_url="{project.url}/logs?{event.properties.logs_url_params}",
button_label="View logs",
@@ -88,9 +93,9 @@ EVENT_KIND_CONFIG: dict[EventKind, EventKindSpec] = {
event_id="$logs_alert_auto_disabled",
display_kind="auto-disabled",
header="⚠️ Log alert '{event.properties.alert_name}' was auto-disabled",
- body=(
- "*Reason:* {event.properties.consecutive_failures} consecutive check failures.\n"
- "*Last error:* {event.properties.last_error_message}"
+ details=(
+ ("Reason", "{event.properties.consecutive_failures} consecutive check failures."),
+ ("Last error", "{event.properties.last_error_message}"),
),
button_url="{project.url}/logs/alerts/{event.properties.alert_id}",
button_label="View alert",
@@ -108,7 +113,10 @@ EVENT_KIND_CONFIG: dict[EventKind, EventKindSpec] = {
event_id="$logs_alert_errored",
display_kind="errored",
header="🟡 Log alert '{event.properties.alert_name}' couldn't evaluate",
- body=("*Reason:* {event.properties.error_message}\n*Failure count:* {event.properties.consecutive_failures}"),
+ details=(
+ ("Reason", "{event.properties.error_message}"),
+ ("Failure count", "{event.properties.consecutive_failures}"),
+ ),
button_url="{project.url}/logs/alerts/{event.properties.alert_id}",
button_label="View alert",
webhook_body={
@@ -151,10 +159,15 @@ _SEVERITY_SERVICE_CONTEXT = (
)
+def _slack_body(spec: EventKindSpec) -> str:
+ # Slack mrkdwn: *single asterisks* for bold, one line per detail.
+ return "\n".join(f"*{label}:* {value}" for label, value in spec.details)
+
+
def _slack_blocks(spec: EventKindSpec) -> list[dict]:
return [
{"type": "header", "text": {"type": "plain_text", "text": spec.header}},
- {"type": "section", "text": {"type": "mrkdwn", "text": spec.body}},
+ {"type": "section", "text": {"type": "mrkdwn", "text": _slack_body(spec)}},
{
"type": "context",
"elements": [
@@ -176,6 +189,14 @@ def _slack_blocks(spec: EventKindSpec) -> list[dict]:
]
+def _teams_text(spec: EventKindSpec) -> str:
+ # The Microsoft Teams template renders a single Adaptive Card TextBlock from `text`, so fold
+ # the header, details, and action into one markdown string (the button becomes an inline link).
+ # Adaptive Card markdown: **double asterisks** for bold, blank lines between paragraphs.
+ details = "\n\n".join(f"**{label}:** {value}" for label, value in spec.details)
+ return f"**{spec.header}**\n\n{details}\n\n[{spec.button_label}]({spec.button_url})"
+
+
def _filter_for(alert: LogsAlertConfiguration, kind: EventKind) -> dict[str, Any]:
return {
"events": [{"id": EVENT_KIND_CONFIG[kind].event_id, "type": "events"}],
@@ -236,3 +257,24 @@ def build_webhook_config(
"headers": {"value": {"Content-Type": "application/json", "X-PostHog-Webhook-Version": "1"}},
},
}
+
+
+def build_teams_config(
+ alert: LogsAlertConfiguration,
+ kind: EventKind,
+ webhook_url: str,
+) -> dict[str, Any]:
+ spec = EVENT_KIND_CONFIG[kind]
+ return {
+ "team": alert.team,
+ "type": "internal_destination",
+ "enabled": True,
+ "filters": _filter_for(alert, kind),
+ "name": _clip_name(f"Logs alert — {alert.name} ({spec.display_kind}) → Microsoft Teams"),
+ "description": spec.destination_description(alert.name),
+ "template_id": "template-microsoft-teams",
+ "inputs": {
+ "webhookUrl": {"value": webhook_url},
+ "text": {"value": _teams_text(spec)},
+ },
+ }
diff --git a/products/logs/backend/alerts_api.py b/products/logs/backend/alerts_api.py
index e9be222dc1ef..2c0e433ac5be 100644
--- a/products/logs/backend/alerts_api.py
+++ b/products/logs/backend/alerts_api.py
@@ -31,7 +31,13 @@ from posthog.utils import relative_date_parse
from products.cdp.backend.api.hog_function import HogFunctionSerializer
from products.cdp.backend.models.hog_functions.hog_function import HogFunction
from products.logs.backend.alert_check_query import AlertCheckQuery, BucketedCount
-from products.logs.backend.alert_destinations import EVENT_KINDS, EventKind, build_slack_config, build_webhook_config
+from products.logs.backend.alert_destinations import (
+ EVENT_KINDS,
+ EventKind,
+ build_slack_config,
+ build_teams_config,
+ build_webhook_config,
+)
from products.logs.backend.alert_state_machine import (
AlertCheckOutcome,
AlertSnapshot,
@@ -78,6 +84,7 @@ def _any_field_changed(instance: LogsAlertConfiguration, validated_data: dict, f
class DestinationType(models.TextChoices):
SLACK = "slack"
WEBHOOK = "webhook"
+ TEAMS = "teams"
class LogsAlertStateIntervalSerializer(serializers.Serializer):
@@ -349,13 +356,13 @@ class LogsAlertConfigurationSerializer(serializers.ModelSerializer):
HogFunction.objects.filter(
team_id=team_id,
deleted=False,
- template_id__in=["template-slack", "template-webhook"],
+ template_id__in=["template-slack", "template-webhook", "template-microsoft-teams"],
filters__properties__contains=[{"key": "alert_id", "value": str(obj.id)}],
)
.values_list("template_id", flat=True)
.distinct()
)
- type_map = {"template-slack": "slack", "template-webhook": "webhook"}
+ type_map = {"template-slack": "slack", "template-webhook": "webhook", "template-microsoft-teams": "teams"}
return sorted(type_map[tid] for tid in template_ids if tid in type_map)
@extend_schema_field(serializers.CharField(allow_null=True))
@@ -657,7 +664,9 @@ class LogsAlertSimulateResponseSerializer(serializers.Serializer):
class LogsAlertCreateDestinationSerializer(serializers.Serializer):
- type = serializers.ChoiceField(choices=list(DestinationType), help_text="Destination type — slack or webhook.")
+ type = serializers.ChoiceField(
+ choices=list(DestinationType), help_text="Destination type — slack, webhook, or teams."
+ )
slack_workspace_id = serializers.IntegerField(
required=False, help_text="Integration ID for the Slack workspace. Required when type=slack."
)
@@ -666,7 +675,8 @@ class LogsAlertCreateDestinationSerializer(serializers.Serializer):
required=False, allow_blank=True, help_text="Human-readable channel name for display."
)
webhook_url = serializers.URLField(
- required=False, help_text="HTTPS endpoint to POST to. Required when type=webhook."
+ required=False,
+ help_text="HTTPS endpoint to POST to. Required when type=webhook, or the Teams webhook URL when type=teams.",
)
def validate(self, attrs: dict) -> dict:
@@ -674,9 +684,9 @@ class LogsAlertCreateDestinationSerializer(serializers.Serializer):
if destination_type == "slack":
if not attrs.get("slack_workspace_id") or not attrs.get("slack_channel_id"):
raise ValidationError("slack_workspace_id and slack_channel_id are required for slack destinations.")
- elif destination_type == "webhook":
+ elif destination_type in ("webhook", "teams"):
if not attrs.get("webhook_url"):
- raise ValidationError("webhook_url is required for webhook destinations.")
+ raise ValidationError(f"webhook_url is required for {destination_type} destinations.")
return attrs
@@ -913,6 +923,8 @@ class LogsAlertViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):
slack_channel_id=data["slack_channel_id"],
slack_channel_name=data.get("slack_channel_name"),
)
+ elif data["type"] == "teams":
+ config = build_teams_config(alert, kind, webhook_url=data["webhook_url"])
else:
config = build_webhook_config(alert, kind, webhook_url=data["webhook_url"])
diff --git a/products/logs/backend/test/test_alert_destinations.py b/products/logs/backend/test/test_alert_destinations.py
new file mode 100644
index 000000000000..af8341d9580e
--- /dev/null
+++ b/products/logs/backend/test/test_alert_destinations.py
@@ -0,0 +1,49 @@
+from django.test import SimpleTestCase
+
+from parameterized import parameterized
+
+from products.logs.backend.alert_destinations import EVENT_KIND_CONFIG, EVENT_KINDS, EventKind, _slack_body, _teams_text
+
+
+class TestSlackBody(SimpleTestCase):
+ @parameterized.expand([(kind,) for kind in EVENT_KINDS])
+ def test_body_is_slack_mrkdwn(self, kind: EventKind) -> None:
+ spec = EVENT_KIND_CONFIG[kind]
+ body = _slack_body(spec)
+ lines = body.split("\n")
+ assert len(lines) == len(spec.details)
+ for line, (label, value) in zip(lines, spec.details):
+ # Slack mrkdwn bold label, then the plain-text value.
+ assert line == f"*{label}:* {value}"
+ # Detail values are plain text — bold markers come only from the renderer.
+ assert "**" not in body
+
+ def test_multi_detail_body_renders_one_line_per_detail(self) -> None:
+ body = _slack_body(EVENT_KIND_CONFIG["broken"])
+ assert body == (
+ "*Reason:* {event.properties.consecutive_failures} consecutive check failures.\n"
+ "*Last error:* {event.properties.last_error_message}"
+ )
+
+
+class TestTeamsText(SimpleTestCase):
+ @parameterized.expand([(kind,) for kind in EVENT_KINDS])
+ def test_text_is_adaptive_card_markdown(self, kind: EventKind) -> None:
+ spec = EVENT_KIND_CONFIG[kind]
+ text = _teams_text(spec)
+ # Bold header, every detail label bolded, the action rendered as an inline markdown link.
+ assert text.startswith(f"**{spec.header}**")
+ for label, value in spec.details:
+ assert f"**{label}:** {value}" in text
+ assert f"[{spec.button_label}]({spec.button_url})" in text
+ # Every asterisk must belong to a `**` pair — no Slack-style single-asterisk bold.
+ assert "*" not in text.replace("**", "")
+
+ def test_multi_detail_text_separates_paragraphs_with_blank_lines(self) -> None:
+ text = _teams_text(EVENT_KIND_CONFIG["broken"])
+ assert (
+ "**Reason:** {event.properties.consecutive_failures} consecutive check failures.\n\n"
+ "**Last error:** {event.properties.last_error_message}"
+ ) in text
+ # Adaptive Card paragraphs need exactly one blank line — never stacked blank lines.
+ assert "\n\n\n" not in text
diff --git a/products/logs/backend/test/test_alerts_api.py b/products/logs/backend/test/test_alerts_api.py
index 1629b9d3f037..97ea2f17d1f4 100644
--- a/products/logs/backend/test/test_alerts_api.py
+++ b/products/logs/backend/test/test_alerts_api.py
@@ -722,13 +722,15 @@ class TestLogsAlertAPI(APIBaseTest):
def _sync_destination_templates(self) -> None:
# Destination creation goes through the full HogFunctionSerializer pipeline,
- # which looks up a HogFunctionTemplate by template_id. Seed Slack + webhook.
+ # which looks up a HogFunctionTemplate by template_id. Seed Slack + Teams + webhook.
from posthog.cdp.templates.hog_function_template import sync_template_to_db
+ from posthog.cdp.templates.microsoft_teams.template_microsoft_teams import template as template_microsoft_teams
from posthog.cdp.templates.slack.template_slack import template as template_slack
from products.cdp.backend.models.hog_function_template import HogFunctionTemplate
sync_template_to_db(template_slack)
+ sync_template_to_db(template_microsoft_teams)
HogFunctionTemplate.objects.get_or_create(
template_id="template-webhook",
defaults={
@@ -818,12 +820,39 @@ class TestLogsAlertAPI(APIBaseTest):
"logs_alert.errored",
)
+ def test_create_teams_destination_creates_one_hog_function_per_event_kind(self):
+ from products.cdp.backend.models.hog_functions.hog_function import HogFunction
+
+ self._sync_destination_templates()
+ created = self._create_via_api()
+ teams_url = "https://prod-00.westus.logic.azure.com:443/workflows/abc/triggers/manual/paths/invoke?api-version=2016-06-01"
+ response = self.client.post(
+ self._destinations_url(created["id"]),
+ {"type": "teams", "webhook_url": teams_url},
+ format="json",
+ )
+ assert response.status_code == status.HTTP_201_CREATED, response.json()
+ ids = response.json()["hog_function_ids"]
+ assert len(ids) == 4 # firing + resolved + broken + errored
+
+ hog_functions = HogFunction.objects.filter(id__in=ids)
+ for hf in hog_functions:
+ assert hf.template_id == "template-microsoft-teams"
+ inputs = hf.inputs or {}
+ assert inputs["webhookUrl"]["value"] == teams_url
+ text_value = inputs["text"]["value"]
+ # Adaptive Card markdown: bold label and an inline action link, not Slack-style single asterisks.
+ assert text_value.startswith("**")
+ assert "[View logs](" in text_value or "[View alert](" in text_value
+
@parameterized.expand(
[
("slack_missing_workspace", {"type": "slack", "slack_channel_id": "C1"}),
("slack_missing_channel", {"type": "slack", "slack_workspace_id": 1}),
("webhook_missing_url", {"type": "webhook"}),
("webhook_invalid_url", {"type": "webhook", "webhook_url": "not-a-url"}),
+ ("teams_missing_url", {"type": "teams"}),
+ ("teams_invalid_url", {"type": "teams", "webhook_url": "not-a-url"}),
]
)
def test_create_destination_rejects_invalid_payloads(self, _name: str, payload: dict) -> None:
diff --git a/products/logs/frontend/components/LogsAlerting/LogsAlertList.tsx b/products/logs/frontend/components/LogsAlerting/LogsAlertList.tsx
index 0e41c0a90538..9d2bc6e394de 100644
--- a/products/logs/frontend/components/LogsAlerting/LogsAlertList.tsx
+++ b/products/logs/frontend/components/LogsAlerting/LogsAlertList.tsx
@@ -17,6 +17,7 @@ import { LemonMenuOverlay } from 'lib/lemon-ui/LemonMenu/LemonMenu'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
import { urls } from 'scenes/urls'
+import IconMicrosoftTeams from 'public/services/microsoft-teams.png'
import IconSlack from 'public/services/slack.png'
import IconWebhook from 'public/services/webhook.svg'
@@ -151,6 +152,12 @@ export function LogsAlertList(): JSX.Element {
Webhook
</LemonTag>
)}
+ {types.includes(NotificationDestinationTypeEnumApi.Teams) && (
+ <LemonTag>
+ <img src={IconMicrosoftTeams} alt="" className="h-3 w-3 object-contain" />
+ Teams
+ </LemonTag>
+ )}
</div>
<LemonButton
size="small"
diff --git a/products/logs/frontend/components/LogsAlerting/LogsAlertNotifications.tsx b/products/logs/frontend/components/LogsAlerting/LogsAlertNotifications.tsx
index 7652b6545d15..9d100996017a 100644
--- a/products/logs/frontend/components/LogsAlerting/LogsAlertNotifications.tsx
+++ b/products/logs/frontend/components/LogsAlerting/LogsAlertNotifications.tsx
@@ -12,6 +12,7 @@ import { LOGS_ALERT_NOTIFICATION_TYPE_OPTIONS, logsAlertNotificationLogic } from
import {
getHogFunctionEventKind,
LOGS_ALERT_NOTIFICATION_TYPE_SLACK,
+ LOGS_ALERT_NOTIFICATION_TYPE_TEAMS,
LOGS_ALERT_NOTIFICATION_TYPE_WEBHOOK,
PendingLogsAlertNotification,
resolveGroupLabel,
@@ -67,7 +68,7 @@ export function LogsAlertNotifications({ alertId }: { alertId?: string }): JSX.E
if (!webhookUrl) {
return
}
- addPendingNotification({ type: LOGS_ALERT_NOTIFICATION_TYPE_WEBHOOK, webhookUrl })
+ addPendingNotification({ type: selectedType, webhookUrl })
setWebhookUrl('')
}
}
@@ -76,6 +77,9 @@ export function LogsAlertNotifications({ alertId }: { alertId?: string }): JSX.E
if (notification.type === LOGS_ALERT_NOTIFICATION_TYPE_SLACK) {
return `Slack: #${notification.slackChannelName ?? 'channel'}`
}
+ if (notification.type === LOGS_ALERT_NOTIFICATION_TYPE_TEAMS) {
+ return `Microsoft Teams: ${notification.webhookUrl}`
+ }
return `Webhook: ${notification.webhookUrl}`
}
@@ -148,7 +152,7 @@ export function LogsAlertNotifications({ alertId }: { alertId?: string }): JSX.E
key={
notification.type === LOGS_ALERT_NOTIFICATION_TYPE_SLACK
? `slack-${notification.slackChannelId}`
- : `webhook-${notification.webhookUrl}`
+ : `${notification.type}-${notification.webhookUrl}`
}
className="flex items-center justify-between border rounded p-2 gap-2"
>
@@ -205,6 +209,21 @@ export function LogsAlertNotifications({ alertId }: { alertId?: string }): JSX.E
/>
)}
+ {selectedType === LOGS_ALERT_NOTIFICATION_TYPE_TEAMS && (
+ <div className="space-y-1">
+ <LemonInput
+ placeholder="https://prod-00.westus.logic.azure.com:443/workflows/..."
+ value={webhookUrl}
+ onChange={setWebhookUrl}
+ fullWidth
+ />
+ <p className="text-xs text-muted-alt m-0">
+ Paste the URL from a Teams "Workflows" (Power Automate) or incoming webhook connector. We
+ send a formatted Adaptive Card to it.
+ </p>
+ </div>
+ )}
+
<LemonButton
type="secondary"
size="small"
diff --git a/products/logs/frontend/components/LogsAlerting/__tests__/logsAlertUtils.test.ts b/products/logs/frontend/components/LogsAlerting/__tests__/logsAlertUtils.test.ts
index 919dd0607173..ebb358401e51 100644
--- a/products/logs/frontend/components/LogsAlerting/__tests__/logsAlertUtils.test.ts
+++ b/products/logs/frontend/components/LogsAlerting/__tests__/logsAlertUtils.test.ts
@@ -63,6 +63,16 @@ describe('logsAlertUtils', () => {
filters: {},
}) as unknown as HogFunctionType
+ // The Microsoft Teams template stores its URL under `webhookUrl`, not `url`.
+ const teamsHf = (id: string, url: string, enabled = true): HogFunctionType =>
+ ({
+ id,
+ name: `teams-${id}`,
+ enabled,
+ inputs: { webhookUrl: { value: url } },
+ filters: {},
+ }) as unknown as HogFunctionType
+
const resolveSlack = (channelValue: string): string | null => `channel-for-${channelValue}`
it('collapses multiple HogFunctions for the same slack channel into one group', () => {
@@ -96,6 +106,22 @@ describe('logsAlertUtils', () => {
expect(groups[0].hogFunctions).toHaveLength(2)
})
+ it('collapses multiple HogFunctions for the same teams url into one group', () => {
+ const teamsUrl = 'https://prod-00.westus.logic.azure.com:443/workflows/abc/triggers/manual/paths/invoke'
+ const a = teamsHf('hf-1', teamsUrl)
+ const b = teamsHf('hf-2', teamsUrl)
+
+ const groups = groupLogsAlertDestinations([a, b], resolveSlack)
+
+ expect(groups).toHaveLength(1)
+ expect(groups[0]).toMatchObject({
+ key: `teams:${teamsUrl}`,
+ type: 'teams',
+ label: `Microsoft Teams ${teamsUrl}`,
+ })
+ expect(groups[0].hogFunctions).toHaveLength(2)
+ })
+
it('keeps distinct slack channels and webhook urls as separate groups', () => {
const groups = groupLogsAlertDestinations(
[
diff --git a/products/logs/frontend/components/LogsAlerting/logsAlertNotificationLogic.ts b/products/logs/frontend/components/LogsAlerting/logsAlertNotificationLogic.ts
index 41baa94a1ef4..d2211028261c 100644
--- a/products/logs/frontend/components/LogsAlerting/logsAlertNotificationLogic.ts
+++ b/products/logs/frontend/components/LogsAlerting/logsAlertNotificationLogic.ts
@@ -15,6 +15,7 @@ import {
buildLogsAlertFilterConfig,
groupLogsAlertDestinations,
LOGS_ALERT_NOTIFICATION_TYPE_SLACK,
+ LOGS_ALERT_NOTIFICATION_TYPE_TEAMS,
LOGS_ALERT_NOTIFICATION_TYPE_WEBHOOK,
LogsAlertDestinationGroup,
LogsAlertNotificationType,
@@ -23,6 +24,7 @@ import {
export const LOGS_ALERT_NOTIFICATION_TYPE_OPTIONS = [
{ label: 'Slack', value: LOGS_ALERT_NOTIFICATION_TYPE_SLACK },
+ { label: 'Microsoft Teams', value: LOGS_ALERT_NOTIFICATION_TYPE_TEAMS },
{ label: 'Webhook', value: LOGS_ALERT_NOTIFICATION_TYPE_WEBHOOK },
]
@@ -162,7 +164,7 @@ export const logsAlertNotificationLogic = kea<logsAlertNotificationLogicType>([
slack_channel_name: notification.slackChannelName,
}
: {
- type: LOGS_ALERT_NOTIFICATION_TYPE_WEBHOOK,
+ type: notification.type,
webhook_url: notification.webhookUrl,
}
return logsAlertsDestinationsCreate(projectId, alertId, payload)
diff --git a/products/logs/frontend/components/LogsAlerting/logsAlertUtils.ts b/products/logs/frontend/components/LogsAlerting/logsAlertUtils.ts
index 6d641956ba88..134c925352c6 100644
--- a/products/logs/frontend/components/LogsAlerting/logsAlertUtils.ts
+++ b/products/logs/frontend/components/LogsAlerting/logsAlertUtils.ts
@@ -138,9 +138,11 @@ export const SNOOZE_DURATIONS = [
export const LOGS_ALERT_NOTIFICATION_TYPE_SLACK = 'slack' as const
export const LOGS_ALERT_NOTIFICATION_TYPE_WEBHOOK = 'webhook' as const
+export const LOGS_ALERT_NOTIFICATION_TYPE_TEAMS = 'teams' as const
export type LogsAlertNotificationType =
| typeof LOGS_ALERT_NOTIFICATION_TYPE_SLACK
| typeof LOGS_ALERT_NOTIFICATION_TYPE_WEBHOOK
+ | typeof LOGS_ALERT_NOTIFICATION_TYPE_TEAMS
export type PendingLogsAlertNotification =
| {
@@ -153,6 +155,10 @@ export type PendingLogsAlertNotification =
type: typeof LOGS_ALERT_NOTIFICATION_TYPE_WEBHOOK
webhookUrl: string
}
+ | {
+ type: typeof LOGS_ALERT_NOTIFICATION_TYPE_TEAMS
+ webhookUrl: string
+ }
// Filter used to list every HogFunction tied to a given alert, regardless of which
// event kind it handles. Deliberately omits the `events` array: the backend
@@ -234,6 +240,8 @@ export function groupLogsAlertDestinations(
const groups = new Map<string, LogsAlertDestinationGroup>()
for (const hf of hogFunctions) {
const slackChannelValue = hf.inputs?.channel?.value
+ // The Microsoft Teams template stores its URL under `webhookUrl`; the generic webhook uses `url`.
+ const teamsUrl = hf.inputs?.webhookUrl?.value
const webhookUrl = hf.inputs?.url?.value
let key: string
let type: LogsAlertNotificationType
@@ -244,6 +252,10 @@ export function groupLogsAlertDestinations(
key = `slack:${slackChannelValue}`
const channelName = resolveSlackLabel(slackChannelValue)
label = channelName ? `Slack #${channelName}` : 'Slack'
+ } else if (typeof teamsUrl === 'string') {
+ type = LOGS_ALERT_NOTIFICATION_TYPE_TEAMS
+ key = `teams:${teamsUrl}`
+ label = `Microsoft Teams ${teamsUrl}`
} else if (typeof webhookUrl === 'string') {
type = LOGS_ALERT_NOTIFICATION_TYPE_WEBHOOK
key = `webhook:${webhookUrl}`
diff --git a/products/logs/frontend/generated/api.schemas.ts b/products/logs/frontend/generated/api.schemas.ts
index bda65ed7ac15..b3a5b43316ea 100644
--- a/products/logs/frontend/generated/api.schemas.ts
+++ b/products/logs/frontend/generated/api.schemas.ts
@@ -355,6 +355,7 @@ export interface LogsAlertStateIntervalApi {
/**
* * `slack` - slack
* * `webhook` - webhook
+ * * `teams` - teams
*/
export type NotificationDestinationTypeEnumApi =
(typeof NotificationDestinationTypeEnumApi)[keyof typeof NotificationDestinationTypeEnumApi]
@@ -362,6 +363,7 @@ export type NotificationDestinationTypeEnumApi =
export const NotificationDestinationTypeEnumApi = {
Slack: 'slack',
Webhook: 'webhook',
+ Teams: 'teams',
} as const
/**
@@ -625,10 +627,11 @@ export interface PatchedLogsAlertConfigurationApi {
}
export interface LogsAlertCreateDestinationApi {
- /** Destination type — slack or webhook.
+ /** Destination type — slack, webhook, or teams.
*
* * `slack` - slack
- * * `webhook` - webhook */
+ * * `webhook` - webhook
+ * * `teams` - teams */
type: NotificationDestinationTypeEnumApi
/** Integration ID for the Slack workspace. Required when type=slack. */
slack_workspace_id?: number
@@ -636,7 +639,7 @@ export interface LogsAlertCreateDestinationApi {
slack_channel_id?: string
/** Human-readable channel name for display. */
slack_channel_name?: string
- /** HTTPS endpoint to POST to. Required when type=webhook. */
+ /** HTTPS endpoint to POST to. Required when type=webhook, or the Teams webhook URL when type=teams. */
webhook_url?: string
}
diff --git a/products/logs/frontend/generated/api.zod.ts b/products/logs/frontend/generated/api.zod.ts
index ed4d7e2f4cbd..6addc972fe83 100644
--- a/products/logs/frontend/generated/api.zod.ts
+++ b/products/logs/frontend/generated/api.zod.ts
@@ -296,16 +296,21 @@ export const LogsAlertsPartialUpdateBody = /* @__PURE__ */ zod.object({
*/
export const LogsAlertsDestinationsCreateBody = /* @__PURE__ */ zod.object({
type: zod
- .enum(['slack', 'webhook'])
- .describe('\* `slack` - slack\n\* `webhook` - webhook')
- .describe('Destination type — slack or webhook.\n\n\* `slack` - slack\n\* `webhook` - webhook'),
+ .enum(['slack', 'webhook', 'teams'])
+ .describe('\* `slack` - slack\n\* `webhook` - webhook\n\* `teams` - teams')
+ .describe(
+ 'Destination type — slack, webhook, or teams.\n\n\* `slack` - slack\n\* `webhook` - webhook\n\* `teams` - teams'
+ ),
slack_workspace_id: zod
.number()
.optional()
.describe('Integration ID for the Slack workspace. Required when type=slack.'),
slack_channel_id: zod.string().optional().describe('Slack channel ID. Required when type=slack.'),
slack_channel_name: zod.string().optional().describe('Human-readable channel name for display.'),
- webhook_url: zod.url().optional().describe('HTTPS endpoint to POST to. Required when type=webhook.'),
+ webhook_url: zod
+ .url()
+ .optional()
+ .describe('HTTPS endpoint to POST to. Required when type=webhook, or the Teams webhook URL when type=teams.'),
})
/**
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index ad3988e8f053..108c0d3d4e5b 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -22577,6 +22577,7 @@ export namespace Schemas {
/**
* * `slack` - slack
* * `webhook` - webhook
+ * * `teams` - teams
*/
export type NotificationDestinationTypeEnum = typeof NotificationDestinationTypeEnum[keyof typeof NotificationDestinationTypeEnum];
@@ -22584,6 +22585,7 @@ export namespace Schemas {
export const NotificationDestinationTypeEnum = {
Slack: 'slack',
Webhook: 'webhook',
+ Teams: 'teams',
} as const;
export interface LogsAlertConfiguration {
@@ -22685,10 +22687,11 @@ export namespace Schemas {
}
export interface LogsAlertCreateDestination {
- /** Destination type — slack or webhook.
+ /** Destination type — slack, webhook, or teams.
*
* * `slack` - slack
- * * `webhook` - webhook */
+ * * `webhook` - webhook
+ * * `teams` - teams */
type: NotificationDestinationTypeEnum;
/** Integration ID for the Slack workspace. Required when type=slack. */
slack_workspace_id?: number;
@@ -22696,7 +22699,7 @@ export namespace Schemas {
slack_channel_id?: string;
/** Human-readable channel name for display. */
slack_channel_name?: string;
- /** HTTPS endpoint to POST to. Required when type=webhook. */
+ /** HTTPS endpoint to POST to. Required when type=webhook, or the Teams webhook URL when type=teams. */
webhook_url?: string;
}
diff --git a/services/mcp/src/generated/logs/api.ts b/services/mcp/src/generated/logs/api.ts
index 5742bb3ed82c..c16efc75a649 100644
--- a/services/mcp/src/generated/logs/api.ts
+++ b/services/mcp/src/generated/logs/api.ts
@@ -2255,16 +2255,21 @@ export const LogsAlertsDestinationsCreateParams = /* @__PURE__ */ zod.object({
export const LogsAlertsDestinationsCreateBody = /* @__PURE__ */ zod.object({
type: zod
- .enum(['slack', 'webhook'])
- .describe('* `slack` - slack\n* `webhook` - webhook')
- .describe('Destination type — slack or webhook.\n\n* `slack` - slack\n* `webhook` - webhook'),
+ .enum(['slack', 'webhook', 'teams'])
+ .describe('* `slack` - slack\n* `webhook` - webhook\n* `teams` - teams')
+ .describe(
+ 'Destination type — slack, webhook, or teams.\n\n* `slack` - slack\n* `webhook` - webhook\n* `teams` - teams'
+ ),
slack_workspace_id: zod
.number()
.optional()
.describe('Integration ID for the Slack workspace. Required when type=slack.'),
slack_channel_id: zod.string().optional().describe('Slack channel ID. Required when type=slack.'),
slack_channel_name: zod.string().optional().describe('Human-readable channel name for display.'),
- webhook_url: zod.url().optional().describe('HTTPS endpoint to POST to. Required when type=webhook.'),
+ webhook_url: zod
+ .url()
+ .optional()
+ .describe('HTTPS endpoint to POST to. Required when type=webhook, or the Teams webhook URL when type=teams.'),
})
/**