Skip to main content

Azure Monitor Exporter Configuration

Caution

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.

PermissionDescriptionScope
Monitoring ReaderRead access for Azure Monitor metricsSubscription or Resource Group
ReaderResource information lookup (for service discovery)Subscription or Resource Group
Note

Recommended Configuration

  • Use the Monitoring Reader role 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.

ItemDescriptionExample
Subscription IDAzure subscription identifierxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Tenant IDAzure AD tenant identifierxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Client IDApplication ID of the registered appxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Client SecretSecret key for app authenticationxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Resource GroupResource group namexxxxxxxxxx
Resource NameResource 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

Tip

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.

ServiceAzure Docs
Microsoft.Compute virtualMachineshttps://learn.microsoft.com/en-us/azure/azure-monitor/reference/supported-metrics/microsoft-compute-virtualmachines-metrics
Microsoft.ContainerService managedClustershttps://learn.microsoft.com/en-us/azure/aks/monitor-aks-reference
Microsoft.Storage storageAccountshttps://learn.microsoft.com/en-us/azure/azure-monitor/reference/supported-metrics/microsoft-storage-storageaccounts-metrics
Microsoft.Sql servers databaseshttps://learn.microsoft.com/en-us/azure/azure-sql/database/monitoring-sql-database-azure-monitor-reference
Microsoft.DBforPostgreSQL flexibleServershttps://learn.microsoft.com/en-us/azure/postgresql/flexible-server/concepts-monitoring
Microsoft.DBforMySQL flexibleServershttps://learn.microsoft.com/en-us/azure/mysql/flexible-server/concepts-monitoring
Microsoft.DocumentDB databaseAccountshttps://learn.microsoft.com/en-us/azure/cosmos-db/monitor-cosmos-db
Microsoft.Cache redishttps://learn.microsoft.com/en-us/azure/redis/monitor-cache
Microsoft.EventHub namespaceshttps://learn.microsoft.com/en-us/azure/event-hubs/monitor-event-hubs-reference
Microsoft.ServiceBus namespaceshttps://learn.microsoft.com/en-us/azure/service-bus-messaging/monitor-service-bus-reference
Microsoft.KeyVault vaultshttps://learn.microsoft.com/en-us/azure/key-vault/general/monitor-key-vault
Microsoft.Network applicationGatewayshttps://learn.microsoft.com/en-us/azure/application-gateway/monitor-application-gateway

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

SymptomCauseResolution
401 UnauthorizedAzure authentication failureVerify credentials input values
403 ForbiddenInsufficient permissionsGrant Monitoring Reader permission to the service principal
No metric valuesEnhanced metrics disabledEnable server parameters
Server stoppedDB is stoppedRun 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
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
  1. Apply first rule (keep apiserver_request_total): retain apiserver_request_total, drop some_other_metric
  2. Apply second rule (replace verb → http_verb): copy the verb label value to the http_verb label
  • Final collected metrics
apiserver_request_total{code="200", resource="pods", verb="GET", http_verb="GET"} 100