Fix maxdimassociator to loop through all mappings #1081
Merged
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.
Mappings in the new associator are sorted by decreasing number of dimensions, e.g.
[ Mapping_Dim_A_Dim_B, Mapping_Dim_A_Dim_C, Mapping_Dim_A ]
If trying to map a metric with
Dim_A
,Dim_B
andDim_C
, the current implementation would pic the first mapping (Mapping_Dim_A_Dim_B
) because it already matches part of the metric dimensions and would try to find a match for dimensions names and values. However, if values don't match it would give up and mark the metric to be skipped.The new implementation continues to loop through the regex mappings to check if there another one that contains the metric dimensions. In the example above,
Mapping_Dim_A_Dim_C
would match again and the algo would try again to find a match for dimensions names and values.This should fix cases where ListMetrics returns metrics with more dimensions than can be extracted from the ARN regex. E.g. for ApiGateway the ARN contains only the
ApiId
dimension, but we should now be able to match metrics that contains bothApiId
andMethod
(as long as theApiId
value matches).