User Tools

Site Tools


wiki:ai:openai-chatbot-deployment-checklist

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
wiki:ai:openai-chatbot-deployment-checklist [2025/05/16 18:35] – created ddehamerwiki:ai:openai-chatbot-deployment-checklist [2025/05/16 19:14] (current) ddehamer
Line 96: Line 96:
     * Webhook (optional)     * Webhook (optional)
  
 +===== Bicep Definitions To Create Alerts =====
 +
 +<code ->
 +param containerAppResourceId string
 +param logAnalyticsWorkspaceId string
 +param actionGroupId string
 +
 +@description('Create CPU High Usage Alert')
 +resource cpuAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
 +  name: 'cpu-high-usage'
 +  location: 'global'
 +  properties: {
 +    description: 'Alert when CPU usage exceeds 80%'
 +    severity: 3
 +    enabled: true
 +    scopes: [containerAppResourceId]
 +    evaluationFrequency: 'PT1M'
 +    windowSize: 'PT5M'
 +    criteria: {
 +      allOf: [
 +        {
 +          metricName: 'cpuUsagePercentage'
 +          metricNamespace: 'Microsoft.App/containerApps'
 +          operator: 'GreaterThan'
 +          threshold: 80
 +          timeAggregation: 'Average'
 +        }
 +      ]
 +    }
 +    actions: [
 +      {
 +        actionGroupId: actionGroupId
 +      }
 +    ]
 +  }
 +}
 +
 +@description('Create Memory High Usage Alert')
 +resource memoryAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
 +  name: 'memory-high-usage'
 +  location: 'global'
 +  properties: {
 +    description: 'Alert when memory usage exceeds 75%'
 +    severity: 3
 +    enabled: true
 +    scopes: [containerAppResourceId]
 +    evaluationFrequency: 'PT1M'
 +    windowSize: 'PT5M'
 +    criteria: {
 +      allOf: [
 +        {
 +          metricName: 'memoryWorkingSetBytes'
 +          metricNamespace: 'Microsoft.App/containerApps'
 +          operator: 'GreaterThan'
 +          threshold: 75
 +          timeAggregation: 'Average'
 +        }
 +      ]
 +    }
 +    actions: [
 +      {
 +        actionGroupId: actionGroupId
 +      }
 +    ]
 +  }
 +}
 +</code>
 +
 +==== KQL Code for HTTP 500 Errors ====
 +
 +<code ->
 +AppContainerAppConsoleLogs_CL
 +| where Log_s contains "500"
 +| summarize Count=count() by bin(TimeGenerated, 5m)
 +| where Count > 0
 +</code>
 +
 +==== Bicep Template for Log Query Alert ====
 +
 +<code ->
 +param logAnalyticsWorkspaceId string
 +param actionGroupId string
 +
 +@description('Create HTTP 500 Error Log Alert')
 +resource errorLogAlert 'Microsoft.Insights/scheduledQueryRules@2021-08-01' = {
 +  name: 'http-500-error-alert'
 +  location: 'global'
 +  properties: {
 +    description: 'Alert when HTTP 500 errors are detected in logs'
 +    enabled: true
 +    source: {
 +      query: '''
 +        AppContainerAppConsoleLogs_CL
 +        | where Log_s contains "500"
 +        | summarize Count=count() by bin(TimeGenerated, 5m)
 +        | where Count > 0
 +      '''
 +      dataSourceId: logAnalyticsWorkspaceId
 +      queryType: 'ResultCount'
 +    }
 +    schedule: {
 +      frequencyInMinutes: 5
 +      timeWindowInMinutes: 5
 +    }
 +    action: {
 +      severity: 3
 +      trigger: {
 +        thresholdOperator: 'GreaterThan'
 +        threshold: 0
 +      }
 +      actions: [
 +        {
 +          actionGroupId: actionGroupId
 +        }
 +      ]
 +    }
 +  }
 +}
 +</code>
 +
 +==== Deployment Example ====
 +
 +<code ->
 +az deployment group create \
 +  --resource-group MyResourceGroup \
 +  --template-file log-alert.bicep \
 +  --parameters \
 +    logAnalyticsWorkspaceId="/subscriptions/<sub-id>/resourceGroups/<rg>/providers/Microsoft.OperationalInsights/workspaces/<workspace-name>" \
 +    actionGroupId="/subscriptions/<sub-id>/resourceGroups/<rg>/providers/Microsoft.Insights/actionGroups/NotifyTeam"
 +</code>
 +
 +===== ✅ What This Provides =====
 +
 +  * **Detection of HTTP 500 Errors** in Console Logs.
 +  * **Trigger Every 5 Minutes** if any are found.
 +  * **Send Notifications via Action Group**.
 +
 +Complete Bicep Bundle
 +
 +<code ->
 +param containerAppResourceId string
 +param logAnalyticsWorkspaceId string
 +param actionGroupId string
 +
 +// CPU High Usage Alert
 +resource cpuAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
 +  name: 'cpu-high-usage'
 +  location: 'global'
 +  properties: {
 +    description: 'Alert when CPU usage exceeds 80%'
 +    severity: 3
 +    enabled: true
 +    scopes: [containerAppResourceId]
 +    evaluationFrequency: 'PT1M'
 +    windowSize: 'PT5M'
 +    criteria: {
 +      allOf: [
 +        {
 +          metricName: 'cpuUsagePercentage'
 +          metricNamespace: 'Microsoft.App/containerApps'
 +          operator: 'GreaterThan'
 +          threshold: 80
 +          timeAggregation: 'Average'
 +        }
 +      ]
 +    }
 +    actions: [
 +      {
 +        actionGroupId: actionGroupId
 +      }
 +    ]
 +  }
 +}
 +
 +// Memory High Usage Alert
 +resource memoryAlert 'Microsoft.Insights/metricAlerts@2018-03-01' = {
 +  name: 'memory-high-usage'
 +  location: 'global'
 +  properties: {
 +    description: 'Alert when memory usage exceeds 75%'
 +    severity: 3
 +    enabled: true
 +    scopes: [containerAppResourceId]
 +    evaluationFrequency: 'PT1M'
 +    windowSize: 'PT5M'
 +    criteria: {
 +      allOf: [
 +        {
 +          metricName: 'memoryWorkingSetBytes'
 +          metricNamespace: 'Microsoft.App/containerApps'
 +          operator: 'GreaterThan'
 +          threshold: 75
 +          timeAggregation: 'Average'
 +        }
 +      ]
 +    }
 +    actions: [
 +      {
 +        actionGroupId: actionGroupId
 +      }
 +    ]
 +  }
 +}
 +
 +// HTTP 500 Log Alert
 +resource errorLogAlert 'Microsoft.Insights/scheduledQueryRules@2021-08-01' = {
 +  name: 'http-500-error-alert'
 +  location: 'global'
 +  properties: {
 +    description: 'Alert when HTTP 500 errors are detected in logs'
 +    enabled: true
 +    source: {
 +      query: '''
 +        AppContainerAppConsoleLogs_CL
 +        | where Log_s contains "500"
 +        | summarize Count=count() by bin(TimeGenerated, 5m)
 +        | where Count > 0
 +      '''
 +      dataSourceId: logAnalyticsWorkspaceId
 +      queryType: 'ResultCount'
 +    }
 +    schedule: {
 +      frequencyInMinutes: 5
 +      timeWindowInMinutes: 5
 +    }
 +    action: {
 +      severity: 3
 +      trigger: {
 +        thresholdOperator: 'GreaterThan'
 +        threshold: 0
 +      }
 +      actions: [
 +        {
 +          actionGroupId: actionGroupId
 +        }
 +      ]
 +    }
 +  }
 +}
 +</code>
 +
 +Deployment Command Example
 +<code>
 +az deployment group create \
 +  --resource-group MyResourceGroup \
 +  --template-file complete-alerts.bicep \
 +  --parameters \
 +    containerAppResourceId="/subscriptions/<sub-id>/resourceGroups/<rg>/providers/Microsoft.App/containerApps/<app-name>" \
 +    logAnalyticsWorkspaceId="/subscriptions/<sub-id>/resourceGroups/<rg>/providers/Microsoft.OperationalInsights/workspaces/<workspace-name>" \
 +    actionGroupId="/subscriptions/<sub-id>/resourceGroups/<rg>/providers/Microsoft.Insights/actionGroups/NotifyTeam"
 +</code>
  
wiki/ai/openai-chatbot-deployment-checklist.1747420504.txt.gz · Last modified: by ddehamer