Monitoring Azure Container Instances

When you have critical applications and business processes relying on Azure resources, you want to monitor those resources for their availability, performance, and operation.

This article describes the monitoring data generated by Azure Container Instances. Azure Container Instances includes built-in support for Azure Monitor. If you're unfamiliar with the features of Azure Monitor common to all Azure services that use it, read Monitoring Azure resources with Azure Monitor.

Monitoring overview page in Azure portal

The Overview page in the Azure portal for each container instance includes a brief view of resource usage and telemetry.

Graphs of resource usage displayed on Container Instance overview page, PNG.

Monitoring data

Azure Container Instances collects the same kinds of monitoring data as other Azure resources that are described in Monitoring data from Azure resources.

See Monitoring Azure Container Instances data reference for detailed information on the metrics and logs metrics created by Azure Container Instances.

Collection and routing

Platform metrics and the Activity log are collected and stored automatically, but can be routed to other locations by using a diagnostic setting.

Resource Logs aren't collected and stored until you create a diagnostic setting and route them to one or more locations.

See Create diagnostic setting to collect platform logs and metrics in Azure for the detailed process for creating a diagnostic setting using the Azure portal, CLI, or PowerShell. When you create a diagnostic setting, you specify which categories of logs to collect.

The metrics and logs you can collect are discussed in the following sections.

Analyzing metrics

You can analyze metrics for Azure Container Instances with metrics from other Azure services using metrics explorer by opening Metrics from the Azure Monitor menu. See Getting started with Azure Metrics Explorer for details on using this tool.

For a list of the platform metrics collected for Azure Container Instances, see Monitoring Azure Container Instances data reference metrics.

All metrics for Azure Container Instances are in the namespace Container group standard metrics. In a container group with multiple containers, you can additionally filter on the dimension containerName to acquire metrics from a specific container within the group.

For reference, you can see a list of all resource metrics supported in Azure Monitor.

View operation level metrics for Azure Container Instances

  1. Sign in to the Azure portal.

  2. Select Monitor from the left-hand navigation bar, and select Metrics.

Screenshot of metrics tab under Monitor on the Azure portal, PNG.

  1. On the Select a scope page, choose your subscription and resource group. Under Refine scope, choose Container instances for Resource type. Pick one of your container instances from the list and select Apply.

Screenshot of selecting scope for metrics analysis on the Azure portal, PNG.

  1. Next, you can pick a metric to view from the list of available metrics. Here, we choose CPU Usage and use Avg as the aggregation value.

Screenshot of selecting CPU Usage metric, PNG.

Add filters to metrics

In a scenario where you have a container group with multiple containers, you may find it useful to apply a filter on the metric dimension containerName. This will allow you to view metrics by container as opposed to an aggregate of the group as a whole.

Screenshot of filtering metrics by container name in a container group, PNG.

Analyzing logs

Data in Azure Monitor Logs is stored in tables where each table has its own set of unique properties.

All resource logs in Azure Monitor have the same fields followed by service-specific fields. The common schema is outlined in Azure Monitor resource log schema The schema for Azure Container Instances resource logs is found in the Azure Container Instances Data Reference.

The Activity log is a type of Azure platform log that provides insight into subscription-level events. You can view it independently or route it to Azure Monitor Logs, where you can do much more complex queries using Log Analytics. You can see a list of the kinds of operations that will be logged in the Azure Container Instances Data Reference

Sample Kusto queries

Azure Monitor logs includes an extensive [query language][query_lang] for pulling information from potentially thousands of lines of log output.

The basic structure of a query is the source table (in this article, ContainerInstanceLog_CL or ContainerEvent_CL) followed by a series of operators separated by the pipe character (|). You can chain several operators to refine the results and perform advanced functions.

To see example query results, paste the following query into the query text box, and select the Run button to execute the query. This query displays all log entries whose "Message" field contains the word "warn":

ContainerInstanceLog_CL
| where Message contains "warn"

More complex queries are also supported. For example, this query displays only those log entries for the "mycontainergroup001" container group generated within the last hour:

ContainerInstanceLog_CL
| where (ContainerGroup_s == "mycontainergroup001")
| where (TimeGenerated > ago(1h))

Important

When you select Logs from the Azure Container Instances menu, Log Analytics is opened with the query scope set to the current Azure Container Instances. This means that log queries will only include data from that resource. If you want to run a query that includes data from other resources or data from other Azure services, select Logs from the Azure Monitor menu. See Log query scope and time range in Azure Monitor Log Analytics for details.

For a list of common queries for Azure Container Instances, see the Log Analytics queries interface.

Alerts

Azure Monitor alerts proactively notify you when important conditions are found in your monitoring data. They allow you to identify and address issues in your system before your customers notice them. You can set alerts on metrics, logs, and the activity log. Different types of alerts have benefits and drawbacks.

For Azure Container Instances, there are three categories for alerting:

  • Activity logs - You can set alerts for Azure Container Instances operations like create, update, and delete. See the Monitoring Azure Container Instances data reference for a list of activities you can track.
  • Metrics - You can set alerts for vCPU usage, memory usage, and network input and output utilization. Depending on the function of the container you deploy, you may want to monitor different metrics. For example, if you don't expect your container's memory usage to exceed a certain threshold, setting an alert for when memory usage exceeds it may be useful.
  • Custom log search - You can set alerts for specific outputs in logs. For example, you can use these alerts to robustly capture stdout and stderr by setting alerts for when those outputs appear in the logs.

Next steps