diff --git a/.github/workflows/appsignals-e2e-ec2-test.yml b/.github/workflows/appsignals-e2e-ec2-test.yml index b872d75de..eb2377a9a 100644 --- a/.github/workflows/appsignals-e2e-ec2-test.yml +++ b/.github/workflows/appsignals-e2e-ec2-test.yml @@ -166,10 +166,10 @@ jobs: - name: Call all test APIs continue-on-error: true run: | - curl -S -s http://${{ env.MAIN_SERVICE_ENDPOINT }}/outgoing-http-call/ - curl -S -s http://${{ env.MAIN_SERVICE_ENDPOINT }}/aws-sdk-call/ - curl -S -s http://${{ env.MAIN_SERVICE_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_IP }}/ - curl -S -s http://${{ env.MAIN_SERVICE_ENDPOINT }}/client-call/ + curl -S -s http://${{ env.MAIN_SERVICE_ENDPOINT }}/outgoing-http-call + curl -S -s http://${{ env.MAIN_SERVICE_ENDPOINT }}/aws-sdk-call?testingId=${{ env.TESTING_ID }} + curl -S -s http://${{ env.MAIN_SERVICE_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_IP }} + curl -S -s http://${{ env.MAIN_SERVICE_ENDPOINT }}/client-call # Validation for pulse telemetry data - name: Validate generated EMF logs @@ -201,7 +201,7 @@ jobs: --log-group ${{ env.LOG_GROUP_NAME }} --service-name sample-application-${{ env.TESTING_ID }} --remote-service-name sample-remote-application-${{ env.TESTING_ID }} - --request-body ip=${{ env.REMOTE_SERVICE_IP }} + --request-body ip=${{ env.REMOTE_SERVICE_IP }}&testingId=${{ env.TESTING_ID }} --instance-ami ${{ env.EC2_INSTANCE_AMI }} --rollup' diff --git a/.github/workflows/appsignals-e2e-eks-test.yml b/.github/workflows/appsignals-e2e-eks-test.yml index b389f7247..52ce2ab80 100644 --- a/.github/workflows/appsignals-e2e-eks-test.yml +++ b/.github/workflows/appsignals-e2e-eks-test.yml @@ -253,10 +253,10 @@ jobs: - name: Call all test APIs continue-on-error: true run: | - curl -S -s http://${{ env.APP_ENDPOINT }}/outgoing-http-call/ - curl -S -s http://${{ env.APP_ENDPOINT }}/aws-sdk-call/ - curl -S -s http://${{ env.APP_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_POD_IP }}/ - curl -S -s http://${{ env.APP_ENDPOINT }}/client-call/ + curl -S -s http://${{ env.APP_ENDPOINT }}/outgoing-http-call + curl -S -s http://${{ env.APP_ENDPOINT }}/aws-sdk-call?testingId=${{ env.TESTING_ID }} + curl -S -s http://${{ env.APP_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_POD_IP }} + curl -S -s http://${{ env.APP_ENDPOINT }}/client-call # Validation for app signals telemetry data - name: Call endpoint and validate generated EMF logs @@ -291,7 +291,7 @@ jobs: --service-name sample-application-${{ env.TESTING_ID }} --remote-service-name sample-remote-application-${{ env.TESTING_ID }} --remote-service-deployment-name ${{ env.REMOTE_SERVICE_DEPLOYMENT_NAME }} - --request-body ip=${{ env.REMOTE_SERVICE_POD_IP }} + --request-body ip=${{ env.REMOTE_SERVICE_POD_IP }}&testingId=${{ env.TESTING_ID }} --rollup' - name: Call endpoints and validate generated traces diff --git a/.github/workflows/appsignals-python-e2e-ec2-test.yml b/.github/workflows/appsignals-python-e2e-ec2-test.yml index 14f677ddb..9b8fd03ca 100644 --- a/.github/workflows/appsignals-python-e2e-ec2-test.yml +++ b/.github/workflows/appsignals-python-e2e-ec2-test.yml @@ -170,7 +170,7 @@ jobs: continue-on-error: true run: | curl -S -s -o /dev/null http://${{ env.MAIN_SERVICE_ENDPOINT }}/outgoing-http-call - curl -S -s -o /dev/null http://${{ env.MAIN_SERVICE_ENDPOINT }}/aws-sdk-call + curl -S -s -o /dev/null http://${{ env.MAIN_SERVICE_ENDPOINT }}/aws-sdk-call?testingId=${{ env.TESTING_ID }} curl -S -s -o /dev/null http://${{ env.MAIN_SERVICE_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_IP }} curl -S -s -o /dev/null http://${{ env.MAIN_SERVICE_ENDPOINT }}/client-call @@ -204,7 +204,7 @@ jobs: --log-group ${{ env.LOG_GROUP_NAME }} --service-name python-sample-application-${{ env.TESTING_ID }} --remote-service-name python-sample-remote-application-${{ env.TESTING_ID }} - --request-body ip=${{ env.REMOTE_SERVICE_IP }} + --request-body ip=${{ env.REMOTE_SERVICE_IP }}&testingId=${{ env.TESTING_ID }} --instance-ami ${{ env.EC2_INSTANCE_AMI }} --rollup' diff --git a/.github/workflows/appsignals-python-e2e-eks-test.yml b/.github/workflows/appsignals-python-e2e-eks-test.yml index c9c0aa737..47e4fe52d 100644 --- a/.github/workflows/appsignals-python-e2e-eks-test.yml +++ b/.github/workflows/appsignals-python-e2e-eks-test.yml @@ -301,7 +301,7 @@ jobs: continue-on-error: true run: | curl -S -s -o /dev/null http://${{ env.APP_ENDPOINT }}/outgoing-http-call - curl -S -s -o /dev/null http://${{ env.APP_ENDPOINT }}/aws-sdk-call + curl -S -s -o /dev/null http://${{ env.APP_ENDPOINT }}/aws-sdk-call?testingId=${{ env.TESTING_ID }} curl -S -s -o /dev/null http://${{ env.APP_ENDPOINT }}/remote-service?ip=${{ env.REMOTE_SERVICE_POD_IP }} curl -S -s -o /dev/null http://${{ env.APP_ENDPOINT }}/client-call @@ -338,7 +338,7 @@ jobs: --service-name python-application-${{ env.TESTING_ID }} --remote-service-name python-remote-application-${{ env.TESTING_ID }} --remote-service-deployment-name ${{ env.REMOTE_SERVICE_DEPLOYMENT_NAME }} - --request-body ip=${{ env.REMOTE_SERVICE_POD_IP }} + --request-body ip=${{ env.REMOTE_SERVICE_POD_IP }}&testingId=${{ env.TESTING_ID }} --rollup' - name: Call endpoints and validate generated traces diff --git a/terraform/ec2/main.tf b/terraform/ec2/main.tf index b3bc009cb..ff289d0c5 100644 --- a/terraform/ec2/main.tf +++ b/terraform/ec2/main.tf @@ -177,7 +177,7 @@ resource "null_resource" "remote_service_setup" { "echo $agent_config > amazon-cloudwatch-agent.json", # Get and run CW agent rpm - "${var.get_cw_agent_rpm_command}", + "${var.get_cw_agent_rpm_command}", "sudo rpm -U ./cw-agent.rpm", "sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:./amazon-cloudwatch-agent.json", diff --git a/validator/src/main/java/com/amazon/aoc/App.java b/validator/src/main/java/com/amazon/aoc/App.java index 423c74d12..9f71d1a62 100644 --- a/validator/src/main/java/com/amazon/aoc/App.java +++ b/validator/src/main/java/com/amazon/aoc/App.java @@ -75,6 +75,9 @@ public class App implements Callable { @CommandLine.Option(names = {"--remote-service-deployment-name"}) private String remoteServiceDeploymentName; + @CommandLine.Option(names = {"--remote-target-name"}) + private String remoteTargetName; + @CommandLine.Option(names = {"--endpoint"}) private String endpoint; @@ -160,6 +163,7 @@ public Integer call() throws Exception { context.setServiceName(this.serviceName); context.setRemoteServiceName(this.remoteServiceName); context.setRemoteServiceDeploymentName(this.remoteServiceDeploymentName); + context.setRemoteTargetName(this.remoteTargetName); context.setEndpoint(this.endpoint); context.setRequestBody(this.requestBody); context.setLogGroup(this.logGroup); diff --git a/validator/src/main/java/com/amazon/aoc/models/Context.java b/validator/src/main/java/com/amazon/aoc/models/Context.java index 5d8a13c08..b3f6559e0 100644 --- a/validator/src/main/java/com/amazon/aoc/models/Context.java +++ b/validator/src/main/java/com/amazon/aoc/models/Context.java @@ -49,6 +49,8 @@ public class Context { private String remoteServiceDeploymentName; + private String remoteTargetName; + private String endpoint; private String requestBody; diff --git a/validator/src/main/java/com/amazon/aoc/services/CloudWatchService.java b/validator/src/main/java/com/amazon/aoc/services/CloudWatchService.java index db444f42e..f181ee4e7 100644 --- a/validator/src/main/java/com/amazon/aoc/services/CloudWatchService.java +++ b/validator/src/main/java/com/amazon/aoc/services/CloudWatchService.java @@ -28,6 +28,8 @@ import com.amazonaws.services.logs.model.OutputLogEvent; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; +import kotlin.Pair; import lombok.extern.log4j.Log4j2; /** a wrapper of cloudwatch client. */ @@ -35,6 +37,7 @@ public class CloudWatchService { public static final String SERVICE_DIMENSION = "Service"; public static final String REMOTE_SERVICE_DIMENSION = "RemoteService"; + public static final String REMOTE_TARGET_DIMENSION = "RemoteTarget"; private static final int MAX_QUERY_PERIOD = 60; private static final String REQUESTER = "integrationTest"; @@ -62,15 +65,20 @@ public CloudWatchService(String region) { public List listMetrics( final String namespace, final String metricName, - final String dimensionKey, - final String dimensionValue) { - final DimensionFilter dimensionFilter = - new DimensionFilter().withName(dimensionKey).withValue(dimensionValue); + final List> dimensionList) { + final List dimensionFilters = + dimensionList.stream() + .map( + dimension -> + new DimensionFilter() + .withName(dimension.getFirst()) + .withValue(dimension.getSecond())) + .collect(Collectors.toList()); final ListMetricsRequest listMetricsRequest = new ListMetricsRequest() .withNamespace(namespace) .withMetricName(metricName) - .withDimensions(dimensionFilter) + .withDimensions(dimensionFilters) .withRecentlyActive("PT3H"); return amazonCloudWatch.listMetrics(listMetricsRequest).getMetrics(); } diff --git a/validator/src/main/java/com/amazon/aoc/validators/CWMetricValidator.java b/validator/src/main/java/com/amazon/aoc/validators/CWMetricValidator.java index 6a665dd2b..b64102591 100644 --- a/validator/src/main/java/com/amazon/aoc/validators/CWMetricValidator.java +++ b/validator/src/main/java/com/amazon/aoc/validators/CWMetricValidator.java @@ -30,17 +30,19 @@ import com.google.common.collect.Lists; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.TreeSet; +import kotlin.Pair; import lombok.extern.log4j.Log4j2; @Log4j2 public class CWMetricValidator implements IValidator { - private static int DEFAULT_MAX_RETRY_COUNT = 80; + private static int DEFAULT_MAX_RETRY_COUNT = 10; private MustacheHelper mustacheHelper = new MustacheHelper(); private ICaller caller; @@ -103,16 +105,30 @@ public void validate() throws Exception { } List actualMetricList = Lists.newArrayList(); - addMetrics( - CloudWatchService.SERVICE_DIMENSION, - serviceNames, - expectedMetricList, - actualMetricList); - addMetrics( - CloudWatchService.REMOTE_SERVICE_DIMENSION, - remoteServiceNames, - expectedMetricList, - actualMetricList); + + // Add sets of dimesion filters to use for each query to CloudWatch + List>> dimensionLists = Lists.newArrayList(); + // Query metrics for rolled up into the [serviceDimension] dimension + for (String serviceName : serviceNames) { + dimensionLists.add( + Arrays.asList(new Pair<>(CloudWatchService.SERVICE_DIMENSION, serviceName))); + } + // Query metrics for rolled up into the [remoteServiceDimension] dimension + for (String remoteServiceName : remoteServiceNames) { + dimensionLists.add( + Arrays.asList( + new Pair<>(CloudWatchService.REMOTE_SERVICE_DIMENSION, remoteServiceName))); + } + // Query metrics for rolled up into the [remoteServiceDimension, remoteTargetDemsion] dimensions + dimensionLists.add( + Arrays.asList( + new Pair<>(CloudWatchService.REMOTE_SERVICE_DIMENSION, "AWS.SDK.S3"), + new Pair<>(CloudWatchService.REMOTE_TARGET_DIMENSION, context.getRemoteTargetName()))); + + // Populate actualMetricList with metrics that pass through one of the dimension filters + for (List> dimensionList : dimensionLists) { + addMetrics(dimensionList, expectedMetricList, actualMetricList); + } // remove the skip dimensions log.info("dimensions to be skipped in validation: {}", skippedDimensionNameList); @@ -132,16 +148,12 @@ public void validate() throws Exception { } private void addMetrics( - String dimensionName, - List dimensionValues, + List> dimensionList, List expectedMetricList, List actualMetricList) throws Exception { - for (String dimensionValue : dimensionValues) { - actualMetricList.addAll( - this.listMetricFromCloudWatch( - cloudWatchService, expectedMetricList, dimensionName, dimensionValue)); - } + actualMetricList.addAll( + this.listMetricFromCloudWatch(cloudWatchService, expectedMetricList, dimensionList)); } /** @@ -194,8 +206,7 @@ private void compareMetricLists(List toBeCheckedMetricList, List private List listMetricFromCloudWatch( CloudWatchService cloudWatchService, List expectedMetricList, - String dimensionKey, - String dimensionValue) + List> dimensionList) throws IOException { // put namespace into the map key, so that we can use it to search metric HashMap metricNameMap = new HashMap<>(); @@ -207,8 +218,7 @@ private List listMetricFromCloudWatch( List result = new ArrayList<>(); for (String metricName : metricNameMap.keySet()) { result.addAll( - cloudWatchService.listMetrics( - metricNameMap.get(metricName), metricName, dimensionKey, dimensionValue)); + cloudWatchService.listMetrics(metricNameMap.get(metricName), metricName, dimensionList)); } return result; } diff --git a/validator/src/main/resources/expected-data-template/ec2/aws-sdk-call-metric.mustache b/validator/src/main/resources/expected-data-template/ec2/aws-sdk-call-metric.mustache index cd23971e9..773ae4503 100644 --- a/validator/src/main/resources/expected-data-template/ec2/aws-sdk-call-metric.mustache +++ b/validator/src/main/resources/expected-data-template/ec2/aws-sdk-call-metric.mustache @@ -95,7 +95,7 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} - metricName: Latency @@ -115,7 +115,35 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Latency + namespace: {{metricNamespace}} + dimensions: + - + name: Service + value: {{serviceName}} + - + name: HostedIn.Environment + value: EC2 + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Latency + namespace: {{metricNamespace}} + dimensions: + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} - metricName: Error @@ -214,7 +242,7 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} - metricName: Error @@ -234,7 +262,35 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Error + namespace: {{metricNamespace}} + dimensions: + - + name: Service + value: {{serviceName}} + - + name: HostedIn.Environment + value: EC2 + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Error + namespace: {{metricNamespace}} + dimensions: + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} - metricName: Fault @@ -333,7 +389,7 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} - metricName: Fault @@ -353,6 +409,33 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Fault + namespace: {{metricNamespace}} + dimensions: + - + name: Service + value: {{serviceName}} + - + name: HostedIn.Environment + value: EC2 + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} +- + metricName: Fault + namespace: {{metricNamespace}} + dimensions: + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} diff --git a/validator/src/main/resources/expected-data-template/eks/aws-sdk-call-metric.mustache b/validator/src/main/resources/expected-data-template/eks/aws-sdk-call-metric.mustache index cca870991..c9f739d1e 100644 --- a/validator/src/main/resources/expected-data-template/eks/aws-sdk-call-metric.mustache +++ b/validator/src/main/resources/expected-data-template/eks/aws-sdk-call-metric.mustache @@ -113,7 +113,7 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} - metricName: Latency @@ -136,7 +136,38 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Latency + namespace: {{metricNamespace}} + dimensions: + - + name: Service + value: {{serviceName}} + - + name: HostedIn.EKS.Cluster + value: {{platformInfo}} + - + name: HostedIn.K8s.Namespace + value: {{appNamespace}} + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Latency + namespace: {{metricNamespace}} + dimensions: + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} - metricName: Error @@ -253,7 +284,7 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} - metricName: Error @@ -276,7 +307,38 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Error + namespace: {{metricNamespace}} + dimensions: + - + name: Service + value: {{serviceName}} + - + name: HostedIn.EKS.Cluster + value: {{platformInfo}} + - + name: HostedIn.K8s.Namespace + value: {{appNamespace}} + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Error + namespace: {{metricNamespace}} + dimensions: + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} - metricName: Fault @@ -393,7 +455,7 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} - metricName: Fault @@ -416,4 +478,35 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name \ No newline at end of file + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Fault + namespace: {{metricNamespace}} + dimensions: + - + name: Service + value: {{serviceName}} + - + name: HostedIn.EKS.Cluster + value: {{platformInfo}} + - + name: HostedIn.K8s.Namespace + value: {{appNamespace}} + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Fault + namespace: {{metricNamespace}} + dimensions: + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} diff --git a/validator/src/main/resources/expected-data-template/python/ec2/aws-sdk-call-metric.mustache b/validator/src/main/resources/expected-data-template/python/ec2/aws-sdk-call-metric.mustache index 65586b715..fc5a43bd3 100644 --- a/validator/src/main/resources/expected-data-template/python/ec2/aws-sdk-call-metric.mustache +++ b/validator/src/main/resources/expected-data-template/python/ec2/aws-sdk-call-metric.mustache @@ -95,7 +95,7 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} - metricName: Latency @@ -115,7 +115,35 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Latency + namespace: {{metricNamespace}} + dimensions: + - + name: Service + value: {{serviceName}} + - + name: HostedIn.Environment + value: EC2 + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Latency + namespace: {{metricNamespace}} + dimensions: + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} - metricName: Error @@ -214,7 +242,7 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} - metricName: Error @@ -234,7 +262,35 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Error + namespace: {{metricNamespace}} + dimensions: + - + name: Service + value: {{serviceName}} + - + name: HostedIn.Environment + value: EC2 + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Error + namespace: {{metricNamespace}} + dimensions: + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} - metricName: Fault @@ -333,7 +389,7 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} - metricName: Fault @@ -353,6 +409,33 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Fault + namespace: {{metricNamespace}} + dimensions: + - + name: Service + value: {{serviceName}} + - + name: HostedIn.Environment + value: EC2 + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} +- + metricName: Fault + namespace: {{metricNamespace}} + dimensions: + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} diff --git a/validator/src/main/resources/expected-data-template/python/eks/aws-sdk-call-metric.mustache b/validator/src/main/resources/expected-data-template/python/eks/aws-sdk-call-metric.mustache index b30ff3294..501adfcff 100644 --- a/validator/src/main/resources/expected-data-template/python/eks/aws-sdk-call-metric.mustache +++ b/validator/src/main/resources/expected-data-template/python/eks/aws-sdk-call-metric.mustache @@ -113,7 +113,7 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} - metricName: Latency @@ -136,7 +136,38 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Latency + namespace: {{metricNamespace}} + dimensions: + - + name: Service + value: {{serviceName}} + - + name: HostedIn.EKS.Cluster + value: {{platformInfo}} + - + name: HostedIn.K8s.Namespace + value: {{appNamespace}} + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Latency + namespace: {{metricNamespace}} + dimensions: + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} - metricName: Error @@ -253,7 +284,7 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} - metricName: Error @@ -276,7 +307,38 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Error + namespace: {{metricNamespace}} + dimensions: + - + name: Service + value: {{serviceName}} + - + name: HostedIn.EKS.Cluster + value: {{platformInfo}} + - + name: HostedIn.K8s.Namespace + value: {{appNamespace}} + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Error + namespace: {{metricNamespace}} + dimensions: + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} - metricName: Fault @@ -393,7 +455,7 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name + value: ::s3:::e2e-test-bucket-name-{{testingId}} - metricName: Fault @@ -416,4 +478,35 @@ value: AWS.SDK.S3 - name: RemoteTarget - value: ::s3:::e2e-test-bucket-name \ No newline at end of file + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Fault + namespace: {{metricNamespace}} + dimensions: + - + name: Service + value: {{serviceName}} + - + name: HostedIn.EKS.Cluster + value: {{platformInfo}} + - + name: HostedIn.K8s.Namespace + value: {{appNamespace}} + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} + +- + metricName: Fault + namespace: {{metricNamespace}} + dimensions: + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: ::s3:::e2e-test-bucket-name-{{testingId}} diff --git a/validator/src/main/resources/validations/ec2/metric-validation.yml b/validator/src/main/resources/validations/ec2/metric-validation.yml index 98f1595ad..db83cc1d7 100644 --- a/validator/src/main/resources/validations/ec2/metric-validation.yml +++ b/validator/src/main/resources/validations/ec2/metric-validation.yml @@ -8,7 +8,7 @@ validationType: "cw-metric" httpPath: "/aws-sdk-call" httpMethod: "get" - callingType: "http" + callingType: "http-with-body" expectedMetricTemplate: "EC2_AWS_SDK_CALL_METRIC" - validationType: "cw-metric" diff --git a/validator/src/main/resources/validations/eks/metric-validation.yml b/validator/src/main/resources/validations/eks/metric-validation.yml index dde79819c..a8e64becb 100644 --- a/validator/src/main/resources/validations/eks/metric-validation.yml +++ b/validator/src/main/resources/validations/eks/metric-validation.yml @@ -8,7 +8,7 @@ validationType: "cw-metric" httpPath: "/aws-sdk-call" httpMethod: "get" - callingType: "http" + callingType: "http-with-body" expectedMetricTemplate: "EKS_AWS_SDK_CALL_METRIC" - validationType: "cw-metric" diff --git a/validator/src/main/resources/validations/python/ec2/metric-validation.yml b/validator/src/main/resources/validations/python/ec2/metric-validation.yml index 56b234b32..56b48a8cd 100644 --- a/validator/src/main/resources/validations/python/ec2/metric-validation.yml +++ b/validator/src/main/resources/validations/python/ec2/metric-validation.yml @@ -8,7 +8,7 @@ validationType: "cw-metric" httpPath: "/aws-sdk-call" httpMethod: "get" - callingType: "http" + callingType: "http-with-body" expectedMetricTemplate: "PYTHON_EC2_AWS_SDK_CALL_METRIC" - validationType: "cw-metric" diff --git a/validator/src/main/resources/validations/python/eks/metric-validation.yml b/validator/src/main/resources/validations/python/eks/metric-validation.yml index 4778326d3..998d0fa4f 100644 --- a/validator/src/main/resources/validations/python/eks/metric-validation.yml +++ b/validator/src/main/resources/validations/python/eks/metric-validation.yml @@ -8,7 +8,7 @@ validationType: "cw-metric" httpPath: "/aws-sdk-call" httpMethod: "get" - callingType: "http" + callingType: "http-with-body" expectedMetricTemplate: "PYTHON_EKS_AWS_SDK_CALL_METRIC" - validationType: "cw-metric" diff --git a/validator/src/test/java/com/amazon/aoc/validators/CWMetricValidatorTest.java b/validator/src/test/java/com/amazon/aoc/validators/CWMetricValidatorTest.java index 2e750c703..e183a55a7 100644 --- a/validator/src/test/java/com/amazon/aoc/validators/CWMetricValidatorTest.java +++ b/validator/src/test/java/com/amazon/aoc/validators/CWMetricValidatorTest.java @@ -30,7 +30,9 @@ import com.amazon.aoc.models.ValidationConfig; import com.amazon.aoc.services.CloudWatchService; import com.amazonaws.services.cloudwatch.model.Metric; +import java.util.Arrays; import java.util.List; +import kotlin.Pair; import org.assertj.core.util.Lists; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -45,10 +47,12 @@ public class CWMetricValidatorTest { private CWMetricHelper cwMetricHelper = new CWMetricHelper(); private static final String SERVICE_DIMENSION = "Service"; private static final String REMOTE_SERVICE_DIMENSION = "RemoteService"; + private static final String REMOTE_TARGET_DIMENSION = "RemoteTarget"; private static final String TEMPLATE_ROOT = "file://" + System.getProperty("user.dir") + "/src/test/test-resources/"; private static final String SERVICE_NAME = "serviceName"; private static final String REMOTE_SERVICE_NAME = "remoteServiceName"; + private static final String REMOTE_TARGET_NAME = "remoteTargetName"; private static final String REMOTE_SERVICE_DEPLOYMENT_NAME = "remoteServiceDeploymentName"; private Context context; @@ -97,6 +101,7 @@ public void testValidateEndToEnd_Success() throws Exception { List remoteMetricsWithRemoteApp = getTestMetrics("endToEnd_remoteMetricsWithRemoteApp"); List remoteMetricsWithAmazon = getTestMetrics("endToEnd_remoteMetricsWithAmazon"); List remoteMetricsWithAwsSdk = getTestMetrics("endToEnd_remoteMetricsWithAwsSdk"); + List remoteMetricsWithS3Target = getTestMetrics("endToEnd_remoteMetricsWithS3Target"); CloudWatchService cloudWatchService = mockCloudWatchService( @@ -104,7 +109,8 @@ public void testValidateEndToEnd_Success() throws Exception { remoteServiceMetrics, remoteMetricsWithRemoteApp, remoteMetricsWithAmazon, - remoteMetricsWithAwsSdk); + remoteMetricsWithAwsSdk, + remoteMetricsWithS3Target); validate(validationConfig, cloudWatchService); } @@ -120,6 +126,8 @@ public void testValidateEndToEnd_MissingRemoteService() throws Exception { List remoteMetricsWithRemoteApp = Lists.newArrayList(); List remoteMetricsWithAmazon = getTestMetrics("endToEnd_remoteMetricsWithAmazon"); List remoteMetricsWithAwsSdk = getTestMetrics("endToEnd_remoteMetricsWithAwsSdk"); + List remoteMetricsWithAwsSdkWithTarget = + getTestMetrics("endToEnd_remoteMetricsWithAwsSdk"); CloudWatchService cloudWatchService = mockCloudWatchService( @@ -127,7 +135,8 @@ public void testValidateEndToEnd_MissingRemoteService() throws Exception { remoteServiceMetrics, remoteMetricsWithRemoteApp, remoteMetricsWithAmazon, - remoteMetricsWithAwsSdk); + remoteMetricsWithAwsSdk, + remoteMetricsWithAwsSdkWithTarget); try { validate(validationConfig, cloudWatchService); @@ -175,22 +184,48 @@ private CloudWatchService mockCloudWatchService( List remoteServiceMetrics, List remoteMetricsWithRemoteApp, List remoteMetricsWithAmazon, - List remoteMetricsWithAwsSdk) { + List remoteMetricsWithAwsSdk, + List remoteMetricsWithS3Target) { CloudWatchService cloudWatchService = mock(CloudWatchService.class); - when(cloudWatchService.listMetrics(any(), any(), eq(SERVICE_DIMENSION), eq(SERVICE_NAME))) + Lists.newArrayList(); + when(cloudWatchService.listMetrics( + any(), + any(), + eq(Arrays.asList(new Pair(SERVICE_DIMENSION, SERVICE_NAME))))) .thenReturn(localServiceMetrics); when(cloudWatchService.listMetrics( - any(), any(), eq(SERVICE_DIMENSION), eq(REMOTE_SERVICE_NAME))) + any(), + any(), + eq(Arrays.asList(new Pair(SERVICE_DIMENSION, REMOTE_SERVICE_NAME))))) .thenReturn(remoteServiceMetrics); when(cloudWatchService.listMetrics( - any(), any(), eq(REMOTE_SERVICE_DIMENSION), eq(REMOTE_SERVICE_DEPLOYMENT_NAME))) + any(), + any(), + eq( + Arrays.asList( + new Pair( + REMOTE_SERVICE_DIMENSION, REMOTE_SERVICE_DEPLOYMENT_NAME))))) .thenReturn(remoteMetricsWithRemoteApp); when(cloudWatchService.listMetrics( - any(), any(), eq(REMOTE_SERVICE_DIMENSION), eq("www.amazon.com"))) + any(), + any(), + eq( + Arrays.asList( + new Pair(REMOTE_SERVICE_DIMENSION, "www.amazon.com"))))) .thenReturn(remoteMetricsWithAmazon); when(cloudWatchService.listMetrics( - any(), any(), eq(REMOTE_SERVICE_DIMENSION), eq("AWS.SDK.S3"))) + any(), + any(), + eq(Arrays.asList(new Pair(REMOTE_SERVICE_DIMENSION, "AWS.SDK.S3"))))) .thenReturn(remoteMetricsWithAwsSdk); + when(cloudWatchService.listMetrics( + any(), + any(), + eq( + Arrays.asList( + new Pair(REMOTE_SERVICE_DIMENSION, "AWS.SDK.S3"), + new Pair(REMOTE_TARGET_DIMENSION, REMOTE_TARGET_NAME))))) + .thenReturn(remoteMetricsWithS3Target); return cloudWatchService; } @@ -212,7 +247,7 @@ private void runBasicValidation(ValidationConfig validationConfig) throws Except CloudWatchService cloudWatchService = mock(CloudWatchService.class); // mock listMetrics - when(cloudWatchService.listMetrics(any(), any(), any(), any())).thenReturn(metrics); + when(cloudWatchService.listMetrics(any(), any(), any())).thenReturn(metrics); // start validation validate(validationConfig, cloudWatchService); diff --git a/validator/src/test/test-resources/endToEnd_expectedMetrics.mustache b/validator/src/test/test-resources/endToEnd_expectedMetrics.mustache index 331d6620c..218acab71 100644 --- a/validator/src/test/test-resources/endToEnd_expectedMetrics.mustache +++ b/validator/src/test/test-resources/endToEnd_expectedMetrics.mustache @@ -84,4 +84,14 @@ dimensions: - name: RemoteService - value: remoteServiceDeploymentName \ No newline at end of file + value: remoteServiceDeploymentName +- + metricName: metricName + namespace: metricNamespace + dimensions: + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: e2e-test-bucket-name \ No newline at end of file diff --git a/validator/src/test/test-resources/endToEnd_remoteMetricsWithS3Target.mustache b/validator/src/test/test-resources/endToEnd_remoteMetricsWithS3Target.mustache new file mode 100644 index 000000000..ccbc4905f --- /dev/null +++ b/validator/src/test/test-resources/endToEnd_remoteMetricsWithS3Target.mustache @@ -0,0 +1,10 @@ +- + metricName: metricName + namespace: metricNamespace + dimensions: + - + name: RemoteService + value: AWS.SDK.S3 + - + name: RemoteTarget + value: e2e-test-bucket-name \ No newline at end of file