feat: Implement full multi-region support for all AWS service collectors #270
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi
This PR is for support multi-region scrape from one exporter instance. Mostly prepared with AI.
Now when you have rds in more tha one region, you have to prepare deployment for each region separately, and ypu have:
After changes you can use one instance and add to config for example which region should be scraped:
Also in version 0.16.0 there is a error that you can find in logs :
Summary
This PR completes the multi-region support across all metric collectors in prometheus-rds-exporter. Previously, only RDS and CloudWatch collectors supported multi-region querying. This PR extends full multi-region capability to EC2 and ServiceQuotas collectors, ensuring consistent region labeling and data aggregation across all metrics.
Key Achievement: All collectors (RDS, CloudWatch, EC2, ServiceQuotas) now have feature-complete, consistent multi-region support with correct region labels.
Related Issue
This addresses the incomplete multi-region implementation detected during RDS exporter migration. The analysis revealed that EC2 instance type metrics and ServiceQuotas were only querying specific regions without proper region labeling.
Type of Change
Changes Overview
Phase 1: EC2 Collector Multi-Region Support
Files Modified
internal/app/ec2/ec2.gointernal/app/exporter/exporter.goChanges
Added Region tracking to EC2InstanceMetrics
Region stringto store the source regionUpdated GetDBInstanceTypeInformation() function
region stringparameterRegionfield during metrics collectionImplemented composite key aggregation
aggregatedMetrics[instanceType]aggregatedMetrics[region+":"+instanceType](when region != "")Updated metrics export in Collect() method
c.awsRegionfor backward compatibilityEnhanced EC2 metric lookup for RDS metrics
region:instanceTypeResult: EC2 metrics now correctly labeled with source region for all instances across multiple regions.
Phase 2: ServiceQuotas Collector Multi-Region Support
Files Modified
internal/app/servicequotas/servicequotas.gointernal/app/exporter/exporter.goChanges
Added Region tracking to ServiceQuotas Metrics
Region stringto store the quota source regionUpdated GetRDSQuotas() function signature
region stringparameterRegionfield in returned metricsRefactored ServiceQuota storage structure
ServiceQuota servicequotas.MetricsServiceQuota map[string]servicequotas.MetricsCompletely rewrote getQuotasMetrics() function
Updated Collect() method for multi-region export
aws_regionlabelc.awsRegionif region is empty (backward compatible)Result: ServiceQuotas now queries and exports metrics for ALL configured regions with proper region labels.
Multi-Region Support Completion Matrix
Testing
Pre-Merge Testing
All changes follow the existing code patterns and have been validated against:
Post-Merge Testing (Suggested)
Verification Checklist
Files Changed
Total: 4 files modified, 13 distinct code changes
Modified Files
internal/app/ec2/ec2.go- 3 changesinternal/app/exporter/exporter.go- 7 changesinternal/app/servicequotas/servicequotas.go- 2 changesBackward Compatibility
✅ All changes are fully backward compatible:
Performance Impact
Minimal Performance Impact:
Version Information
Recommended Version: 1.0.8
Notes for Reviewers
Design Decisions:
region:id) follow CloudWatch patternCode Quality:
Testing Strategy:
regions: [us-west-2, eu-central-1]Contributor Checklist
Summary for Changelog
Add multi-region support to EC2 and ServiceQuotas collectors
This PR completes multi-region support across all metric collectors. EC2 instance type metrics and ServiceQuotas now query all configured regions with proper region labeling, consistent with RDS and CloudWatch implementations. Includes composite key aggregation strategy to prevent metric collisions and improved error handling that continues processing other regions on failure.
Breaking Changes: None
New Features:
Bug Fixes: