← Back to Tutorials
Advanced⏱️ 35 min

Monitoring and Diagnostics with Application Insights

Monitoring and Diagnostics with Application Insights

Why Monitoring Matters for Production Logic Apps

Production Logic Apps handle critical business workflows — order processing, data synchronization, partner integrations. Without proper monitoring, failures go unnoticed, performance degrades silently, and troubleshooting becomes guesswork.

Application Insights provides:

  • End-to-end tracing across workflow runs and actions
  • Failure detection with root cause analysis
  • Performance metrics to identify bottlenecks
  • Alerting for proactive incident response
  • Historical analysis via KQL queries

Step 1: Create an Application Insights Resource

  1. In the Azure Portal, search for Application Insights and select Create
  2. Configure the resource:
    • Subscription: Select your subscription
    • Resource Group: Use the same group as your Logic App
    • Name: appinsights-logicapps-prod
    • Region: Same region as your Logic App
    • Workspace: Select or create a Log Analytics workspace
  3. Click Review + Create, then Create

Screenshot: Create Application Insights resource


Step 2: Connect Logic App to Application Insights

  1. Navigate to your Logic App in the Azure Portal
  2. Under Settings, select Application Insights
  3. Toggle Enable Application Insights to On
  4. Select the Application Insights resource created in Step 1
  5. Click Save

Screenshot: Connect Logic App to Application Insights

For Standard Logic Apps, you can also set this in host.json:

{
  "version": "2.0",
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle.Workflows",
    "version": "[1.*, 2.0.0)"
  },
  "extensions": {
    "workflow": {
      "settings": {
        "Runtime.ApplicationInsightsInstrumentationKey": "<your-instrumentation-key>"
      }
    }
  }
}

Step 3: View Workflow Traces in Application Insights

  1. Open your Application Insights resource
  2. Navigate to Transaction search
  3. Filter by Event types → Custom Events
  4. Look for events named WorkflowRunStart, WorkflowRunEnd, WorkflowActionStart, WorkflowActionEnd
  5. Click any event to see the end-to-end transaction with all actions

Screenshot: Workflow traces in Application Insights

You can also use the Application Map to visualize dependencies between your Logic App and connected services.

Screenshot: Application Map showing Logic App dependencies


Step 4: KQL Queries for Logic Apps

Open Logs in your Application Insights resource to run these queries.

Query 1: Failed Workflow Runs (Last 24 Hours)

requests
| where timestamp > ago(24h)
| where success == false
| where name has "workflow"
| summarize FailedRuns = count() by bin(timestamp, 1h), operation_Name
| order by timestamp desc
| render timechart

Query 2: Slow Workflow Runs (Duration > 30 seconds)

requests
| where timestamp > ago(7d)
| where duration > 30000
| where name has "workflow"
| project timestamp, operation_Name, duration, resultCode
| order by duration desc
| take 50

Query 3: Workflow Throughput by Hour

requests
| where timestamp > ago(24h)
| where name has "workflow"
| summarize TotalRuns = count(), FailedRuns = countif(success == false), AvgDuration = avg(duration) by bin(timestamp, 1h)
| extend SuccessRate = round((TotalRuns - FailedRuns) * 100.0 / TotalRuns, 2)
| order by timestamp desc
| render timechart

Query 4: Top Failing Actions

customEvents
| where timestamp > ago(7d)
| where name == "WorkflowActionCompleted"
| where customDimensions.status == "Failed"
| summarize FailureCount = count() by tostring(customDimensions.actionName), tostring(customDimensions.workflowName)
| order by FailureCount desc
| take 20

Screenshot: KQL query results in Log Analytics


Step 5: Create Alert Rules

Alert Rule 1: Failure Rate Threshold

  1. In Application Insights, go to AlertsCreate alert rule
  2. Condition: Custom log search
    requests
    | where timestamp > ago(5m)
    | where name has "workflow"
    | summarize Total = count(), Failed = countif(success == false)
    | extend FailureRate = Failed * 100.0 / Total
    | where FailureRate > 10
    
  3. Threshold: Greater than 0 results
  4. Evaluation frequency: Every 5 minutes
  5. Action Group: Select or create (email, SMS, webhook)
  6. Alert rule name: Logic Apps - High Failure Rate

Screenshot: Create failure rate alert rule

Alert Rule 2: Duration Anomaly

  1. Create another alert rule
  2. Condition: Custom log search
    requests
    | where timestamp > ago(15m)
    | where name has "workflow"
    | summarize AvgDuration = avg(duration), P95Duration = percentile(duration, 95)
    | where P95Duration > 60000
    
  3. Threshold: Greater than 0 results
  4. Evaluation frequency: Every 15 minutes
  5. Action Group: Same or different group
  6. Alert rule name: Logic Apps - Duration Anomaly

Screenshot: Create duration anomaly alert rule


Step 6: Dashboard Creation in Azure Portal

  1. Navigate to Dashboard in the Azure Portal
  2. Click New dashboardBlank dashboard
  3. Name it Logic Apps Monitoring
  4. Add tiles:
    • Metrics tile: Workflow runs completed (success vs failure)
    • Log Analytics tile: Pin your KQL throughput query
    • Metrics tile: Action latency P95
    • Alert summary tile: Active alerts count
  5. Arrange tiles and set time ranges
  6. Click Save and optionally Share with your team

Screenshot: Azure Portal monitoring dashboard


Step 7: Diagnostic Settings (Send to Log Analytics)

  1. Navigate to your Logic App
  2. Under Monitoring, select Diagnostic settings
  3. Click Add diagnostic setting
  4. Configure:
    • Name: send-to-log-analytics
    • Logs: Check WorkflowRuntime and AllMetrics
    • Destination: Select Send to Log Analytics workspace
    • Workspace: Choose your workspace
  5. Click Save

Screenshot: Diagnostic settings configuration

This enables long-term retention and cross-resource querying in Log Analytics.


Alerting Best Practices

PracticeRecommendation
Alert fatigueSet meaningful thresholds; avoid alerting on every single failure
Severity levelsUse Sev 0 for critical (complete outage), Sev 2 for warnings
Action groupsRoute critical alerts to PagerDuty/phone; warnings to email/Teams
SuppressionConfigure suppression windows during planned maintenance
EscalationSet up multi-tier notification (email → SMS → phone call)
DocumentationInclude runbook links in alert descriptions
TestingTest alert rules with intentional failures before going live
Review cadenceReview and tune alert thresholds monthly

Summary

You now have full observability over your Logic Apps:

  • ✅ Application Insights connected for tracing
  • ✅ KQL queries for failure analysis and performance monitoring
  • ✅ Alert rules for proactive incident detection
  • ✅ Dashboard for at-a-glance health overview
  • ✅ Diagnostic settings for long-term log retention

Navigation

← Previous: Managed Identity Configuration | Next: Back to Tutorials