Skip to content
Azure metrics exporter for Prometheus
Branch: master
Clone or download
vincentcreusotfx and brian-brazil Release/list by tag (#53)
Co-Authored-By: vincentcreusotfx <>
Latest commit 4411b47 Apr 16, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
config Release/list by tag (#53) Apr 15, 2019
vendor Build improvements (#4) Apr 9, 2018
.gitignore Make the Dockerfile suitable for Docker Hub automatic builds (#28) Oct 11, 2018
.promu.yml Make the Dockerfile suitable for Docker Hub automatic builds (#28) Oct 11, 2018
.travis.yml Build improvements (#4) Apr 9, 2018
Dockerfile Make the Dockerfile suitable for Docker Hub automatic builds (#28) Oct 11, 2018
Makefile Make the Dockerfile suitable for Docker Hub automatic builds (#28) Oct 11, 2018 Release/list by tag (#53) Apr 15, 2019
azure-example.yml Azure endpoints from config (#54) Apr 12, 2019
azure.go Release/list by tag (#53) Apr 15, 2019
main.go Release/list by tag (#53) Apr 15, 2019
utils.go Add additional label to fix SQL database scrap issue (#44) Apr 3, 2019


Azure metrics exporter for Prometheus.

Allows for the exporting of metrics from Azure applications using the Azure monitor API.


go get -u


./azure_metrics_exporter --help

Rate limits

Note that Azure imposes an API read limit of 15,000 requests per hour so the number of metrics you're querying for should be proportional to your scrape interval.

Retrieving Metric definitions

In order to get all the metric definitions for the resources specified in your configuration file, run the following:

./azure-metrics-exporter --list.definitions

This will print your resource id's application/service name along with a list of each of the available metric definitions that you can query for for that resource.

Exporter configuration

This exporter requires a configuration file. By default, it will look for the azure.yml file in the CWD.

Azure account requirements

This exporter reads metrics from an existing Azure subscription with these requirements:

  • An application must be registered (e.g., Azure Active Directory -> App registrations -> New application registration)
  • The registered application must have reading permission to Azure Monitor (e.g., Subscriptions -> your_subscription -> Access control (IAM) -> Role assignments -> Add -> Add role assignment -> Role : "Monitoring Reader", Select: my_app)

Example azure-metrics-exporter config

azure_resource_id and subscription_id can be found under properties in the Azure portal for your application/service.

azure_resource_id should start with /resourceGroups... (/subscriptions/xxxxxxxx-xxxx-xxxx-xxx-xxxxxxxxx must be removed from the begining of azure_resource_id property value)

tenant_id is found under Azure Active Directory > Properties and is listed as Directory ID.

The client_id and client_secret are obtained by registering an application under 'Azure Active Directory'.

client_id is the application_id of your application and the client_secret is generated by selecting your application/service under Azure Active Directory, selecting 'keys', and generating a new key.

If you want to scrape metrics from Azure national clouds (e.g. AzureChinaCloud, AzureGermanCloud), you should provide active_directory_authority_url and resource_manager_url parameters. active_directory_authority_url is AzureAD url for getting access token. resource_manager_url is Azure API management url. If you won't provide active_directory_authority_url and resource_manager_url parameters, azure-metrics-exporter scrapes metrics from global cloud. You can find endpoints for national clouds here

active_directory_authority_url: ""
resource_manager_url: ""
  subscription_id: <secret>
  client_id: <secret>
  client_secret: <secret>
  tenant_id: <secret>

  - resource: "azure_resource_id"
    - name: "BytesReceived"
    - name: "BytesSent"
  - resource: "azure_resource_id"
    - Minimum
    - Maximum
    - Average
    - name: "Http2xx"
    - name: "Http5xx"

  - resource_group: "webapps"
    - "Microsoft.Compute/virtualMachines"
    - "testvm.*"
    - "testvm12"
    - name: "CPU Credits Consumed"

  - resource_tag_name: "group"
    resource_tag_value: "tomonitor"
    - name: "CPU Credits Consumed"

By default, all aggregations are returned (Total, Maximum, Average, Minimum). It can be overridden per resource.

Resource group filtering

Resources in a resource group can be filtered using the the following keys:

resource_types: List of resource types to include (corresponds to the Resource type column in the Azure portal).

resource_name_include_re: List of regexps that is matched against the resource name. Metrics of all matched resources are exported (defaults to include all)

resource_name_exclude_re: List of regexps that is matched against the resource name. Metrics of all matched resources are ignored (defaults to exclude none) Excludes take precedence over the include filter.

Resource tag filtering

Resources having a specific tag name and tag value can be filtered:

resource_tag_name: Name of the tag to be filtered against.

resource_tag_value: Value of the tag to be filtered against.

Prometheus configuration

Example config

  scrape_interval:     60s # Set a high scrape_interval either globally or per-job to avoid hitting Azure Monitor API limits.

  - job_name: azure
      - targets: ['localhost:9276']
You can’t perform that action at this time.