This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| wiki:ai:openai-chatbot-deployment-checklist [2025/05/16 18:35] – created ddehamer | wiki: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(' | ||
| + | resource cpuAlert ' | ||
| + | name: ' | ||
| + | location: ' | ||
| + | properties: { | ||
| + | description: | ||
| + | severity: 3 | ||
| + | enabled: true | ||
| + | scopes: [containerAppResourceId] | ||
| + | evaluationFrequency: | ||
| + | windowSize: ' | ||
| + | criteria: { | ||
| + | allOf: [ | ||
| + | { | ||
| + | metricName: ' | ||
| + | metricNamespace: | ||
| + | operator: ' | ||
| + | threshold: 80 | ||
| + | timeAggregation: | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | actions: [ | ||
| + | { | ||
| + | actionGroupId: | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | } | ||
| + | |||
| + | @description(' | ||
| + | resource memoryAlert ' | ||
| + | name: ' | ||
| + | location: ' | ||
| + | properties: { | ||
| + | description: | ||
| + | severity: 3 | ||
| + | enabled: true | ||
| + | scopes: [containerAppResourceId] | ||
| + | evaluationFrequency: | ||
| + | windowSize: ' | ||
| + | criteria: { | ||
| + | allOf: [ | ||
| + | { | ||
| + | metricName: ' | ||
| + | metricNamespace: | ||
| + | operator: ' | ||
| + | threshold: 75 | ||
| + | timeAggregation: | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | actions: [ | ||
| + | { | ||
| + | actionGroupId: | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ==== KQL Code for HTTP 500 Errors ==== | ||
| + | |||
| + | <code -> | ||
| + | AppContainerAppConsoleLogs_CL | ||
| + | | where Log_s contains " | ||
| + | | summarize Count=count() by bin(TimeGenerated, | ||
| + | | where Count > 0 | ||
| + | </ | ||
| + | |||
| + | ==== Bicep Template for Log Query Alert ==== | ||
| + | |||
| + | <code -> | ||
| + | param logAnalyticsWorkspaceId string | ||
| + | param actionGroupId string | ||
| + | |||
| + | @description(' | ||
| + | resource errorLogAlert ' | ||
| + | name: ' | ||
| + | location: ' | ||
| + | properties: { | ||
| + | description: | ||
| + | enabled: true | ||
| + | source: { | ||
| + | query: ''' | ||
| + | AppContainerAppConsoleLogs_CL | ||
| + | | where Log_s contains " | ||
| + | | summarize Count=count() by bin(TimeGenerated, | ||
| + | | where Count > 0 | ||
| + | ''' | ||
| + | dataSourceId: | ||
| + | queryType: ' | ||
| + | } | ||
| + | schedule: { | ||
| + | frequencyInMinutes: | ||
| + | timeWindowInMinutes: | ||
| + | } | ||
| + | action: { | ||
| + | severity: 3 | ||
| + | trigger: { | ||
| + | thresholdOperator: | ||
| + | threshold: 0 | ||
| + | } | ||
| + | actions: [ | ||
| + | { | ||
| + | actionGroupId: | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ==== Deployment Example ==== | ||
| + | |||
| + | <code -> | ||
| + | az deployment group create \ | ||
| + | --resource-group MyResourceGroup \ | ||
| + | --template-file log-alert.bicep \ | ||
| + | --parameters \ | ||
| + | logAnalyticsWorkspaceId="/ | ||
| + | actionGroupId="/ | ||
| + | </ | ||
| + | |||
| + | ===== ✅ 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 ' | ||
| + | name: ' | ||
| + | location: ' | ||
| + | properties: { | ||
| + | description: | ||
| + | severity: 3 | ||
| + | enabled: true | ||
| + | scopes: [containerAppResourceId] | ||
| + | evaluationFrequency: | ||
| + | windowSize: ' | ||
| + | criteria: { | ||
| + | allOf: [ | ||
| + | { | ||
| + | metricName: ' | ||
| + | metricNamespace: | ||
| + | operator: ' | ||
| + | threshold: 80 | ||
| + | timeAggregation: | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | actions: [ | ||
| + | { | ||
| + | actionGroupId: | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | } | ||
| + | |||
| + | // Memory High Usage Alert | ||
| + | resource memoryAlert ' | ||
| + | name: ' | ||
| + | location: ' | ||
| + | properties: { | ||
| + | description: | ||
| + | severity: 3 | ||
| + | enabled: true | ||
| + | scopes: [containerAppResourceId] | ||
| + | evaluationFrequency: | ||
| + | windowSize: ' | ||
| + | criteria: { | ||
| + | allOf: [ | ||
| + | { | ||
| + | metricName: ' | ||
| + | metricNamespace: | ||
| + | operator: ' | ||
| + | threshold: 75 | ||
| + | timeAggregation: | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | actions: [ | ||
| + | { | ||
| + | actionGroupId: | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | } | ||
| + | |||
| + | // HTTP 500 Log Alert | ||
| + | resource errorLogAlert ' | ||
| + | name: ' | ||
| + | location: ' | ||
| + | properties: { | ||
| + | description: | ||
| + | enabled: true | ||
| + | source: { | ||
| + | query: ''' | ||
| + | AppContainerAppConsoleLogs_CL | ||
| + | | where Log_s contains " | ||
| + | | summarize Count=count() by bin(TimeGenerated, | ||
| + | | where Count > 0 | ||
| + | ''' | ||
| + | dataSourceId: | ||
| + | queryType: ' | ||
| + | } | ||
| + | schedule: { | ||
| + | frequencyInMinutes: | ||
| + | timeWindowInMinutes: | ||
| + | } | ||
| + | action: { | ||
| + | severity: 3 | ||
| + | trigger: { | ||
| + | thresholdOperator: | ||
| + | threshold: 0 | ||
| + | } | ||
| + | actions: [ | ||
| + | { | ||
| + | actionGroupId: | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Deployment Command Example | ||
| + | < | ||
| + | az deployment group create \ | ||
| + | --resource-group MyResourceGroup \ | ||
| + | --template-file complete-alerts.bicep \ | ||
| + | --parameters \ | ||
| + | containerAppResourceId="/ | ||
| + | logAnalyticsWorkspaceId="/ | ||
| + | actionGroupId="/ | ||
| + | </ | ||