Azure Monitor Exporter Configuration
Cost Notice for Azure Metrics Exporter
Azure Metrics Exporter queries metrics through the Azure Monitor API. Charges may apply based on the number of metrics queried and the volume of API calls. Fees are calculated based on usage such as metric queries and API requests in Azure Monitor. For details, refer to the Azure official pricing page.
Prerequisites
Azure Subscription and Permission Requirements
The following permissions are required to collect metrics from Azure resources.
| Permission | Description | Scope |
|---|---|---|
| Monitoring Reader | Read access for Azure Monitor metrics | Subscription or Resource Group |
| Reader | Resource information lookup (for service discovery) | Subscription or Resource Group |
Recommended Configuration
- Use the
Monitoring Readerrole following the principle of least privilege - If monitoring only specific resource groups, limit the scope accordingly
Collecting Required Azure Resource Information
Collect the following information in advance for Exporter configuration.
| Item | Description | Example |
|---|---|---|
| Subscription ID | Azure subscription identifier | xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx |
| Tenant ID | Azure AD tenant identifier | xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx |
| Client ID | Application ID of the registered app | xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx |
| Client Secret | Secret key for app authentication | xxxxxxxxxxxxxxxxxxxxxxxxxxxx |
| Resource Group | Resource group name | xxxxxxxxxx |
| Resource Name | Resource name (server name/cache name/namespace name/cluster name, etc.) | xxxxxxxxxx |
Azure Metrics Exporter Installation
Download Exporter
# linux/amd64 (x86_64)
wget https://repo.whatap.io/exporter/azure_metrics_exporter/amd64/azure_metrics_exporter
# linux/arm64 (aarch64)
wget https://repo.whatap.io/exporter/azure_metrics_exporter/arm64/azure_metrics_exporter
Grant Execution Permission and Install
chmod +x azure_metrics_exporter
sudo mv azure_metrics_exporter /usr/local/bin/azure_metrics_exporter
sudo mkdir -p /etc/azure_metrics_exporter
azure.yml File Configuration
To use Azure Metrics Exporter, an azure.yml configuration file is required that defines the target resources and metrics to collect. Select the services and metric items to collect, then download the configuration file and place it on the server where the Exporter is installed.
Supported Services List
The main supported services are listed below. Detailed metric definitions for each service can be found in the official Azure documentation. For additional services and metric definitions beyond the list below, refer to the Azure Monitor official documentation.
azure.yml Example File
# =============================================================================
# azure.yml example
# - credentials: authentication info (values collected in section 1.2)
# - targets: collect by directly specifying a resource
# - resource_groups: auto-discover by resource group + name regex
# - resource_tags: auto-discover by tag
# =============================================================================
credentials:
subscription_id: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
tenant_id: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
client_id: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
client_secret: "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
targets:
# (1) No aggregations specified: collects all supported (Total/Average/Minimum/Maximum)
- resource: /resourceGroups/example-rg/providers/Microsoft.DBforPostgreSQL/flexibleServers/myserver
metrics:
- name: cpu_percent
- name: memory_percent
# (2) Resource-level aggregation: applied as the default to all metrics in this target
- resource: /resourceGroups/example-rg/providers/Microsoft.DBforPostgreSQL/flexibleServers/myserver
aggregations:
- Average
metrics:
- name: cpu_percent
- name: memory_percent
# (3) Metric-level aggregation: per-metric override (overrides the resource-level value)
- resource: /resourceGroups/example-rg/providers/Microsoft.DBforPostgreSQL/flexibleServers/myserver
aggregations:
- Average # default for this target
metrics:
- name: cpu_percent # -> Average (default applied)
- name: memory_percent # -> Average (default applied)
- name: storage_percent
aggregations:
- Maximum # -> Maximum (overridden at metric level)
- name: iops
aggregations:
- Total
- Maximum # -> Total, Maximum
# Auto-discover by resource group + name regex
resource_groups:
- resource_group: "webapps"
resource_types:
- "Microsoft.Compute/virtualMachines"
resource_name_include_re:
- "testvm.*" # include VMs whose name starts with testvm
resource_name_exclude_re:
- "testvm12" # exclude testvm12
metrics:
- name: "CPU Credits Consumed"
aggregations:
- "Average"
# Auto-discover by tag (resources tagged monitoring=enabled)
resource_tags:
- resource_tag_name: "monitoring"
resource_tag_value: "enabled"
resource_types:
- "Microsoft.Compute/virtualMachines"
metrics:
- name: "CPU Credits Consumed"
aggregations:
- "Average"
- "Maximum"
Service Registration and Execution
Method A: Register as a systemd Service
sudo tee /etc/systemd/system/azure-metrics-exporter.service > /dev/null <<EOF
[Unit]
Description=Azure Metrics Exporter
After=network.target
[Service]
User=root
ExecStart=/usr/local/bin/azure_metrics_exporter --config.file=/etc/azure_metrics_exporter/azure.yml
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable azure-metrics-exporter
sudo systemctl start azure-metrics-exporter
sudo systemctl status azure-metrics-exporter
Method B: Run with nohup
nohup /usr/local/bin/azure_metrics_exporter \
--config.file=/etc/azure_metrics_exporter/azure.yml \
> /var/log/azure_metrics_exporter.log 2>&1 &
Verifying Metric Collection and Troubleshooting
# Check all metrics
curl http://localhost:9276/metrics
# Filter PostgreSQL metrics
curl http://localhost:9276/metrics | grep -i postgres
- Normal output example
# HELP azure_microsoft_dbforpostgresql_flexibleservers_cpu_percent_percent_average
# TYPE azure_microsoft_dbforpostgresql_flexibleservers_cpu_percent_percent_average gauge
azure_microsoft_dbforpostgresql_flexibleservers_cpu_percent_percent_average{...} 3.5
- Metric name conversion rule:
azure_{namespace}_{metric_name}_{unit}_{aggregation}
Troubleshooting
| Symptom | Cause | Resolution |
|---|---|---|
401 Unauthorized | Azure authentication failure | Verify credentials input values |
403 Forbidden | Insufficient permissions | Grant Monitoring Reader permission to the service principal |
| No metric values | Enhanced metrics disabled | Enable server parameters |
| Server stopped | DB is stopped | Run az postgres flexible-server start |
OpenAgent Download and Configuration
All files must be located in the same directory.
## Example
/opt/whatap/openagent/
├── openagent # Executable file
├── whatap.conf # Configuration file
└── scrape_config.yaml # Scraping configuration file
Navigate to Directory and Download Executable
mkdir -p /opt/whatap/openagent
cd /opt/whatap/openagent
## AMD64 (Intel/AMD 64-bit processor)
wget https://repo.whatap.io/openagent/latest/amd/openagent
## ARM64 (ARM processor in Linux environment)
## CAUTION: macOS Apple Silicon not supported
wget https://repo.whatap.io/openagent/latest/arm/openagent
Set Execution Permission
chmod +x openagent
Create scrape_config.yaml
When the scrape_config.yaml file is modified, OpenAgent automatically detects the changes and reloads the configuration. No separate restart is required.
#scrape_config.yaml
features:
openAgent:
enabled: true
targets:
- targetName: azure-monitor-exporter
type: StaticEndpoints
enabled: true
endpoints:
- address: "192.168.49.2:9276"
path: "/metrics"
scheme: "http"
interval: "30s"
metricRelabelConfigs:
- source_labels: [__name__]
regex: ".*"
action: keep
Basic Execution
./openagent standalone
Background Execution
nohup ./openagent standalone > /dev/null 2>&1 &
Check Logs
tail -f logs/whatap-boot-{yyyymmdd}.log
Process Management
# Check process
ps aux | grep openagent
# Terminate process
pkill openagent
StaticEndpoints Configuration Elements
- targetName: Name of the target (for identification)
- type: Target type ("StaticEndpoints")
- endpoints: Definition of endpoints to scrape
address: Target address to scrape (IP:PORT or HOSTNAME:PORT)path: Metrics path (default: /metrics)scheme: Scraping protocol (http or https, default: http)interval: Scraping interval (default: 60s)metricRelabelConfigs: Metric relabeling configuration after scraping
Using the params Feature
Using the params feature in OpenAgent allows you to add URL query parameters when scraping HTTP metrics.
params Configuration Format
endpoints:
- address: "192.168.49.2:30400"
path: "/metrics"
scheme: "http"
interval: "30s"
params:
subscription: ["50d91b57-a280-45b5-8d7c-be8005662738"]
resourceGroup: ["WhaTap-Data-KR-MID"]
target: ["/subscriptions/50d91b57-a280-45b5-8d7c-be8005662738/resourceGroups/WhaTap-Data-KR-MID/providers/Microsoft.Sql/managedInstances/openmetrics-instance-01"]
metric: ["avg_cpu_percent,virtual_core_count,memory_usage_percent"]
interval: ["PT1M"]
aggregation: ["average"]
Supported Parameter Value Types
- String: Single value
- String array: Multiple values joined by commas
- Other types: Automatically converted to string
Metric Relabeling Configuration (metricRelabelConfigs)
OpenAgent supports metric relabeling functionality similar to Prometheus metric_relabel_configs.
Relabeling Configuration Elements
- source_labels: List of source labels (array)
- separator: Separator used when joining source label values (default:
;) - target_label: Target label (label to store the result)
- regex: Regular expression applied to source label values
- replacement: Replacement value (can reference regex capture groups, e.g.,
${1}) - action: Action to perform (keep, drop, replace)
Supported Actions
- keep: Retain only metrics matching the regex
- drop: Remove metrics matching the regex
- replace: Replace the value of the target label with the replacement value
Special Labels
- name: Special label representing the metric name
Examples
1. Collect all metrics
metricRelabelConfigs:
- source_labels: [__name__]
regex: ".*"
action: keep
2. Retain only specific metrics
metricRelabelConfigs:
- source_labels: [__name__]
regex: "http_requests_total"
action: keep
This configuration retains only the http_requests_total metric and removes all others.
- Behavior example
# Original
http_requests_total{method="GET", status="200"} 100
http_errors_total{method="GET", status="500"} 5
node_cpu_seconds_total{cpu="0", mode="idle"} 1000
# After applying
http_requests_total{method="GET", status="200"} 100
3. Metric filtering using regex
metricRelabelConfigs:
- source_labels: [__name__]
regex: "node_(cpu|memory).*"
action: keep
4. Rename a label
metricRelabelConfigs:
- source_labels: [method]
target_label: http_method
replacement: "${1}"
action: replace
5. Combine multiple source labels
metricRelabelConfigs:
- source_labels: [__name__, status]
regex: "http_requests_total;(200|500)"
action: keep
6. Add a static label
metricRelabelConfigs:
- target_label: metric_src
replacement: "whatap-open-agent"
action: replace
Comprehensive behavior example
Assume the originally scraped metrics are as follows:
apiserver_request_total{code="200", resource="pods", verb="GET"} 100
some_other_metric{label="value"} 50
- Apply first rule (keep apiserver_request_total): retain
apiserver_request_total, dropsome_other_metric - Apply second rule (replace verb → http_verb): copy the
verblabel value to thehttp_verblabel
- Final collected metrics
apiserver_request_total{code="200", resource="pods", verb="GET", http_verb="GET"} 100