### Quick Start Deployment Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/README.md Clone the repository, install prerequisites, create an agent configuration from a recipe, and deploy the agent. ```bash git clone https://github.com/microsoft/sre-agent.git cd sre-agent/sreagent-templates # Step 0: Install prerequisites (skips already-installed tools) ./bin/install-prerequisites.sh # Create agent config from a recipe ./bin/new-agent.sh --recipe azmon-lawappinsights --non-interactive \ --set agentName=my-agent \ --set resourceGroup=rg-my-agent \ --set location=swedencentral \ --set targetRGs=rg-my-workload \ -o my-agent/ # Deploy (~3 min) ./bin/deploy.sh my-agent/ ``` -------------------------------- ### Manual Install of Tools Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/README.md Instructions for manually installing tools like Azure CLI, jq, Python, curl, Terraform, and azd. ```bash brew install azure-cli brew install jq apt install jq winget install jqlang.jq brew install python3 && pip3 install pyyaml brew install hashicorp/tap/terraform brew install azd ``` -------------------------------- ### SRE Agent Setup Verification Report Source: https://github.com/microsoft/sre-agent/blob/main/labs/deployment-compliance/README.md Example output of the SRE Agent setup script, showing the status of connectors, code repositories, incident platform, and agent resources. All checks passing indicates the agent is fully set up. ```text Connectors: ✓ LAW query access: Built-in (Log Analytics Reader + diagnostic settings) ✓ GitHub connector: Connected Code Repositories: ✓ compliancedemo: https://github.com/dm-chelupati/compliancedemo (sync: Ready) Incident Platform: ✓ Azure Monitor: Connected Agent Resources: ✓ Skill: deployment-compliance-check ✓ Hook: deployment-compliance-approval ✓ Response plan: containerapp-compliance ✓ Scheduled task: compliance-scan ✓ All 8/8 checks passed — agent is fully set up! ``` -------------------------------- ### Install Prerequisites with Optional Tools Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/README.md Use flags to include optional tools like Terraform or to only check for installations. ```bash ./bin/install-prerequisites.sh --all # everything ./bin/install-prerequisites.sh --terraform # just Terraform ./bin/install-prerequisites.sh --check # check only, no install ``` -------------------------------- ### Install Prerequisites for macOS/Linux Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/README.md Run this script to check and install all required tools for macOS or Linux. ```bash # macOS / Linux ./bin/install-prerequisites.sh ``` -------------------------------- ### Example of Getting CPU Metrics with Full Resource ID Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/knowledge-base/http-500-errors.md Demonstrates how to fetch CPU usage metrics using a complete Azure resource ID. This command is useful for verifying metric retrieval. ```bash # Example with full resource ID: az monitor metrics list --resource "/subscriptions/cbf44432-7f45-4906-a85d-d2b14a1e8328/resourceGroups/rg-grubify-app/providers/Microsoft.App/containerApps/ca-grubify-api" --metric "UsageNanoCores" --interval PT5M ``` -------------------------------- ### Install Prerequisites for Windows Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/README.md Run this PowerShell script to check and install all required tools for Windows. ```powershell # Windows (PowerShell 7+) .\bin\ps\Install-Prerequisites.ps1 ``` -------------------------------- ### Manual SRE Agent Setup Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/README.md Provides manual steps for setting up the SRE Agent, including Azure login, environment configuration, and deployment. ```bash az login --use-device-code azd auth login --use-device-code az provider register -n Microsoft.App --wait azd env new sre-lab azd env set AZURE_LOCATION eastus2 # Optional: azd env set GITHUB_USER azd up bash scripts/post-provision.sh ``` -------------------------------- ### Setup GitHub Integration Source: https://github.com/microsoft/sre-agent/blob/main/appendix/lab-instructions.md Script to set up GitHub integration. Ensure you have the necessary permissions or use a fine-grained PAT for least-privilege access. ```bash ./scripts/setup-github.sh # macOS/Linux # Windows: "C:\\Program Files\\Git\\bin\\bash.exe" scripts/setup-github.sh ``` ```bash export GITHUB_PAT=github_pat_xxxx ./scripts/setup-github.sh ``` -------------------------------- ### Setup GitHub Integration Source: https://github.com/microsoft/sre-agent/blob/main/labs/README.md This script is used to set up GitHub integration. It is available for macOS/Linux and Windows. ```bash ./scripts/setup-github.sh # macOS/Linux # Windows: "C:\\Program Files\\Git\\bin\\bash.exe" scripts/setup-github.sh ``` -------------------------------- ### Clone and Setup SRE Agent (Windows) Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/README.md Clones the SRE Agent repository and executes the setup script for Windows environments using Git Bash. ```cmd git clone https://github.com/microsoft/sre-agent.git cd sre-agent\labs\starter-lab "C:\Program Files\Git\bin\bash.exe" scripts/setup.sh ``` -------------------------------- ### Run Lab Setup Script Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/lab/skillable-instructions.md Execute the setup script to deploy and configure the Azure SRE Agent and associated infrastructure. This script handles Azure login, resource provider registration, and agent configuration. Ensure you have your Azure subscription ID ready. ```bash "C:\Program Files\Git\bin\bash.exe" scripts/setup.sh "@lab.CloudSubscription.Id" ``` -------------------------------- ### Retry Setup Script Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/lab/skillable-instructions.md Use this command to re-run specific parts of the setup script if it fails partway through. It's useful for resuming interrupted deployments or configurations. ```bash azd up "C:\Program Files\Git\bin\bash.exe" scripts/post-provision.sh --retry ``` -------------------------------- ### Clone and Setup SRE Agent (macOS/Linux) Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/README.md Clones the SRE Agent repository and executes the setup script for macOS and Linux environments. ```bash git clone https://github.com/microsoft/sre-agent.git cd sre-agent/labs/starter-lab bash scripts/setup.sh ``` -------------------------------- ### Setup SRE Agent Knowledge Base Source: https://github.com/microsoft/sre-agent/blob/main/labs/zava-aks-postgres/AGENTS.md Uploads the knowledge file to the SRE Agent and verifies its deployment. This script is run after the initial Bicep deployment. ```powershell scripts/setup-sre-agent.ps1 ``` -------------------------------- ### Configure SRE Agent Setup Script Source: https://github.com/microsoft/sre-agent/blob/main/labs/deployment-compliance/README.md Executes the post-deployment script to configure the SRE Agent. This script is idempotent and performs various setup tasks including role assignments, diagnostic settings, and connector configurations. ```bash bash scripts/post-deploy.sh ``` -------------------------------- ### Setup GitHub with Fine-Grained PAT Source: https://github.com/microsoft/sre-agent/blob/main/labs/README.md Set up GitHub integration using a fine-grained Personal Access Token (PAT) for least-privilege access. Ensure the PAT is exported as an environment variable. ```bash export GITHUB_PAT=github_pat_xxxx ./scripts/setup-github.sh ``` -------------------------------- ### Gather Current VM Performance Metrics Source: https://github.com/microsoft/sre-agent/blob/main/labs/vm-cosmosdb/skills/vm-performance-diagnostics/SKILL.md Run this KQL query to get a snapshot of current CPU, memory, and disk space usage for specified VMs. ```kql Perf | where TimeGenerated > ago(30m) | where Computer in ("vm-sap-app-01", "vm-sap-db-01") | where ObjectName == "Processor" and CounterName == "% Processor Time" or ObjectName == "Memory" and CounterName == "% Committed Bytes In Use" or ObjectName == "LogicalDisk" and CounterName == "% Free Space" | summarize AvgValue = avg(CounterValue), MaxValue = max(CounterValue) by Computer, ObjectName, CounterName | order by Computer asc, ObjectName asc ``` -------------------------------- ### List VM Extensions Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/recipes/pagerduty-law-vmcosmos/config/skills/investigate-vm-issues.md Lists all installed extensions for a specified virtual machine. Helps identify potentially problematic extensions. ```azurecli az vm extension list -g --vm-name -o table ``` -------------------------------- ### Check Prerequisites Script Source: https://github.com/microsoft/sre-agent/blob/main/labs/deployment-compliance/README.md This script verifies that all required tools for setting up the deployment compliance monitoring are installed. It provides separate commands for macOS/Linux and Windows environments. ```bash # macOS/Linux bash scripts/prereqs.sh ``` ```bash # Windows (Git Bash or CMD)"C:\Program Files\Git\bin\bash.exe" scripts/prereqs.sh ``` -------------------------------- ### Re-run SRE Agent Setup Script Source: https://github.com/microsoft/sre-agent/blob/main/appendix/lab-instructions.md Use these commands to re-run the SRE Agent setup script. The full re-run rebuilds container images and re-uploads all configurations. The --retry flag skips container image builds and only updates the Knowledge Base, subagents, and response plan. ```bash # Full re-run (rebuilds container images + re-uploads everything) ./scripts/post-provision.sh # Skip container image builds (just update KB, subagents, response plan) ./scripts/post-provision.sh --retry # Windows: run from CMD with Python in PATH set PATH=%PATH%;C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python312 "C:\Program Files\Git\bin\bash.exe" scripts/post-provision.sh --retry ``` -------------------------------- ### Check Prerequisites Script Source: https://github.com/microsoft/sre-agent/blob/main/labs/README.md Run the prereqs script to verify that all necessary tools and their versions are installed. This script is available for both macOS/Linux and Windows. ```bash # macOS/Linux bash scripts/prereqs.sh ``` ```bash # Windows (Git Bash or CMD)"C:\Program Files\Git\bin\bash.exe" scripts/prereqs.sh ``` -------------------------------- ### Get Container App Configuration Details Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/knowledge-base/http-500-errors.md Retrieves the full configuration details of a container app in JSON format. Use this to check settings and resource allocations. ```bash # Show container app configuration az containerapp show -g -n --subscription --output json ``` ```bash # Example: az containerapp show -g rg-grubify-app -n ca-grubify-api --subscription cbf44432-7f45-4906-a85d-d2b14a1e8328 --output json ``` -------------------------------- ### Re-run SRE Agent Setup Script Source: https://github.com/microsoft/sre-agent/blob/main/labs/README.md Use these commands to re-run the post-provisioning script for the SRE Agent. The first command performs a full re-run, while the second skips container image builds. A Windows-specific command is also provided. ```bash # Full re-run (rebuilds container images + re-uploads everything) ./scripts/post-provision.sh ``` ```bash # Skip container image builds (just update KB, subagents, response plan) ./scripts/post-provision.sh --retry ``` ```bash # Windows: run from CMD with Python in PATH set PATH=%PATH%;C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python312 "C:\Program Files\Git\bin\bash.exe" scripts/post-provision.sh --retry ``` -------------------------------- ### Deploy Agent using Azure Developer CLI Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/recipes/azmon-lawappinsights/README.md Deploys the configured agent using the Azure Developer CLI. Refer to the main README for setup instructions. ```bash azd up ``` -------------------------------- ### Get VM Boot Log Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/recipes/pagerduty-law-vmcosmos/config/skills/investigate-vm-issues.md Retrieves the boot log for a virtual machine. Essential for diagnosing boot-time failures, kernel panics, or filesystem errors. ```azurecli az vm boot-diagnostics get-boot-log -g -n ``` -------------------------------- ### Query SRE Agent for Recent Deployment Compliance Source: https://github.com/microsoft/sre-agent/blob/main/labs/deployment-compliance/README.md Example prompt to check deployment compliance for the last 30 minutes after triggering a non-compliant deployment. The agent should flag the deployment as non-compliant. ```text Check deployment compliance for the last 30 minutes ``` -------------------------------- ### Retry Post-Provisioning with GitHub User Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/lab/skillable-instructions.md Re-run the post-provisioning script after setting the GitHub user. This ensures GitHub integration is correctly configured, especially if it was skipped during initial setup. ```bash "C:\Program Files\Git\bin\bash.exe" scripts/post-provision.sh --retry ``` -------------------------------- ### Navigate to Lab Directory Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/lab/skillable-instructions.md Change the current directory to the starter lab environment within the cloned repository. ```bash cd sre-agent\labs\starter-lab ``` -------------------------------- ### Get Recent HTTP 5xx Requests Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/recipes/pagerduty-law-vmcosmos/config/skills/investigate-http-errors.md Retrieves the first 5 HTTP requests with status codes starting with '5' from the last hour, including operation ID, name, result code, duration, and timestamp. Useful for initiating a detailed trace. ```kql requests | where timestamp > ago(1h) | where resultCode startswith "5" | take 5 | project operation_Id, name, resultCode, duration, timestamp ``` -------------------------------- ### Create Sample Customer Issues (Windows Bash) Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/README.md Use this command to create sample customer issues for the Grubify project on Windows. It requires the GitHub CLI. ```powershell "C:\Program Files\Git\bin\bash.exe" scripts/create-sample-issues.sh /grubify ``` -------------------------------- ### Create Sample Customer Issues (Bash) Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/README.md Use this bash script to create sample customer issues for the Grubify project. It requires the GitHub CLI. ```bash bash scripts/create-sample-issues.sh /grubify ``` -------------------------------- ### Create Environment and Deploy (macOS/Linux) Source: https://github.com/microsoft/sre-agent/blob/main/labs/README.md Create a new environment for the SRE lab and deploy the resources using the Azure Developer CLI. You will be prompted to select your subscription and region. ```bash # 3. Create environment and deploy azd env new sre-lab azd up # Select your subscription and eastus2 as the region ``` -------------------------------- ### Deploy and Tear Down Infrastructure Source: https://github.com/microsoft/sre-agent/blob/main/labs/zava-aks-postgres/README.md Use Azure Developer CLI to deploy all resources for the demo, and to tear them down when finished. ```bash azd up # Deploy everything (~25 min) azd down --force --purge # Tear down when done ``` -------------------------------- ### Create Environment and Deploy (Windows) Source: https://github.com/microsoft/sre-agent/blob/main/labs/README.md Create a new environment for the SRE lab and deploy the resources using the Azure Developer CLI. You will be prompted to select your subscription and region. ```cmd REM 3. Create environment and deploy azd env new sre-lab azd up ``` -------------------------------- ### Create Sample Support Issues Source: https://github.com/microsoft/sre-agent/blob/main/labs/README.md Use this script to generate sample support issues for a given GitHub repository. The agent will then triage these issues. ```bash ./scripts/create-sample-issues.sh ``` -------------------------------- ### Clone the SRE Agent Repository Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/lab/skillable-instructions.md Clone the official SRE Agent repository to your local machine to begin the lab setup. ```bash git clone https://github.com/microsoft/sre-agent.git ``` -------------------------------- ### GitHub Actions Workflow Environment Variables Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/examples/ci-cd/SETUP.md Example environment variables section for a GitHub Actions workflow, defining agent deployment parameters. ```yaml env: RECIPE: pagerduty-law-vmcosmos AGENT_NAME: my-pd-agent RESOURCE_GROUP: rg-my-pd LOCATION: eastus2 TARGET_RGS: rg-prod-app LAW_ID: $(LAW_ID) PAGERDUTY_API_KEY: $(PAGERDUTY_API_KEY) ``` -------------------------------- ### Prepare Secrets Environment File Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/examples/ci-cd/SETUP.md Create a secrets environment file and remove placeholder API keys. Actual secrets should be managed in CI/CD. ```bash # Remove the placeholder key (secrets go in GitHub, not git) echo "PAGERDUTY_API_KEY=" > agents/prod/connectors.secrets.env ``` -------------------------------- ### Troubleshoot Post-Provisioning Failures (Windows) Source: https://github.com/microsoft/sre-agent/blob/main/labs/README.md If post-provisioning steps fail on Windows due to 'bash not found' or 'Python not found', this command adds Python to the PATH and executes the post-provision script. ```cmd REM If post-provision fails with 'bash not found' or 'Python not found': set PATH=%PATH%;C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python312 "C:\Program Files\Git\bin\bash.exe" scripts/post-provision.sh ``` -------------------------------- ### Troubleshoot Python Not Found on Windows Source: https://github.com/microsoft/sre-agent/blob/main/labs/README.md Instructions for resolving 'Python was not found' errors on Windows, including installing Python and disabling App execution aliases. ```bash winget install Python.Python.3.12 ``` -------------------------------- ### Set GitHub User Environment Variable Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/lab/skillable-instructions.md Configure the GitHub username as an environment variable for the Azure Developer CLI. This is used for subsequent setup steps. ```bash azd env set GITHUB_USER "@lab.Variable(githubUser)" ``` -------------------------------- ### Clone Repository and Provision Infrastructure (macOS/Linux) Source: https://github.com/microsoft/sre-agent/blob/main/labs/deployment-compliance/README.md Clones the SRE Agent demo repository, signs in to Azure using azd, and provisions the necessary infrastructure. Ensure you have cloned the repo and are in the correct directory before running. ```bash # Clone the repo git clone https://github.com/dm-chelupati/compliancedemo.git cd compliancedemo # Sign in to Azure az login azd auth login # Initialize and provision azd init azd provision ``` -------------------------------- ### Calculate Request Failure Rate Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/recipes/pagerduty-law-vmcosmos/data/http-500-errors.md Calculates the rate of failed requests (status code starting with '5') over 15-minute intervals for the past 4 hours. ```kql requests | where timestamp > ago(4h) | summarize Total = count(), Failed = countif(resultCode startswith "5"), FailRate = round(100.0 * countif(resultCode startswith "5") / count(), 2) by bin(timestamp, 15m) | order by timestamp desc ``` -------------------------------- ### Clone Repository and Provision Infrastructure (Windows) Source: https://github.com/microsoft/sre-agent/blob/main/labs/deployment-compliance/README.md Clones the SRE Agent demo repository, signs in to Azure using azd, and provisions the necessary infrastructure on Windows. Ensure you have cloned the repo and are in the correct directory before running. ```cmd REM Clone the repo git clone https://github.com/dm-chelupati/compliancedemo.git cd compliancedemo REM Sign in to Azure az login azd auth login REM Initialize and provision azd init azd provision REM If post-deploy fails with 'bash not found': "C:\Program Files\Git\bin\bash.exe" scripts/post-deploy.sh ``` -------------------------------- ### Deploy Infrastructure with Terraform Source: https://github.com/microsoft/sre-agent/blob/main/labs/terraform-drift-detection/README.md Initializes Terraform, applies the configuration to deploy Azure resources, and outputs necessary information like the Logic App callback URL. ```powershell # 1. Clone and configure git clone https://github.com/surivineela/sre-agent.git cd sre-agent/labs/terraform-drift-detection/terraform cp terraform.tfvars.example terraform.tfvars # Edit terraform.tfvars with your subscription ID # 2. Deploy infrastructure terraform init terraform apply ``` -------------------------------- ### Check VM Performance Anomalies Against Baseline Source: https://github.com/microsoft/sre-agent/blob/main/labs/vm-cosmosdb/skills/vm-performance-diagnostics/SKILL.md Compare current CPU performance against the baseline from the last 7 days to identify anomalies. This query aggregates hourly CPU usage statistics. ```kql Perf | where TimeGenerated > ago(7d) | where Computer in ("vm-sap-app-01", "vm-sap-db-01") | where ObjectName == "Processor" and CounterName == "% Processor Time" | summarize AvgCPU = avg(CounterValue), P95CPU = percentile(CounterValue, 95), MaxCPU = max(CounterValue) by Computer, bin(TimeGenerated, 1h) | order by TimeGenerated desc ``` -------------------------------- ### Clone Agent and Deploy Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/CONTRIBUTING.md This snippet shows how to export an existing agent, then deploy the exported configuration using Bicep or Terraform. It also includes steps for cloning and deploying with azd. ```bash # Export from live agent ./bin/export-agent.sh -s $SUB -g $RG -n test -o /tmp/clone \ --set agentName=clone --set resourceGroup=rg-clone # Deploy clone with any backend ./bin/deploy.sh /tmp/clone/ # Bicep ./bin/deploy-tf.sh /tmp/clone/ # Terraform # azd clone: export to agents/ dir, create new env ./bin/export-agent.sh -s $SUB -g $RG -n test -o agents/clone/ \ --set agentName=clone --set resourceGroup=rg-clone azd env new clone azd env set AZURE_AGENT_NAME clone azd env set AZURE_RESOURCE_GROUP rg-clone azd env set AZURE_LOCATION swedencentral azd up # Verify clone matches source ./bin/verify-agent.sh $SUB rg-clone clone --expected /tmp/clone ``` -------------------------------- ### Get Specific Revision Logs Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/knowledge-base/http-500-errors.md Fetches the last 300 log lines from a specific revision of a container app. Useful for debugging issues related to a particular deployment. ```bash # Get recent logs from active revision (last 300 lines) az containerapp logs show -g -n --subscription --revision --tail 300 ``` ```bash # Example: az containerapp logs show -g rg-octopets-nov9 -n octopetsapi --subscription cbf44432-7f45-4906-a85d-d2b14a1e8328 --revision octopetsapi--0000003 --tail 300 ``` -------------------------------- ### Clone Repository and Initialize Submodules (Windows) Source: https://github.com/microsoft/sre-agent/blob/main/labs/README.md Clone the SRE Agent lab repository and update its submodules. This is the first step in setting up the lab environment on Windows. ```cmd REM 1. Clone the repo (in CMD or PowerShell) git clone https://github.com/dm-chelupati/sre-agent-lab.git cd sre-agent-lab git submodule update --init --recursive ``` -------------------------------- ### Error Rate Over Time (KQL) Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/knowledge-base/http-500-errors.md Calculates the total requests, failed requests (result code starting with '5'), and error rate per 5-minute interval over the last hour. ```kql requests | where timestamp > ago(1h) | summarize Total = count(), Failed = countif(resultCode startswith "5"), ErrorRate = round(100.0 * countif(resultCode startswith "5") / count(), 2) by bin(timestamp, 5m) | order by timestamp desc ``` -------------------------------- ### Get UAMI Principal ID Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/docs/GETTING-STARTED.md Retrieve the User-Assigned Managed Identity (UAMI) principal ID from the agent's resource group. This ID is needed for granting RBAC roles. ```bash # Get UAMI principal ID from the agent's resource group az identity list -g --query "[0].principalId" -o tsv ``` -------------------------------- ### Use Runbook for Diagnostic KQL Queries Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/README.md Use the http-500-errors runbook to walk through diagnostic KQL queries and view results for the Grubify app. ```text Using the http-500-errors runbook, walk me through all the diagnostic KQL queries and show me the results for the Grubify app ``` -------------------------------- ### Create Sample GitHub Issues for Triage Scenario Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/lab/skillable-instructions.md Execute this command to create sample customer-reported issues for the SRE Agent's triage scenario. This requires GitHub integration. ```bash "C:\\Program Files\\Git\\bin\\bash.exe" scripts/create-sample-issues.sh @lab.Variable(githubUser)/grubify ``` -------------------------------- ### Get Recent Container App Logs Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/knowledge-base/http-500-errors.md Retrieves the last 300 log lines from a container app. Use `--format text` if the default JSON output is not suitable. ```bash az containerapp logs show -g -n --tail 300 ``` ```bash az containerapp logs show -g -n --tail 300 --format text ``` -------------------------------- ### Failing Dependencies (KQL) Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/knowledge-base/http-500-errors.md Summarizes failing dependencies from the last hour, grouped by type, target, result code, and name. Includes failure count and average duration. ```kql dependencies | where timestamp > ago(1h) | where success == false | summarize FailureCount = count(), AvgDuration = avg(duration) by type, target, resultCode, name | order by FailureCount desc | take 10 ``` -------------------------------- ### Get VM Instance View Status Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/recipes/pagerduty-law-vmcosmos/config/skills/investigate-vm-issues.md Retrieves the instance view status for a virtual machine, including status codes and messages. Useful for diagnosing VM agent or platform issues. ```azurecli az vm get-instance-view -g -n --query "instanceView.statuses[*].{code:code, message:message}" -o table ``` -------------------------------- ### Create New Agent Configuration Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/examples/ci-cd/SETUP.md Use the new-agent.sh script to create a new agent configuration, specifying various parameters and outputting to a specified directory. ```bash ./templates/bin/new-agent.sh --recipe pagerduty-law-vmcosmos \ --set agentName=my-pd-agent \ --set resourceGroup=rg-my-pd \ --set location=eastus2 \ --set targetRGs=rg-prod-app \ --set lawId=/subscriptions/.../workspaces/law-prod \ --set "pagerdutyApiKey=placeholder" \ -o agents/prod/ ``` -------------------------------- ### Get Memory Usage Metrics via Azure CLI Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/knowledge-base/http-500-errors.md Retrieves memory usage metrics (WorkingSetBytes) for a container app over the last hour with a 5-minute interval. Requires the resource ID. ```bash # Get Memory usage metrics (last 1 hour) az monitor metrics list --resource --metric "WorkingSetBytes" --interval PT5M --start-time $(date -u -d '1 hour ago' +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || date -u -v-1H +"%Y-%m-%dT%H:%M:%SZ") --end-time $(date -u +"%Y-%m-%dT%H:%M:%SZ") ``` -------------------------------- ### Deploy Agent using Bicep Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/recipes/azmon-lawappinsights/README.md Deploys the configured agent using Bicep. Ensure the agent configuration directory exists. ```bash ./bin/deploy.sh azmon-contoso/ ``` -------------------------------- ### Get CPU Usage Metrics via Azure CLI Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/knowledge-base/http-500-errors.md Retrieves CPU usage metrics (UsageNanoCores) for a container app over the last hour with a 5-minute interval. Requires the resource ID. ```bash # Get CPU usage metrics (last 1 hour) az monitor metrics list --resource --metric "UsageNanoCores" --interval PT5M --start-time $(date -u -d '1 hour ago' +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || date -u -v-1H +"%Y-%m-%dT%H:%M:%SZ") --end-time $(date -u +"%Y-%m-%dT%H:%M:%SZ") ``` -------------------------------- ### List Available Metrics Definitions Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/knowledge-base/http-500-errors.md Lists all available metric definitions for a given Azure resource. Use this to identify correct metric names. ```bash # List available metrics for container app az monitor metrics list-definitions --resource ``` -------------------------------- ### Validate SRE Agent Configuration Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/docs/GETTING-STARTED.md Perform a dry run of the agent setup to check for common configuration errors before actual deployment. This includes region support, connector configuration, and placeholder checks. ```bash ./bin/clone-agent.sh --source my-sre-agent/ \ --agent-name my-sre-agent \ --resource-group sre-agent-rg \ --validate-only ``` -------------------------------- ### Get Specific Revision Logs (Text Format) Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/knowledge-base/http-500-errors.md Fetches the last 300 log lines from a specific revision of a container app in plain text format. Use this if the default JSON output is problematic. ```bash # If command fails, retry with --format text: az containerapp logs show -g rg-octopets-nov9 -n octopetsapi --subscription cbf44432-7f45-4906-a85d-d2b14a1e8328 --revision octopetsapi--0000003 --tail 300 --format text ``` -------------------------------- ### Full Exception Details Sample (KQL) Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/knowledge-base/http-500-errors.md Retrieves a sample of 5 recent exceptions with detailed fields like timestamp, type, messages, and operation ID. ```kql exceptions | where timestamp > ago(1h) | project timestamp, type, outerMessage, innermostMessage, details, operation_Id | order by timestamp desc | take 5 ``` -------------------------------- ### Deploy Script Workflow Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/docs/ARCHITECTURE.md This details the steps executed by the deploy.sh script when deploying an agent, including configuration detection, Bicep assembly, and Azure deployment. ```bash User runs: ./bin/deploy.sh my-agent/ deploy.sh: 1. Detects directory input (has agent.json) 2. Calls bicep/assemble-agent.sh my-agent/ → Reads agent.json, connectors.json, config/*.yaml → Resolves ${ENV_VAR} from connectors.secrets.env → Inlines .md content into YAML metadata → Produces .parameters.json + .extras.json 3. Runs az deployment sub create with .parameters.json (Bicep) 4. Runs bicep/apply-extras.sh with .extras.json (data-plane) 5. Cleans up temp files ``` -------------------------------- ### Trace HTTP 5xx Error Flow Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/recipes/pagerduty-law-vmcosmos/config/skills/investigate-http-errors.md Summarizes HTTP requests with status codes starting with '5' over the last hour, grouping by name, result code, and time. Helps identify frequently failing endpoints. ```kql requests | where timestamp > ago(1h) | where resultCode startswith "5" | summarize Count = count(), AvgDuration = avg(duration) by name, resultCode, bin(timestamp, 5m) | order by Count desc ``` -------------------------------- ### Post Comment for Questions Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/knowledge-base/github-issue-triage.md Use this comment to answer user questions. Provide the answer based on the grubify-architecture knowledge base. Add 'question' and 'answered' labels. ```text 🤖 **Grubify SRE Agent Bot** [Answer the question based on the grubify-architecture knowledge base document] 📖 Status: **Question answered** ``` -------------------------------- ### Query SRE Agent for Deployment Compliance Source: https://github.com/microsoft/sre-agent/blob/main/labs/deployment-compliance/README.md Example prompt to ask the SRE Agent to check deployment compliance for a specific time range using the deployment-compliance-check skill. The agent will query Activity Logs and classify deployments. ```text Use the deployment-compliance-check skill to check deployment compliance for the last 4 hours ``` -------------------------------- ### Failed HTTP Requests by Result Code (KQL) Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/knowledge-base/http-500-errors.md Summarizes failed HTTP requests (result codes starting with '5') from the last hour, grouped by name, result code, and URL. Includes count, average duration, and 95th percentile duration. ```kql requests | where timestamp > ago(1h) | where resultCode startswith "5" | summarize FailedCount = count(), AvgDuration = avg(duration), P95Duration = percentile(duration, 95) by name, resultCode, url | order by FailedCount desc | take 20 ``` -------------------------------- ### Test and Deploy SRE Agent Locally Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/CONTRIBUTING.md Commands to create, deploy, and clone an SRE Agent for local testing. This includes generating agent configuration, copying expected settings, deploying the agent, and then cloning and redeploying it. ```bash # Create agent config ./bin/new-agent.sh --recipe my-recipe \ --set agentName=test-agent \ --set resourceGroup=rg-test \ --set location=eastus2 \ --set targetRGs=rg-my-app \ -o /tmp/test-my-recipe \ --non-interactive # Copy expected config cp recipes/my-recipe/expected-config.json /tmp/test-my-recipe/ # Deploy + auto-verify ./bin/deploy.sh /tmp/test-my-recipe/ # Clone test ./bin/export-agent.sh -s $SUB -g rg-test -n test-agent -o /tmp/clone-test # Edit agent.json (new name/RG/region) ./bin/deploy.sh /tmp/clone-test/ ``` -------------------------------- ### Deploy Demo Application Source: https://github.com/microsoft/sre-agent/blob/main/labs/terraform-drift-detection/README.md Deploys the associated demo Node.js application to Azure App Service. ```powershell # 3. Deploy the demo app cd ../scripts .\deploy-app.ps1 ``` -------------------------------- ### Ask Agent for Grubify CPU/Memory Trends Source: https://github.com/microsoft/sre-agent/blob/main/labs/starter-lab/README.md Prompt the agent to display CPU and memory usage trends for the Grubify container app over the last hour. ```text Show me the CPU and memory usage trends for the Grubify container app over the last hour ``` -------------------------------- ### Deploy Application Source: https://github.com/microsoft/sre-agent/blob/main/labs/deployment-compliance/README.md This script deploys the latest image to the Container App. It is typically run after a successful CI/CD build and push. ```bash bash scripts/deploy.sh ``` -------------------------------- ### Generate Agent Configuration (Bash) Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/recipes/azmon-lawappinsights/README.md Use this command to generate the agent configuration file using the bash script. Ensure all prerequisites are met before execution. ```bash ./bin/new-agent.sh --recipe azmon-lawappinsights --non-interactive \ --set agentName=azmon-contoso \ --set resourceGroup=rg-azmon-contoso \ --set location=swedencentral \ --set lawId=/subscriptions/.../workspaces/contoso-law \ --set appInsightsId=/subscriptions/.../components/contoso-ai \ --set appInsightsAppId=b2c3d4e5-... \ --set targetRGs=rg-contoso-prod,rg-contoso-web \ -o azmon-contoso/ ``` -------------------------------- ### List Created Agent Files Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/docs/GETTING-STARTED.md List the files created for the new SRE Agent to review its structure and configuration files. ```bash ls my-sre-agent/ ``` -------------------------------- ### Create Recipe Directory Structure Source: https://github.com/microsoft/sre-agent/blob/main/sreagent-templates/CONTRIBUTING.md Use this command to create the necessary directories for a new SRE Agent recipe, including subdirectories for skills, subagents, hooks, common prompts, repos, scheduled tasks, and incident filters. ```bash mkdir -p recipes/my-recipe/config/{skills,subagents,hooks,common-prompts,repos} mkdir -p recipes/my-recipe/automations/{scheduled-tasks,incident-filters,incident-platforms} ```