Overview
FlexPrice’s metering system processes usage in three stages:Events
Events represent individual usage occurrences:event_name- Type of usage (e.g., “api_call”, “storage_used”)external_customer_id- Customer identifiertimestamp- When the usage occurredproperties- Additional metadata for filtering and aggregation
FlexPrice can handle millions of events per day with real-time aggregation.
Meters
Meters define how events are aggregated into billable usage:Aggregation Types
- COUNT - Count number of events
- SUM - Sum a numeric field
- MAX - Maximum value in period
- LATEST - Most recent value
- UNIQUE_COUNT - Count distinct values
- AVG - Average of numeric field
Real-Time Processing
FlexPrice processes events through Kafka for reliability:- Events are ingested via API
- Published to Kafka topic
events - Consumed by event processors
- Stored in ClickHouse for fast querying
- Aggregated according to meter configuration
Event processing is typically complete within seconds, enabling real-time usage dashboards.
Usage Tracking
Usage is tracked at multiple levels:- Customer level - Total usage across all subscriptions
- Subscription level - Usage tied to a specific plan
- Time period - Hourly, daily, or billing period aggregations
- Dimension level - Grouped by properties (endpoint, region, etc.)
Billing Integration
Metered usage flows into invoices:- Meter aggregates usage during billing period
- Usage is priced according to plan configuration
- Line items are added to customer invoice
- Credits and discounts are applied
- Final invoice is generated
Best Practices
Send Events Immediately
Send events as usage occurs for accurate real-time tracking
Use Idempotency
Include unique event_id to prevent duplicate billing
Add Rich Properties
Include relevant metadata for filtering and grouping
Monitor Ingestion
Track event delivery and processing success rates
Related Resources
Events Guide
Learn about event structure and ingestion
Meters Guide
Configure meters for your use case
Aggregations
Understand aggregation methods
Ingest Events API
API reference for event ingestion