This dashboard is only available to users with a premium license. Please
contact us to get access to Lago Cloud and Lago
Self-Hosted Premium.
Invoiced usage represents the quantified value of consumption-based metrics that have been formally invoiced.
This usage can encompass a wide spectrum, including both metered and recurring usage-based metrics.
It doesn’t matter whether these charges are settled in advance or in arrears, or whether they involve proration.
It’s important to note that usage for the current month is not factored into this calculation.
This omission is due to the inherent uncertainty of current consumption, which hasn’t yet been formalized through
invoicing processes.
To access the invoiced usage analytics dashboard:
Navigate to the “Analytics” section; and
Access the “Invoiced usage” Dashboard.
Invoiced usage dashboard
To access the invoiced usage analytics dashboard:
Navigate to the “Analytics” section; and
Access the “Invoiced usage” Dashboard.
Invoiced usage dashboard
LAGO_URL="https://api.getlago.com"API_KEY="__YOUR_API_KEY__"curl--location--request GET "$LAGO_URL/api/v1/analytics/invoiced_usage?currency=USD"\--header"Authorization: Bearer $API_KEY"\--header'Content-Type: application/json'\
The generated amounts are in cents, making it compatible with different currencies.
-- Get creation date of the organizationWITH organization_creation_date AS(SELECT DATE_TRUNC('month', o.created_at)AS start_monthFROM organizations oWHERE o.id ='__YOUR_ORGANIZATION_ID__'),-- Generate a series of future months all_months AS(SELECT generate_series((SELECT start_month FROM organization_creation_date), DATE_TRUNC('month',CURRENT_DATE+INTERVAL'10 years'),interval'1 month')ASmonth),-- Get revenue for all usage-based fees (charge type) usage_fees AS(SELECT f.charge_id, f.amount_cents::float, f.amount_currency AS currency, f.created_at AS fee_created_atFROM fees fLEFTJOIN subscriptions s ON s.id = f.subscription_idLEFTJOIN customers c ON c.id = s.customer_idWHERE f.invoiceable_type ='Charge'AND f.fee_type =0AND c.organization_id ='__YOUR_ORGANIZATION_ID__'),-- Get total revenue for all billable metrics total_revenue_per_bm AS(SELECT DATE_TRUNC('month', uf.fee_created_at)ASmonth, bm.code, uf.currency,COALESCE(SUM(amount_cents),0)AS amount_centsFROM usage_fees ufLEFTJOIN charges c ON c.id = uf.charge_idLEFTJOIN billable_metrics bm ON bm.id = c.billable_metric_idGROUPBYmonth, code, currencyORDERBYmonth)-- Select the desired resultsSELECT am.month, trpmb.code, trpmb.currency, trpmb.amount_centsFROM all_months AS amLEFTJOIN total_revenue_per_bm trpmb ON trpmb.month= am.monthWHERE am.month<= DATE_TRUNC('month',CURRENT_DATE)AND trpmb.currency ISNOTNULLAND trpmb.amount_cents ISNOTNULLORDERBY am.monthDESC, trpmb.amount_cents DESC;