Generate usage attribution reports
By attributing usage to teams, services, departments, or systems, you can gain insight into how resources are being used and create usage budgets to manage costs more efficiently. Importantly, the accountability of cost reduction becomes shared, rather than solely the responsibility of a centralized business unit. With this usage and cost visibility, for example, the Finance team can generate reports for monthly financial analysis.
In managing usage costs, you can implement chargebacks, where it is feasible for teams or departments to pay for their own usage. In cases where there is no dedicated budget for usage at a team level, you can create showbacks to provide usage visibility, which helps to raise awareness of how much money is being spent, even if a particular team or department does not directly pay for their costs.
Note
Usage attribution reports are currently available for metrics only. Metrics usage-attributions are based on your monthly billable usage, and are not generated for shorter intervals.
To understand Metrics attribution, there are key underlying concepts:
- Active series ; for detailed information, refer to Active series.
- Data points per minute (DPM) ; for more information, refer to Data points per minute (DPM) and Reduce metrics costs by adjusting your data points per minute (DPM).
- Billable series, which are derived from both active series and DPM. For more information, refer to Billing calculations.
You can also break down previously billed months by metric labels, for historical usage attributions.
Identify labels to appear on the report
The label names by which you choose to attribute usage depend on your use-case. There is no need to specify the label values, all the values available for the selected labels appear in the report.
Manage costs via chargebacks or showbacks
In this case, pick a label name where each label value represents ownership by a single billing center, whether that’s a division, team, squad, or similar. For example:
namespace
app
,application
, orservice
<CLOUD-PROVIDER-ACCOUNT-ID>_account_id
or_account
Perform financial analysis or create a report
To understand your cost of goods sold (COGS), and the breakdown between fixed and variable costs, you need to attribute costs to production versus non-production environments.
For example:
environment
orenv
cluster
Examples of other analyses, such as customer, product lines, region, or cloud provider, are as follows:
region
orlocation
cloud
Identify the best labels to use from your metrics
Go to Home > Dashboards > GrafanaCloud.
Search for the Cardinality management - 3 - labels dashboard.
At the top of the dashboard in the Label field, search the available labels.
Select a label to see data about that label.
For example:
- The count of total values.
- The percentage of total series with that label.
- The values that occur most often and their distribution.
- A list of the highest-cardinality metrics for each value.
In some cases you don’t know which label to use, or you have multiple candidates with similar names. For example you might have all of
app
,appid
,app_id
, orapplication
present on your metrics.Pick the best option based on the following criteria:
- A high percentage of total series
- A distribution which is:
- More than one label value. Value-count could be anything between two to tens, or a few hundred.
- A somewhat flat distribution.
Configure a usage report
When you first configure a report, contact Customer Support who sets up generation of it for the past three billing months.
Provide the following information in your support ticket:
- Label names to include in the usage attribution report; refer to Identify the best labels to use from your metrics.
TENANT
Hosted-Prometheus instance ID
View the usage attribution report
You can view all available monthly usage attribution reports via the attributions
HTTP API endpoint.
Note
Currently, this API only has one endpoint.
Before you begin:
To interact with the API, gather the following information:
URL
: In the formhttps://insights-<STACK ZONE>.grafana.net/
. To find your Grafana Cloud Stack’s zone, go to your Grafana Cloud account. Check the Details of your stack, then the Details page of your hosted Grafana. Take the hyphenated slug only. For example, if the Grafana instance shows “Grafana Cloud cluster / region: US Central - us - prod-us-central-0” then useprod-us-central-0
for theSTACK ZONE
.TENANT
: The numeric instance ID where you want to fetch usage attribution reports. To find yourTENANT
value, go to your Grafana Cloud account and check the Details page of your hosted Prometheus endpoint for Username / Instance ID.TOKEN
: A token from a Grafana Cloud Access Policy, make sure the access policy hasmetrics:read
scope for the stack ID where you want to fetch usage attribution reports.Accept
: Eithertext/csv
orapplication/json
Example request (CSV):
curl -u "$TENANT:$TOKEN" --header "Accept: text/csv" "$URL/usage/v0/attributions/$TENANT"
Example response:
label_job,label_probe,Month(ISO),BillableSeries,_InstanceID,_OrgID,_HasDpmPerSeriesLargerThanIncluded,_P95Time,_SumOfAttributions,_BillableSeriesAtP95Time,_BillableSeriesBilled
job_1,Atlanta,2023-12,163,12345,123,false,2023-12-07 03:16:04.246 +0000 UTC,376,416,402
job_1,NewYork,2023-12,163,12345,123,false,2023-12-07 03:16:04.246 +0000 UTC,376,416,402
job_2,Atlanta,2023-12,25,12345,123,false,2023-12-07 03:16:04.246 +0000 UTC,376,416,402
job_2,NewYork,2023-12,25,12345,123,false,2023-12-07 03:16:04.246 +0000 UTC,376,416,402
job_1,Atlanta,2023-11,163,12345,123,false,2023-11-18 02:33:04.246 +0000 UTC,564,578,570
job_1,NewYork,2023-11,325,12345,123,false,2023-11-18 02:33:04.246 +0000 UTC,564,578,570
job_2,Atlanta,2023-11,25,12345,123,false,2023-11-18 02:33:04.246 +0000 UTC,564,578,570
job_2,NewYork,2023-11,51,12345,123,false,2023-11-18 02:33:04.246 +0000 UTC,564,578,570
Example request (JSON):
curl -u "$TENANT:$TOKEN" --header "Accept: application/json" "$URL/usage/v0/attributions/$TENANT"
Example response:
{
"HasDpmPerSeriesLargerThanIncluded": true,
"P95Time": "2023-10-28T22:41:04.246Z",
"Attributions": [
{
"LabelSet": {
"probe": "Atlanta"
},
"Count": 170
},
{
"LabelSet": {
"probe": "NewYork"
},
"Count": 163
},
{
"LabelSet": {
"probe": "Paris"
},
"Count": 51
},
{
"LabelSet": {
"probe": "Tokyo"
},
"Count": 25
}
],
"SumOfAttributions": 409,
"BillableSeriesAtP95Time": 409,
"BillableSeriesBilled": 409,
"attributionLabels": ["probe"],
"year": 2023,
"month": 10,
"instanceId": 478823,
"orgID": 123
}
Edit an existing report
You can specify a new set of labels for the report by contacting Customer Support. Refer to Configure a usage report.