MSDN Documentation

Monitoring Azure Container Instances (ACI)

This tutorial guides you through setting up monitoring for your Azure Container Instances (ACI) to gain insights into their performance and health.

Introduction to ACI Monitoring

Azure Container Instances (ACI) offers a simplified way to run containers in Azure without managing virtual machines. Effective monitoring is crucial for ensuring the reliability and performance of your containerized applications. ACI integrates with Azure Monitor, providing comprehensive tools for collecting, analyzing, and acting on telemetry from your containers.

Key Monitoring Components

Prerequisites

Step 1: Enabling Container Insights

Container Insights provides a unified view of your ACI deployments. You can enable it for your ACI resources.

  1. Navigate to your ACI resource in the Azure portal.
  2. Under the 'Monitoring' section, select 'Insights'.
  3. If Container Insights is not enabled, you will be prompted to enable it. Follow the on-screen instructions.

This typically involves deploying a Log Analytics workspace and configuring the monitoring agent.

Step 2: Accessing Metrics

You can view key performance metrics for your ACI directly from the Azure portal.

  1. Go to your ACI resource in the Azure portal.
  2. Under 'Monitoring', select 'Metrics'.
  3. Choose the desired metric (e.g., 'CPU Usage Percentage', 'Memory Working Set').
  4. Select an appropriate aggregation (e.g., 'Average', 'Maximum').
  5. Set the time range to view the metric data over time.

You can also pin these charts to your Azure dashboard for quick access.

Step 3: Collecting and Querying Logs

To effectively troubleshoot and understand container behavior, you need to collect and query their logs.

Configuring Log Collection:

  • Ensure your container application is configured to output logs to standard output (stdout) or standard error (stderr).
  • When using Container Insights, it automatically collects logs from ACI.

Querying Logs with Kusto Query Language (KQL):

Logs are stored in a Log Analytics workspace. You can query them using KQL.


ContainerLogs
| where ContainerGroupName == "your-aci-group-name"
| where TimeGenerated > ago(1h)
| project TimeGenerated, LogMessage
| order by TimeGenerated desc
                

Replace "your-aci-group-name" with the actual name of your ACI resource.

Step 4: Setting Up Alerts

Proactive alerting helps you respond to potential issues before they impact your users.

  1. Navigate to your Log Analytics workspace or ACI resource in the Azure portal.
  2. Go to 'Alerts' and click 'Create alert rule'.
  3. Configure the conditions based on metrics (e.g., high CPU usage) or log queries (e.g., specific error messages).
  4. Define the action group to notify you (e.g., email, SMS, webhook).

Example Alert Condition (Log-based):


ContainerLogs
| where LogMessage contains "error"
| summarize count() by bin(TimeGenerated, 5m)
| where count_ > 0
                

Conclusion

By leveraging Azure Monitor's capabilities, you can gain deep visibility into your ACI deployments, ensuring their health, performance, and availability. Regular monitoring and timely alerts are key to maintaining robust containerized applications in Azure.