Introducing the Chargebee CLI

Defining Metered Features

Introduction

Features help you define the various aspects offered as part of your product line. Metered features, which can be considered as your value metrics, allow you to track and bill customers based on the actual usage of these specific aspects of your product or service. You define the included usage of a metered feature with plans or non-metered addons, and bill customers for usage beyond it through metered addons.

A metered feature is one of the two kinds of features in Chargebee. Use a non-metered feature when your application manages access and entitlement provisioning, Chargebee is the source of truth for the entitlements, and usage doesn't change the invoice. To compare the two, see Metered and non-metered features in Chargebee.

Let's consider a SaaS business, offering two plans as follows, with respective features and pricing:

Regular PlanPremium Plan
$30 per month for 3 users$50 per month for 3 users
$15 per month for every additional user$20 per month for every additional user
Limited access to applicationUnlimited access to application
15 hours of free on-call support40 hours of free on-call support

For the above use case, metered features can be created to track the number of users signing up, and allocated usage of on-call support provided for the plans individually. Customers can be billed for any additional users as required.

Things to Consider

To create a Metered Feature, you must consider the following key aspects:

  • Identify usage variables: You must first identify the usage event attributes that you want to track and bill your customers for. These are usually the most sought-after capabilities of your product offering. Going by the above example, you would create metered features using attributes such as user sign-ups, and on-call support minutes/hours. Ensure that while ingesting usage events into Chargebee Billing, you ingest these billable/meterable attributes. This is when you clearly know which parts of your product offerings you want to charge your customers for. Alternatively, you can work your way backward and review usage trends for various usage event attributes and monetize them.

  • Determine the aggregation method: The aggregation method is how you would derive the final quantity of the usage event attribute for which you bill your customer. You can use sum, count, min, max, and average. In the above example, you would use count for the number of user sign-ups, and sum for the on-call support minutes/hours.

  • Determine the filter conditions: Filter conditions help you narrow down the usage aggregation for the usage event attributes from the entire usage stream for specific conditions that you define. For instance, you can create metered features with filters to track the usage event attributes for each of your plan offering.

  • Choose group-by attributes for a usage breakdown (optional): Group-by attributes split a metered feature's usage total into groups, such as by region, gpu_type, or api_key. Use them to see what drives consumption and to show customers an itemized view through the Usage Summary API and the Usage PDF API. To plan your attributes, see Group-by attribute limits and best practices.

  • Create, Link Price, Analyze, Repeat: Create metered features to track usage of specific attributes, link pricing to them, analyze usage metrics, and refine your pricing strategy through experimentation. Repeat the process to optimize your pricing model.

Creating a Metered Feature

To create a new metered feature in your Chargebee Billing site, follow these steps:

  1. Navigate to Usages > Metered Features, and click Create Metered Feature. Alternatively, navigate to Entitlements > Features, and click Create Feature. Both open the Create feature page with Metered feature selected.
  2. On the Create feature page, specify the following details:
    • Enter a name for the feature that you are metering.
    • Enter the unit of measurement for the usage, such as tokens. The unit is required.
    • Under Usage Calculation,
      • Specify how usage is aggregated or calculated in your billing period. You can select from the following aggregation methods: Sum, Count, Min, Max, Average, Count Distinct.
      • Select the usage event attribute that you want to aggregate. You can select any quantity based attributes from your usage event resource.
    • The Usage Calculation Formula gets displayed as you define the metered feature.
    • The Usage Calculation Preview displays a sample set computation for your metered feature from the available usage data. You can also view a Preview of Filter events for the feature.
    • Under Filter Conditions, you can add AND/OR filter conditions to filter usage events for which usage gets calculated.
    • For complex calculations and use cases where basic filter conditions might not suffice, you can use the SQL mode that allows custom SQL queries.
    • Under Group-by attributes, add up to five event attributes to group this metered feature's usage by. You can select attributes detected in your usage events or enter custom attribute names manually. You can view usage breakdowns by group-by attributes in Usage Insights and Automatic Exports, and show them to your customers through the Usage Summary API and the Usage PDF API. For example scenarios, see Break down usage by group-by attributes.
      • Attribute names are case-sensitive. For example, Region and region are different attributes.
      • You can add an attribute even if your current usage events don't include it yet. Until events include the attribute, their usage is reported under the null group for that attribute.
      • Review your group-by attributes before you click Create. Once something depends on a group-by attribute, such as usage events ingested against the metered feature, you can't remove or replace it.
      • Group-by attributes don't change billing. Included usage and overage rates linked to items are always evaluated against the metered feature's overall total.
      • For the limits that apply, see Group-by attribute limits and best practices.
  3. Once you're done, click Create.

