# Resources usage

This page shows you how to get started using the resources usage mediarithmics API.

Each datamart resource (segments, exports, imports...) that lead to write or read access on mediarithmics platform are tracked and their consumption are measured.

Thanks to this API you can get a report of your datamart consumption that match:&#x20;

* the cost of each query executed on the platform
* the amount of data ingested

This API is a mediarithmics [Data cube](/resources/data-cubes.md) and works similarly as [Activities analytics queries API](/querying-your-data/activities-analytics-queries.md).&#x20;

## Quickstart

<mark style="color:green;">`POST`</mark> `https://api.mediarithmics.com/v1/platform_monitoring/resources_usage`

#### Request Body

| Name                                                         | Type                            | Description                                                                                                                                              |
| ------------------------------------------------------------ | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| metrics<mark style="color:red;">\*</mark>                    | array                           | Array of [Metric](/resources/data-cubes/reference.md#metric) to retrieve.                                                                                |
| dimension\_filter\_clauses<mark style="color:red;">\*</mark> | object                          | Filters to apply on dimensions before calculating the metric. For more information, see [FilterClause](/resources/data-cubes/reference.md#filterclause). |
| dimensions<mark style="color:red;">\*</mark>                 | Dimensions to group metrics by. | [Dimensions](/resources/data-cubes/reference.md#dimension) to group metrics by.                                                                          |
| date\_ranges<mark style="color:red;">\*</mark>               | array                           | Periods to analyze. Each date range is an object with a `start_date` and an `end_date`. See [DateRange](/resources/data-cubes/reference.md#daterange).   |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{
    "status": "ok",
    "data": {
        "report_view": {
            "items_per_page": 100,
            "total_items": 7,
            "columns_headers": [
                "date_time",
                "datamart_id",
                "collection",
                "count"
            ],
            "rows": [
                [
                    1637931755000,
                    9999,
                    "USER_POINT",
                    100
                ],
                [
                    1637931755100,
                    9999,
                    "USER_EVENT",
                    50
                ]
            ]
        }
    }
}
```

{% endtab %}
{% endtabs %}

Here is a sample body payload with all the important properties:

```
{
    // Retrieve the data in the specified date range
    // Mandatory
    "date_ranges": [
        {
            "start_date": "2021-10-10T00:00:00",
            "end_date": "2021-10-25T23:59:59"
        }
    ],
    // List of dimensions to retrieve
    "dimensions": [
        {
            "name": "date_time"
        },
        {
            "name": "community_id"
        },
        {
            "name": "source"
        }, 
        {
            "name": "scan_cost"
        }
    ],
    // Filters on dimensions
    "dimension_filter_clauses": {
        "operator": "AND",
        "filters": [
            {
                "dimension_name": "community_id",
                "operator": "EXACT",
                "expressions": [
                    100
                ]
            }
        ]
    },
    // List of metrics to retrieve
    "metrics": [
        {
            "expression": "scan_cost"
        }
    ]
}
```

## Retention

These aggregated stats are kept for two years.

## Supported dimensions and metrics

See [Dimensions and metrics](/advanced-usages/platform-monitoring/collection-volumes/dimensions-and-metrics.md) for the complete list of supported dimensions and metrics.

## Learning more about data cubes

This endpoint is a mediarithmics [Data cube](/resources/data-cubes.md). You can find documentation on how data cubes work and which data cubes are available in the specific documentation section.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.mediarithmics.io/advanced-usages/platform-monitoring/usage-reports.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
