Custom Metrics
Overview
Custom metrics represent business or domain-specific behavior that default infrastructure metrics cannot capture.
When to Add Custom Metrics
- Critical workflow steps need visibility
- Business impact must be measurable
- Default host metrics miss service-level behavior
flowchart LR
A[Business Event] --> B[Application Metric]
B --> C[Monitoring Backend]
C --> D[Alert and Dashboard]
Practical Example
OrdersCreatedTotal
.WithLabels("eu-west-2", "web")
.Inc();
PaymentFailuresTotal
.WithLabels("timeout")
.Inc();
Production Example
Subscription platforms monitor trial conversion and renewal failures as first-class observability signals.
Common Pitfalls
- Creating metrics with excessive label cardinality
- Defining metrics without clear ownership
- Shipping metrics that are never used by dashboards or alerts
Key Takeaways
- Custom metrics bridge technical telemetry and business outcomes.
- Clear naming and bounded labels prevent scale issues.
- Metrics should map directly to decisions and actions.