Azure Extension

The Azure extension enables pulling cost data from Azure Cost Management in Grainite applications.

Setup

In order to be able to use the Azure extension, first include it as a dependency in your application's pom.xml file.

...
<dependency>
  <groupId>ext.grainite</groupId>
  <artifactId>grainite-azure</artifactId>
  <version>{GRAINITE-VERSION}</version>
</dependency>
...

Replace {GRAINITE-VERSION} with the version of Grainite you are also using for libgrainite (the Grainite Client library for Java).

Contents

The Azure Extension includes:

  • CostDetailsReportTask: Task that continuously polls Azure Cost Management to get cost details for various resources.

CostDetailsReportsTask

Usage

To include this task in your application, you must specify the taskClass ext.grainite.tasks.azure.CostDetailsReportsTask and taskInstanceClass ext.grainite.tasks.azure.CostDetailsReportsInstance in your application's configuration YAML file.

app.yaml
...
tasks:
  - task_name: my_azure_cost_task
    taskClass: ext.grainite.tasks.azure.CostDetailsReportsTask
    taskInstanceClass: ext.grainite.tasks.azure.CostDetailsReportsInstance
    config:
...

Below are the configuration options that can be passed in under config:

PropertyRequired?ValueDescription

subscriptionId

REQUIRED

Example: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Azure Subscription ID to query

tenantId

REQUIRED

Example: yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy

Azure Tenant ID to query

clientId

REQUIRED

Example: zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz

Azure Client ID to use (obtained with a service principal)

clientSecret

REQUIRED

Example: nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn

Azure Client Secret to use

numDaysToScan

Optional

Example: 14 Default: 8

Number of days in the past to poll the data for. Azure allows a max of 30.

keyFields

Optional

Default: SubscriptionId, resourceGroupName

Comma-separated list of fields in the payload that form the (compound) key for the event to be emitted.

output.topic

Optional

Example: cost_events

Grainite topic to emit output of this task to

output.table

Optional

Example: cost_table

Grainite table to emit output of this task to via Grain message (output.table_action must also be provided)

output.table_action

Optional

Example: cost_table_action

Given action to invoke via Grain Message to the table specified in output.table

Azure is a trademark of Microsoft Corporation.

Last updated