Azure Container Instances can send logs and performance data to a Log Analytics workspace, which acts as a central hub for security monitoring. You enable this by creating a diagnostic setting on each container group. The setting streams two types of data: ContainerInstanceLogs (which contain the container's stdout and stderr output) and ContainerInstanceMetrics (which contain CPU, memory, and other performance numbers). You can send these logs to multiple places, including Azure Monitor metrics and storage accounts for long-term storage.
A data collection rule controls how logs flow into your workspace and can apply workspace transformations to filter out data you do not need. For example, you might filter to keep only logs about authentication failures or container restarts while discarding routine startup messages. This filtering saves storage costs and keeps your security data focused.
To find threats or problems, you write queries using Kusto Query Language (KQL) against your container log tables. These queries can search for patterns like repeated failed logins, containers that exit unexpectedly, or sudden spikes in CPU or memory usage. Each of these patterns could indicate a security issue or a misconfigured workload.
Once you have useful queries, you create scheduled query rules that run automatically at set intervals. When a query returns results that meet your threshold, it triggers an alert. You can also create metric alerts that watch real-time numbers like CPU percentage across one or many container instances. Both types of alerts can connect to action groups that notify your team through email, SMS, or automated workflows so you can respond quickly.
Following best practices makes monitoring more effective and affordable. Stream only security-relevant logs instead of every message the container produces. Use basic logs where full detail is not needed to reduce costs. Avoid collecting resource logs that your team will never review. Apply workspace transformations to filter data before it enters your workspace, which keeps your analysis focused on what matters for detecting incidents.
Are you a guardian of your domain? Lean how to leverage your aptitude in security to protect Microsoft Azure technologies, with a goal of earning the Microsoft Certified: Azure Security Engineer Associate certification!
Prepare and test your skills

Prepare and test your skills

A diagnostic setting on a container group streams two types of data: ContainerInstanceLogs, which contain the container's stdout and stderr output, and ContainerInstanceMetrics, which contain CPU, memory, and other performance numbers.
A data collection rule controls how logs flow into your workspace and can apply workspace transformations to filter out data you do not need, such as keeping only logs about authentication failures or container restarts while discarding routine startup messages.
You write queries using Kusto Query Language (KQL) against your container log tables to search for patterns like repeated failed logins, containers that exit unexpectedly, or sudden spikes in CPU or memory usage, each of which could indicate a security issue or misconfigured workload.
You create scheduled query rules that run automatically at set intervals and trigger an alert when results meet a threshold, or you create metric alerts that watch real-time numbers like CPU percentage across one or many container instances; both types can connect to action groups that notify your team through email, SMS, or automated workflows.