diff --git a/pkg/job/discovery_test.go b/pkg/job/discovery_test.go index cc96d1810..4394011c9 100644 --- a/pkg/job/discovery_test.go +++ b/pkg/job/discovery_test.go @@ -420,6 +420,87 @@ func Test_getFilteredMetricDatas(t *testing.T) { }, }, }, + { + "sagemaker endpoint with variant", + args{ + region: "us-east-1", + accountID: "123123123123", + namespace: "sagemaker", + customTags: nil, + tagsOnMetrics: []string{ + "Value1", + "Value2", + }, + dimensionRegexps: config.SupportedServices. + GetService("AWS/SageMaker"). + ToModelDimensionsRegexp(), + // We don't set dimensionNameRequirements here: we want to allow + // metrics that have extra dimensions like VariantName. + resources: []*model.TaggedResource{ + { + ARN: "arn:aws:sagemaker:us-east-1:123123123123:endpoint/someendpoint", + Tags: []model.Tag{ + { + Key: "Environment", + Value: "prod", + }, + }, + Namespace: "sagemaker", + Region: "us-east-1", + }, + }, + metricsList: []*model.Metric{ + { + MetricName: "ModelLatency", + Namespace: "AWS/SageMaker", + Dimensions: []model.Dimension{ + // Note the mixed case here – this is what your + // SageMaker fixDimension logic is about. + {Name: "EndpointName", Value: "SomeEndpoint"}, + {Name: "VariantName", Value: "AllTraffic"}, + }, + }, + }, + m: &model.MetricConfig{ + Name: "ModelLatency", + Statistics: []string{ + "Average", + }, + Period: 60, + Length: 600, + Delay: 120, + NilToZero: false, + AddCloudwatchTimestamp: false, + }, + }, + []model.CloudwatchData{ + { + MetricName: "ModelLatency", + Dimensions: []model.Dimension{ + // getFilteredMetricDatas just forwards cwMetric.Dimensions, + // so we expect both EndpointName AND VariantName here. + {Name: "EndpointName", Value: "SomeEndpoint"}, + {Name: "VariantName", Value: "AllTraffic"}, + }, + ResourceName: "arn:aws:sagemaker:us-east-1:123123123123:endpoint/someendpoint", + Namespace: "sagemaker", + Tags: []model.Tag{ + {Key: "Value1", Value: ""}, + {Key: "Value2", Value: ""}, + }, + GetMetricDataProcessingParams: &model.GetMetricDataProcessingParams{ + Statistic: "Average", + Period: 60, + Length: 600, + Delay: 120, + }, + MetricMigrationParams: model.MetricMigrationParams{ + NilToZero: false, + AddCloudwatchTimestamp: false, + }, + }, + }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/job/maxdimassociator/associator_sagemaker_test.go b/pkg/job/maxdimassociator/associator_sagemaker_test.go index 079eae0ab..cac4dafdf 100644 --- a/pkg/job/maxdimassociator/associator_sagemaker_test.go +++ b/pkg/job/maxdimassociator/associator_sagemaker_test.go @@ -171,6 +171,24 @@ func TestAssociatorSagemaker(t *testing.T) { expectedSkip: false, expectedResource: sagemakerInferenceComponentInvocationUpper, }, + { + name: "variant name match in Upper case", + args: args{ + dimensionRegexps: config.SupportedServices.GetService("AWS/SageMaker").ToModelDimensionsRegexp(), + resources: sagemakerInvocationResources, + metric: &model.Metric{ + MetricName: "ModelLatency", + Namespace: "AWS/SageMaker", + Dimensions: []model.Dimension{ + {Name: "EndpointName", Value: "example-endpoint-two"}, + // this is the important part: VariantName with upper/mixed case + {Name: "VariantName", Value: "Variant-One"}, + }, + }, + }, + expectedSkip: false, + expectedResource: sagemakerEndpointInvocationTwo, + }, } for _, tc := range testcases {