Azure VM Monitoring
Query Metrics
Retrieve performance metrics for an Azure VM.Endpoint
Available Metrics
- CPU Metrics
- Memory Metrics
Response
Query Configuration
Metrics are queried for the last hour from the current timeStart Time:
End Time:
datetime.utcnow() - timedelta(hours=1)End Time:
datetime.utcnow()Data aggregation interval (5 minutes)Format: ISO 8601 duration
Statistical aggregation applied to metrics
AVERAGE- Mean value over the intervalMINIMUM- Lowest value in the intervalMAXIMUM- Highest value in the intervalTOTAL- Sum of all values
Check Agent Status
Verify if Azure Monitor Agent (AMA) or legacy MMA is installed.Endpoint
Response
Azure Monitor Agent (AMA) is the modern replacement for MMA (Microsoft Monitoring Agent). Use AMA for new deployments.
Install Azure Monitor Agent
Automatically install the appropriate monitoring agent.Endpoint
Agent Selection
The system automatically detects the OS type and installs the correct agent:- Linux
- Windows
Extension:
Publisher:
Version: 1.0
Auto-upgrade: EnabledInstalled on VMs without
AzureMonitorLinuxAgentPublisher:
Microsoft.Azure.MonitorVersion: 1.0
Auto-upgrade: EnabledInstalled on VMs without
windows_configuration in OS profile.Response
If the agent is already installed, the API returns a 200 status with message “AMA already installed”.
GCP VM Monitoring
Find VM for Monitoring
Locate a VM instance across all projects and zones.Endpoint
Response
Available Metrics
Query available metrics for a GCP VM instance.Endpoint
Response
Agentless Metrics
Agentless Metrics
Available without installing Ops Agent:
- CPU utilization
- Network bytes (sent/received)
- Disk operations (read/write bytes)
Agent-Based Metrics
Agent-Based Metrics
Require Google Cloud Ops Agent:
- Memory usage percentage
- Disk usage percentage
- Custom application metrics
Query Metric Time Series
Retrieve historical metric data.Endpoint
Request Parameters
Metric type to query (e.g.,
compute.googleapis.com/instance/cpu/utilization)Time window for the query in minutes
Request Example
Response
Aggregation Configuration
Time interval for data aggregation (5 minutes)
Aggregation function applied to time series data
ALIGN_MEAN- Average valueALIGN_MIN- Minimum valueALIGN_MAX- Maximum valueALIGN_SUM- Sum of values
Check Ops Agent Status
Verify if Google Cloud Ops Agent is installed and active.Endpoint
Response
Detection Method
The system checks for theagent.googleapis.com/agent/uptime metric in the last 10 minutes:
- Active: Metric data exists → Agent is running
- Inactive: No metric data → Agent not installed or not reporting
Install Ops Agent
Automatically install Google Cloud Ops Agent on a VM.Endpoint
Response
Installation Scripts
- Linux
- Windows
SHELL command type.Required Permissions
To install Ops Agent, the service account needs:compute.instances.getosconfig.guestPolicies.create(or useroles/osconfig.guestPolicyAdmin)
Query VM Logs (GCP)
Execute custom log queries using Cloud Logging.Endpoint
Request Parameters
Log Query Language (LQL) filter expressionMust include:
resource.labels.instance_id="<instance_id>"Request Example
Response
Query Configuration
Sort order by timestamp (newest first)
Maximum number of log entries to return
Monitoring Comparison
- Azure Monitor
- Cloud Monitoring
Features
- Agent: Azure Monitor Agent (AMA)
- Metrics Interval: 5 minutes
- Default Retention: 30 days
- Memory Metrics: Requires agent
- Log Analytics: Azure Monitor Logs
Metrics Source
- Platform metrics (agentless): CPU, network, disk
- Guest metrics (AMA required): Memory, processes
Code Reference
backend/azure_modules/vmmonitor.py:14-208Next Steps
Configure Alerts
Set up alert policies for metrics
Azure VMs
Learn more about Azure VM management
GCP VMs
Explore GCP VM operations