treebee / azure-cost-mon

Prometheus exporter for the Azure billing API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status Coverage Status PyPI version

ACE azure-costs-exporter

Prometheus exporter for the Microsoft Azure billing API. Check out this blog post for more background about the idea and some nice screenshots.

Description

azure-costs-exporter is a web app, that is intended to be called by Prometheus to export billing information from Azure. It will then return the available metrics in Prometheus compatible format.

The billing API in use is part of the "Enterprise Agreement (EA)" Portal. Hence, it is not available for pay-as-you-go subscriptions. The configuration requires an active EA with Microsoft.

Configuration

You need to create an application.cfg file with the following content:

ENROLLMENT_NUMBER="123456"
BILLING_API_ACCESS_KEY="XXX"
PROMETHEUS_METRIC_NAME="my_metric_name"
  • ENROLLMENT_NUMBER is the unique ID that identifies a particular EA.
  • The BILLING_API_ACCESS_KEY can be created in the EA portal to gain access to the billing API. Navigate to "Reports > Download Usage" and generate an API Access Key.
  • PROMETHEUS_METRIC_NAME is the name of the time series that will be generated in Prometheus.

Deployment

E.g. via gunicorn. In an activated virtualenv, you can do:

pip install azure-costs-exporter gunicorn
cp /path/to/application.cfg .
gunicorn azure_costs_exporter:app

Tests

The used python testing tool is pytest. To run the tests:

mkvirtualenv billing
pip install -r requirements_dev.txt
pip install -e .
py.test

About

Prometheus exporter for the Azure billing API

License:MIT License


Languages

Language:Python 100.0%