Work in progress
Azure metrics exporter for Prometheus.
Allows for the exporting of metrics from Azure applications using the Azure monitor API.
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.
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.
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.
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']
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.