Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Establishing monitoring for Application Gateway for Containers is crucial part of successful operations. Firstly, it allows you to visualize how traffic is controlled, providing actionable insights that help optimize performance and troubleshoot issues promptly. Secondly, monitoring enhances security measures by providing valuable insights during investigations, ensuring that your gateway remains secure and resilient against threats. Implementing monitoring for your Application Gateway for Containers not only supports ongoing performance optimization but also strengthens your overall security posture by enabling proactive detection and response capabilities.
You can monitor Azure Application Gateway for Containers resources in the following ways. Refer to the diagram.
Backend Health Metrics: ALB Controller's metric and backend health endpoints exposes several metrics and summary of backend health. The metrics endpoint enables exposure to Prometheus.
Metrics: Metrics and Activity Logs are exposed through Azure Monitor to monitor the performance of your Application Gateway for Containers deployments. The metrics contain numerical values in an ordered set of time-series data.
Diagnostic Logs: Access Logs audit all requests made to Application Gateway for Containers. Logs can provide several characteristics, such as the client's IP, requested URL, request latencies, return code, and bytes in and out. An access log is collected every 60 seconds.
Learn About the Services
- What is Azure Managed Prometheus?
- Why use Prometheus: Azure Prometheus offers native integration and management capabilities, simplifying the setup and management of monitoring infrastructure.
- What is Azure Managed Grafana?
- Why use Grafana: Azure Managed Grafana lets you bring together all your telemetry data into one place and Built-in support for Azure Monitor and Azure Data Explorer using Microsoft Entra identities.
- What is Azure Log Analytics Workspace?
- Why use Log Analytics Workspace: Log Analytics workspace scales with your business needs, handling large volumes of log data efficiently and detects and diagnose issues quickly.
Prerequisites
- An Azure account for work or school and an active subscription. You can create an account for free.
- Active Kubernetes cluster.
- Active Application Gateway for Container deployment.
- Active Resource Group with contributor permission.
Tip
Alternative to Contributor role, you may also want to leverage the following:
- Custom Role with 'microsoft.monitor/accounts/write'.
- Read access.
- Grafana Admin.
- Log Analytics Contributor.
- Monitoring Contributor permissions. Learn more about custom roles here.
Create new Applications for Configuration
Complete the steps to configure prometheus and grafana.
Sign in to the Azure portal with your Azure account.
In Search resources, service, and docs, type Kubernetes services and select your Kubernetes Cluster name.
Expand Monitoring, select Insights, and select Configure Monitoring.
Create new instances of Log analytics, Azure Monitor (Prometheus), and Managed Grafana to store current Kubernetes cluster metrics.
In Search resources, service, and docs, type Managed Prometheus and select.
Follow the steps to enable Azure Monitor to enable Managed Prometheus service by selecting Create.
Create Azure Monitor Workspace Instance:
- In the Create an Azure Monitor Workspace page, select a subscription and resource group.
- Provide a name and a region for the workspace.
- Select Review + create to create the workspace.
Add Prometheus Config Map to your cluster:
- Copy this file to notepad or Visual Studio Code: https://github.com/Azure/prometheus-collector/blob/main/otelcollector/configmaps/ama-metrics-settings-configmap.yaml.
- Modify line 35 to set podannotationnamespaceregex from “” to "azure-alb-system".
# Example Kusto Query podannotationnamespaceregex = "azure-alb-system"
- Save the file as configprometheus.yaml.
- Add file into CLI (command-line interfaces) under manage files.
- Run the following command:
# Run the Following Command in Bash kubectl apply -f configprometheus.yaml
Create a managed Grafana. Link a Grafana Workspace:
- In Search resources, service, and docs, type Azure Monitor.
- Select your monitor workspace.
- Select Linked Grafana Workspaces.
Select a Grafana workspace.
Select Link.
Configure Kubernetes cluster for logging
We created the resources and now we combine all resources and configure prometheus.
- Cluster configuration
- In Search resources, service, and docs, search for your kubernetes cluster.
- Search for insights and Select on Configure Monitoring.
- Specify each instance:
- Log analytics workspace: Use the default new log analytics workspace created for you.
- Managed Prometheus: Select on “Enable Prometheus metrics” checkbox.
- Select on advanced setting: specify the Azure monitor workspace recently created.
- Grafana Workspace: Select on Enable Grafana checkbox.
- Select on advanced setting: specify the Grafana instance recently created.
- Select “Configure”.
Enable diagnostic logs for Application Gateway for Containers
Activity logging is automatically enabled for every Resource Manager resource. For Access Logs, you must enable access logging to start collecting the data available through those logs. To enable logging, you may configure diagnostic settings in Azure Monitor.
Send logs from Application Gateway for Containers to log analytics workspace:
- Enter Application Gateway for Containers in the search box. Select your active Application Gateway for Container resource.
- Search and select Diagnostic Setting under Monitoring. Add diagnostic setting.
- Select a name, check box allLogs which includes the Application Gateway for Container Access Logs, and select Send to Log analytics Workspace with your desired subscription and recently made log analytics workspace.
Select Save.
Access Grafana dashboard
In this section, we enter Grafana default dashboards.
In Search resources, service, and docs, select your Managed Grafana.
Select the grafana resource used for configuring monitoring in the cluster.
Select on Endpoint URL in the overview.
After entering your user credentials, refer to the Grafana introduction.
Select on the left side bar to access default dashboards under dashboards.
Graph Prometheus metrics on Grafana
In this section, we visualize a sample metric from Prometheus metrics. Refer to all Prometheus metrics availabilities here: Prometheus Metrics.
- In the right top corner, Select Add Dashboard.
- Select Add Visualization.
- Search for prometheus under data source.
- Select desired metric. For Example: alb_controller_total_unhealthy_endpoints that gives any unhealthy endpoints of your backend service.
- Choose app as alb-controller.
- Select name of the panel, type of visualization, and time range.
- Save + Apply of your panel to add into your dashboard.
Note
Add a custom legend by {{variable_name}}.
Graph access logs and metrics on Grafana
In this section, we visualize a sample logs from Log Analytics Workspace. Refer to all diagnostic Logs availabilities here: Diagnostic Logs.
Workspace for logs
- In the right top corner, Select Add + Add Dashboard.
- Select Add Visualization.
- Search for Azure Monitor under data source + Add.
- Change service as Logs.
- Type:
// Example Kusto Query
AGCAccessLogs
| project BackendResponseLatency, TimeGenerated
- Select a Time Series as a visualization.
- Select name, description, and time range of the panel.
- Save + Apply to your dashboard.
Workspace for metrics
- In the right top corner, select Add + Add Dashboard.
- Select Add Visualization.
- Search for Azure Monitor under data source+ Add.
- Change service as Metrics.
- Select your application gateway for containers instance.
- Select metric namespace as microsoft.servicenetworking/trafficcontrollers.
- Choose a metric such as total requests and type of data visualization.
- Select a name, description, and time range of the panel.
- Save + Apply to your dashboard.
Congratulations! You set up a monitoring service to enhance your health tracking!