Skip to content

credativ/azure_metrics_exporter

 
 

Repository files navigation

Azure-metrics-exporter

Work in progress

Azure metrics exporter for Prometheus.

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

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.

Example azure-metrics-exporter config

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

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.

To grant the application access to the resource group, navigate to the resource group > Access control (IAM) > Add. Select the application by entering its name and assign it to the Monitoring Reader role.

credentials:
  subscription_id: <secret>
  client_id: <secret>
  client_secret: <secret>
  tenant_id: <secret>

resources:
  - name: "/resourceGroups/blog-group/providers/Microsoft.Web/sites/blog"
    metrics:
      - "BytesReceived"
      - "BytesSent"
    aggregations:
      - "Average"
  - name: "/resourceGroups/app-group/providers/Microsoft.Web/sites/app"
    metrics:
      - "Http2xx"
      - "Http5xx"

resource_groups:
  - name: "webapps"
    resource_types:
      - "Microsoft.Compute/virtualMachines"
    resource_include:
      - "^testvm"
    resource_exclude:
      - "^testvm12$"
    metrics:
      - "CPU Credits Consumed"
    aggregations:
      - "Average"

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

Example Prometheus config

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

scrape_configs:
  - job_name: azure
    static_configs:
      - targets: ['localhost:9276']

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_include: List of regexps that is matched against the resource name. Metrics of all matched resources are exported (defaults to include all)

resource_exclude: 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.

About

Azure metrics exporter for Prometheus

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 91.8%
  • Makefile 7.5%
  • Dockerfile 0.7%