API versioning enables evolution without breaking existing consumers. But maintaining multiple versions creates monitoring complexity.
Each version might have different performance characteristics, different bugs, and different consumer bases. Without version-aware monitoring, issues affecting specific versions go undetected.
What is API Version Monitoring?
API version monitoring tracks the behavior, usage, and health of each API version independently while providing aggregate views across all versions.
Key Metrics by Version
- Per-version availability and latency
- Version-specific error rates and types
- Usage distribution across versions
- Consumer migration progress
- Version-specific SLO compliance
Handling Different Versioning Strategies
| Strategy | Extraction Method |
|---|---|
URL path (/v1/users) | Parse URL segment |
Header (Accept: application/vnd.api+json;version=2) | Extract from header |
Query parameter (?version=1) | Parse query string |
| Content negotiation | Parse Accept header |
Why Version-Specific Monitoring Matters
Different Reliability Characteristics
Different versions often have different reliability:
- A newer version might have bugs not present in the battle-tested older version
- An older version might have performance issues fixed in newer versions
Aggregate monitoring hides these differences; version-specific monitoring reveals them.
Data-Driven Deprecation Decisions
Deprecation decisions require data:
- When should you sunset an old version?
- How many consumers still depend on it?
- Is traffic declining naturally, or do consumers need active migration encouragement?
Version monitoring provides the data foundation for these decisions.
Migration Issue Detection
Migration issues often manifest in version-specific patterns:
v1: Error rate 0.1% (stable)
v2: Error rate 2.5% (increasing)
Root cause: Consumers migrating from v1 to v2 encounter
unexpected behavior differences
Version-segmented monitoring identifies these challenges.
Differentiated SLOs
Different versions might have different SLOs:
| Version | Status | Availability SLO |
|---|---|---|
| v1 | Maintenance mode | 99.5% |
| v2 | Current | 99.9% |
| v3 | Beta | 99.0% |
Version-aware monitoring enables different alerting thresholds.
How to Monitor Multiple API Versions
Extract and Tag Version Information
Ensure version becomes a dimension in all monitoring data:
app.use((req, res, next) => {
// Extract version from various sources
const version =
req.params.version || // URL: /v1/users
req.headers['api-version'] || // Header
req.query.version || // Query param
'1'; // Default
// Attach to request for downstream use
req.apiVersion = version;
// Include in all metrics
res.on('finish', () => {
metrics.recordRequest({
path: req.path,
method: req.method,
status: res.statusCode,
version: version,
duration: res.duration
});
});
next();
});
Create Version Comparison Dashboards
Show side-by-side metrics across versions:
// Query for version comparison
const versionMetrics = await query(`
SELECT
version,
COUNT(*) as request_count,
AVG(duration_ms) as avg_latency,
PERCENTILE(duration_ms, 0.95) as p95_latency,
SUM(CASE WHEN status >= 500 THEN 1 ELSE 0 END) / COUNT(*) as error_rate
FROM api_requests
WHERE timestamp > NOW() - INTERVAL '1 hour'
GROUP BY version
ORDER BY version
`);
These comparisons quickly reveal version-specific issues.
Track Version Adoption Over Time
Plot daily or weekly traffic percentages:
async function trackVersionAdoption() {
const adoption = await query(`
SELECT
DATE_TRUNC('day', timestamp) as date,
version,
COUNT(*) as requests
FROM api_requests
WHERE timestamp > NOW() - INTERVAL '30 days'
GROUP BY date, version
`);
// Calculate percentages
return calculateVersionPercentages(adoption);
}
This trend data shows:
- Natural migration progress
- When active deprecation efforts are needed
- Impact of migration campaigns
Monitor Version-Specific Features
If v2 adds features not in v1, monitor those features separately:
// Track v2-specific endpoints
if (version === '2') {
if (req.path.startsWith('/api/v2/new-feature')) {
metrics.increment('v2_new_feature_usage', {
action: req.method,
status: res.statusCode
});
}
}
This prevents new feature issues from being diluted in overall v2 metrics.
Implement Synthetic Monitoring for Each Version
Even versions with declining traffic need continued monitoring:
const versionsToMonitor = ['v1', 'v2', 'v3'];
versionsToMonitor.forEach(version => {
syntheticMonitor.schedule({
name: `API Health Check - ${version}`,
url: `https://api.example.com/${version}/health`,
interval: '1m',
assertions: [
{ type: 'statusCode', value: 200 },
{ type: 'responseTime', max: 500 }
]
});
});
Configure Version-Specific Alerting
Set appropriate thresholds per version:
# Alert rules by version
- alert: V2HighErrorRate
expr: api_error_rate{version="v2"} > 0.01
for: 5m
labels:
severity: critical
version: v2
- alert: V1HighErrorRate
expr: api_error_rate{version="v1"} > 0.05 # Higher threshold for legacy
for: 10m
labels:
severity: warning
version: v1
A version with 5% of traffic might not need the same alert sensitivity as the version with 80%.
API Version Monitoring Best Practices
Maintain Complete Coverage
Use Adoption Metrics in Product Decisions
Low adoption of new versions might indicate:
- Documentation gaps
- Missing features
- Migration friction
function analyzeAdoptionBarriers() {
const metrics = {
v1_retention: getRetentionRate('v1'),
v2_adoption_rate: getAdoptionRate('v2'),
migration_failure_rate: getMigrationFailures(),
support_tickets_by_version: getSupportTickets()
};
return identifyBarriers(metrics);
}
Alert on Unexpected Distribution Changes
Sudden shifts in traffic between versions might indicate issues:
- alert: UnexpectedVersionShift
expr: |
abs(
api_requests_by_version{version="v2"}
/ sum(api_requests_by_version)
- api_requests_by_version{version="v2"} offset 1h
/ sum(api_requests_by_version offset 1h)
) > 0.1
for: 5m
labels:
severity: warning
Investigate even if overall metrics remain healthy.
Track Deprecation Status
Distinguish between version lifecycle states in monitoring:
const versionStatus = {
'v1': { status: 'deprecated', sunsetDate: '2025-06-01' },
'v2': { status: 'current', sunsetDate: null },
'v3': { status: 'beta', sunsetDate: null }
};
// Include in metrics
metrics.gauge('api_version_status', 1, {
version: 'v1',
status: 'deprecated',
days_until_sunset: daysUntil('2025-06-01')
});
Monitor Deprecation Warnings
If you return deprecation headers or warnings, track their effectiveness:
// Send deprecation warning
if (versionStatus[version].status === 'deprecated') {
res.set('Deprecation', versionStatus[version].sunsetDate);
res.set('Sunset', versionStatus[version].sunsetDate);
metrics.increment('deprecation_warning_sent', {
version,
consumer: req.apiKey
});
}
Track whether consumers receive and act on these warnings.
Document Version Monitoring Configurations
When a version is sunset, its monitoring configurations become irrelevant:
## Version Monitoring Documentation
### v1 (Deprecated)
- **Status**: Deprecated, sunset 2025-06-01
- **Monitoring**: Full synthetic + production metrics
- **Alerts**: Warning-level only
- **Removal checklist**: [ ] Remove synthetic tests, [ ] Archive dashboards
### v2 (Current)
- **Status**: Active
- **Monitoring**: Full coverage
- **Alerts**: Standard SLO-based alerting
Clear documentation enables confident removal of monitoring infrastructure alongside version retirement.
Conclusion
API version monitoring enables confident management of multiple API generations. It provides the visibility needed to maintain quality across versions and make data-driven deprecation decisions.
By treating each version as a distinct entity with its own health metrics while maintaining aggregate views, you balance detailed visibility with operational simplicity.
Key Takeaways
- Tag all monitoring data with version information
- Create side-by-side version comparison dashboards
- Track adoption trends to inform deprecation decisions
- Maintain monitoring coverage until version sunset
Invest in version-aware monitoring infrastructure early in your API versioning journey. The patterns established for v1/v2 monitoring will scale as you continue to evolve your APIs.