Skip to content

Filtering

When querying using the lists endpoints - POST/api/consumptionlog/log/list and POST/api/consumptionlog/log/my-list - there are multiple options that can optionally be used to filter the results for the logs that are retrieved.

The filter options are:

  • from: Will retrieve logs with a ValidFrom that is greater than this date
  • to: Will retrieve logs with a ValidTo that is less than this date
  • projectId: Retrieves from a specific project
  • operationId: Retrieves for a particular operation
  • metricType: Only retrieves for a particular metric, i.e. StorageUsage, ComputeTime, and TotalStorageUsage
  • resourceId: Retrieves for a particular resource, e.g. compute.azure.VM-S-5 and storage.azure.multidimensional-HotStorage
  • billingReference: Retrieves for a particular billing reference.
  • billingReferenceTag: Retrieves all logs with the specified tag

Aggregation

On top of the filter options above deciding which logs gets retrieved there are some aggregation options that can be used to aggregate the data across various attributes.

This is represented in the body of the query as follows with the possible values indicated in the values and separated by | when there are more than one:

{
  ...,
  "aggregateBy": {
    "Time": "all|day",
    "ProjectId": "all",
    "ResourceId": "all",
    "OperationId": "all",
    "BillingReference": "all|billingReference|tag"
  },
  ...
}
Here all means that the attribute will be fully aggregated and will appear in the output with a null value.

For Time day means that daily aggregations will be returned.

Finally billing reference can be aggregated both by the actual reference as well as the tag attached to it.

Sorting

Sorting is also available for a single attribute and can be done both ascending and descending. It is represented by two fields in the body of the request:

{
  ...,
  "sortBy": "Id|TenantId|ProjectId|MetricType|OperationId|ValidFrom|ValidTo|Value",
  "sortOrder": "Asc|Desc",
  ...
}

Paging

Finally you can get the results paged, as you can set the properties offset and limit, where limit sets how many results are returned while offset sets where in the list the query starts.