The metered feature is successfully created. You can now proceed to Link Pricing for the metered feature as required.

Group-by attribute limits and best practices

Each metered feature has limits on how many group-by attributes it can have and how many unique combinations of their values it can store. To see what you can build with group-by attributes, see Break down usage by group-by attributes.

Group-by attributes work best when each attribute has a bounded set of values, such as regions, models, or GPU types.

Attribute typeExamplesGuidance
Small, fixed set of valuesregion, model, gpu_type, environment, plan tierBest fit. Combine freely.
Larger set, bounded per subscriptionuser_id, api_key, project_idWorks on its own or with a small attribute. Avoid combining two of these.
Values unique to each eventEvent ID, request ID, timestamp, session IDNot suited to group-by, because every event creates a new combination.

Group-by attribute limits at a glance

LimitValueApplies to
Group-by attributesFiveEach metered feature
Unique combinations of attribute values10,000 per minuteEach metered feature, for each subscription

How the 10,000-combination limit for group-by attributes works

For each metered feature, subscription, and minute, Chargebee Billing stores one row per unique combination of group-by attribute values. Without group-by attributes, that's one row per minute. Events that share the same values are aggregated into the same row. The limit is 10,000 rows per minute for each metered feature and subscription. If a minute's usage events produce more than 10,000 combinations, Chargebee Billing rejects the additional combinations.

  • Combinations multiply. Two attributes with 200 values each can produce up to 40,000 combinations, not 400.
  • Each subscription has its own limit. One subscription's combinations don't count toward another's, and each metered feature has its own limit.
  • Only combinations that occur in the same minute count. Combinations across a billing period can exceed 10,000 as long as no single minute does.
Attributes and unique values per minuteMaximum combinations per subscription in a minuteWithin the limit?
region (5 values)5Yes
model (5 values), user_id (500 values)2,500Yes
gpu_type (40 values), region (5 values)200Yes
user_id (500 values), api_key (400 values)200,000No

The maximum assumes every combination appears in the same minute. To plan with a safe margin, multiply the largest number of values you expect each attribute to have for a single subscription, and keep the result well below 10,000.

Managing Metered Features

From the Metered Features details page, you can edit, archive, or delete a metered feature depending on how it is being used.

Editing a Metered Feature

You can update the configuration of a metered feature, such as its name, unit, aggregation method, filter conditions, and group-by attributes.

  • You can edit the name of a metered feature at any time.
  • You can edit the unit until the metered feature is linked to an active subscription.
  • You can change the aggregation method and filter conditions until the first usage event is ingested against the metered feature or a usage alert is set on it.
  • The metered feature identifier cannot be changed once the feature has been created.
  • You can add group-by attributes at any time, including after usage events have been ingested. Breakdowns by a newly added attribute start from the time you add it. Usage ingested earlier isn't backfilled and is reported under the null group for that attribute.
  • You can remove a group-by attribute only if nothing depends on it, such as usage events already ingested against the metered feature or a usage alert set on it. If you can't remove an attribute you don't need, it doesn't affect billing, but it still counts toward the five-attribute limit.

To edit a metered feature, navigate to Usages > Metered Features, select the feature, and click Edit.

Archiving a Metered Feature

If you intend to discontinue a metered feature, you can archive it to hide it from future use.

When a metered feature is archived:

  • It remains linked to any existing entitlements.
  • Subscriptions already using the metered feature continue to work without any change.

To archive a metered feature, navigate to Usages > Metered Features, select the feature, and click Archive.

Deleting a Metered Feature

You can delete a metered feature that was misconfigured or is no longer required.

  • You can delete a metered feature only after you archive it.
  • You can delete an archived metered feature when it isn't linked to an active subscription and has no usage alert.

To delete a metered feature, navigate to Usages > Metered Features, select the feature, and click Delete.

If the metered feature is linked to a metered addon, unlinking the metered addon does not remove the feature from older grandfathered entitlement versions. As a result, subscriptions created against those older versions continue to reference the metered feature and its metered addon, which can lead to incorrect metered entitlements.

To remove the link completely across all versions:

  1. Go to Configure Chargebee > Billing > Entitlements.
  2. Select Manage Immediate Metered entitlements update.
  3. Select the unlinked metered feature and its corresponding metered addon.
  4. Set the action to Remove and apply the change.

Once applied, the link is removed across all versions, and you can link new metered features to that addon.