如何为Logic App Standard工作流配置失败告警?
Hey there, I've dealt with this exact scenario before—Logic App Standard doesn't have that handy RunsFailed out-of-the-box metric like Consumption plans do, but you don't need to write custom logs to set up failure alerts. The key is leveraging the built-in telemetry that's automatically sent to your Log Analytics Workspace if you've configured it correctly. Here's how to set this up properly:
Option 1: Alert on Failed Workflow Runs (Broad Scope)
First, make sure your Logic App Standard instance is linked to a Log Analytics Workspace:
- Go to your Logic App > Monitoring > Diagnostic settings
- Create a new setting, select your Log Analytics Workspace, and check the
WorkflowRuntimeLogscategory (this captures all workflow run and activity events)
Once that's set up, create the alert rule:
- Navigate to Azure Monitor > Alerts > Create > Alert rule
- Under Resource, select your Log Analytics Workspace
- For Condition, choose "Custom log search" as the signal type, then paste this Kusto query to filter failed runs:
WorkflowRuntimeLogs | where OperationName == "WorkflowRunCompleted" | where Status == "Failed" | project TimeGenerated, WorkflowName, RunId, Status - Set your alert threshold (e.g., "Number of results greater than 0") and evaluation frequency (e.g., check every 5 minutes, look back 5 minutes)
- Configure your Action Group to send notifications (email, Teams, SMS) or trigger automated actions
- Finish by naming your alert rule and adding a description for context
Option 2: Alert on Specific Failed Activities (Granular Control)
If you need to target failures in individual activities rather than entire runs, adjust the Kusto query to focus on activity-level events:
WorkflowRuntimeLogs | where OperationName == "ActivityCompleted" | where Status == "Failed" | project TimeGenerated, WorkflowName, ActivityName, RunId, ErrorMessage
This lets you get alerts only when a specific step (like an HTTP call or SQL query) fails, which is great for targeted troubleshooting.
Pro Tips for Optimization
- Add dynamic details to notifications: Include fields like
WorkflowNameandRunIdin your alert message so your team can jump straight to the failed run in the Logic App portal - Set alert suppression: Prevent spammy alerts by configuring a suppression period (e.g., don't send another alert for the same workflow failure within 15 minutes)
- Automate remediation: Use Action Groups to trigger a Logic App or Azure Function that attempts to retry the failed run, or creates a ticket in your ITSM tool
内容的提问来源于stack exchange,提问作者AasthaK

