or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

aggregated-cost.mdbudget-management.mdclient-management.mdcost-analysis.mdcredits-billing.mdindex.mdoperations.mdreservation-management.mdtags-operations.mdusage-analytics.md

usage-analytics.mddocs/

0

# Usage and Analytics

1

2

Access detailed usage information, marketplace transactions, and consumption analytics for Azure resources. This module provides comprehensive usage reporting across various scopes and time periods.

3

4

## Capabilities

5

6

### Usage Details

7

8

Retrieve detailed usage information for Azure resources including cost, usage quantities, and metadata.

9

10

```python { .api }

11

def list(

12

scope: str,

13

expand: str = None,

14

filter: str = None,

15

skiptoken: str = None,

16

top: int = None,

17

metric: str = None,

18

**kwargs

19

) -> Iterable[UsageDetailsListResult]:

20

"""

21

List usage details for the defined scope.

22

23

Parameters:

24

- scope: The scope for the usage details query (str)

25

- expand: May be 'additionalInfo' or 'meterDetails' (str, optional)

26

- filter: OData filter expression for the data (str, optional)

27

- skiptoken: Token for pagination (str, optional)

28

- top: Maximum number of items to return (int, optional)

29

- metric: Type of metric to retrieve (str, optional)

30

31

Returns:

32

Iterable[UsageDetailsListResult]: Usage details collection

33

"""

34

```

35

36

**Usage Example:**

37

38

```python

39

# Get usage details for subscription

40

scope = f"/subscriptions/{subscription_id}"

41

usage_details = client.usage_details.list(

42

scope=scope,

43

expand="meterDetails",

44

top=100

45

)

46

47

for usage in usage_details:

48

print(f"Resource: {usage.instance_name}")

49

print(f"Cost: {usage.cost} {usage.billing_currency}")

50

print(f"Date: {usage.date}")

51

print(f"Meter: {usage.meter_details.meter_name}")

52

53

# Filter usage by date range

54

filter_expr = "properties/usageStart ge '2024-01-01' and properties/usageEnd le '2024-01-31'"

55

january_usage = client.usage_details.list(

56

scope=scope,

57

filter=filter_expr

58

)

59

```

60

61

### Marketplace Transactions

62

63

Access marketplace usage data for third-party and marketplace services on Azure.

64

65

```python { .api }

66

def list(

67

scope: str,

68

filter: str = None,

69

top: int = None,

70

skiptoken: str = None,

71

**kwargs

72

) -> Iterable[MarketplacesListResult]:

73

"""

74

List marketplace charges for the specified scope.

75

76

Parameters:

77

- scope: The scope for the marketplace query (str)

78

- filter: OData filter expression (str, optional)

79

- top: Maximum number of items to return (int, optional)

80

- skiptoken: Token for pagination (str, optional)

81

82

Returns:

83

Iterable[MarketplacesListResult]: Marketplace transactions collection

84

"""

85

```

86

87

**Usage Example:**

88

89

```python

90

# Get marketplace usage

91

marketplace_usage = client.marketplaces.list(

92

scope=f"/subscriptions/{subscription_id}",

93

top=50

94

)

95

96

for marketplace in marketplace_usage:

97

print(f"Publisher: {marketplace.publisher_name}")

98

print(f"Service: {marketplace.offer_name}")

99

print(f"Cost: {marketplace.cost_in_billing_currency}")

100

print(f"Billing Period: {marketplace.billing_period_name}")

101

```

102

103

### Tags Analysis

104

105

Analyze cost allocation and usage patterns by resource tags.

106

107

```python { .api }

108

def get(scope: str, **kwargs) -> Optional[TagsResult]:

109

"""

110

Get all available tag keys for the defined scope.

111

112

Parameters:

113

- scope: The scope for the tags query (str)

114

115

Returns:

116

TagsResult: Collection of available tag keys

117

"""

118

```

119

120

**Usage Example:**

121

122

```python

123

# Get available tags for cost analysis

124

tags_result = client.tags.get(scope=f"/subscriptions/{subscription_id}")

125

126

if tags_result and tags_result.tags:

127

print("Available tags for cost allocation:")

128

for tag in tags_result.tags:

129

print(f"- {tag.key}: {len(tag.values)} values")

130

```

131

132

## Types

133

134

### Usage Detail Models

135

136

```python { .api }

137

class UsageDetail:

138

"""Base class for usage detail information."""

139

billing_account_id: str

140

billing_account_name: str

141

billing_period_start_date: datetime

142

billing_period_end_date: datetime

143

billing_profile_id: str

144

billing_profile_name: str

145

account_owner_id: str

146

account_name: str

147

subscription_id: str

148

subscription_name: str

149

date: datetime

150

product: str

151

part_number: str

152

meter_id: str

153

meter_details: MeterDetails

154

quantity: float

155

effective_price: float

156

cost: float

157

unit_price: float

158

billing_currency: str

159

resource_location: str

160

consumed_service: str

161

resource_id: str

162

resource_name: str

163

service_info1: str

164

service_info2: str

165

additional_info: str

166

invoice_section: str

167

cost_center: str

168

resource_group: str

169

reservation_id: str

170

reservation_name: str

171

product_order_id: str

172

product_order_name: str

173

offer_id: str

174

is_azure_credit_eligible: bool

175

term: str

176

publisher_name: str

177

publisher_type: str

178

plan_name: str

179

charge_type: str

180

frequency: str

181

182

class LegacyUsageDetail(UsageDetail):

183

"""Legacy usage detail format."""

184

instance_name: str

185

instance_id: str

186

instance_location: str

187

currency: str

188

usage_start: datetime

189

usage_end: datetime

190

191

class ModernUsageDetail(UsageDetail):

192

"""Modern usage detail format."""

193

cost_in_billing_currency: float

194

cost_in_usd: float

195

exchange_rate_pricing_to_billing: float

196

exchange_rate_date: datetime

197

invoice_id: str

198

previous_invoice_id: str

199

pricing_currency: str

200

service_period_start_date: datetime

201

service_period_end_date: datetime

202

```

203

204

### Marketplace Models

205

206

```python { .api }

207

class Marketplace:

208

"""Marketplace usage information."""

209

billing_period_name: str

210

cost_in_billing_currency: float

211

cost_in_usd: float

212

subscription_guid: str

213

subscription_name: str

214

meter_id: str

215

meter_name: str

216

meter_category: str

217

meter_subcategory: str

218

meter_region: str

219

unit_of_measure: str

220

instance_name: str

221

instance_id: str

222

instance_location: str

223

currency: str

224

consumed_quantity: float

225

resource_rate: float

226

offer_name: str

227

resource_group: str

228

order_number: str

229

additional_properties: dict

230

consumed_service: str

231

service_info1: str

232

service_info2: str

233

tags: dict

234

publisher_name: str

235

plan_name: str

236

is_recurring_charge: bool

237

```

238

239

### Tag Models

240

241

```python { .api }

242

class Tag:

243

"""Tag information for cost allocation."""

244

key: str

245

values: List[str]

246

247

class TagsResult:

248

"""Collection of available tag keys."""

249

tags: List[Tag]

250

next_link: str

251

```

252

253

### Meter Detail Models

254

255

```python { .api }

256

class MeterDetails:

257

"""Detailed meter information."""

258

meter_name: str

259

meter_category: str

260

meter_subcategory: str

261

unit_of_measure: str

262

service_name: str

263

service_tier: str

264

meter_location: str

265

total_included_quantity: float

266

pre_tax_standard_rate: float

267

268

class MeterDetailsResponse:

269

"""Response containing meter details."""

270

meter_details: List[MeterDetails]

271

```

272

273

### List Result Models

274

275

```python { .api }

276

class UsageDetailsListResult:

277

"""Container for usage details list response."""

278

value: List[UsageDetail]

279

next_link: str

280

281

class MarketplacesListResult:

282

"""Container for marketplace list response."""

283

value: List[Marketplace]

284

next_link: str

285

```

286

287

### Enumeration Types

288

289

```python { .api }

290

class Metrictype:

291

"""Metric types for usage queries."""

292

ACTUAL_COST = "ActualCost"

293

AMORTIZED_COST = "AmortizedCost"

294

USAGE = "Usage"

295

296

class UsageDetailsKind:

297

"""Usage detail format types."""

298

LEGACY = "legacy"

299

MODERN = "modern"

300

```