From 24fbcba8f0a336f47ceda007f6c6494733c7dbe8 Mon Sep 17 00:00:00 2001 From: Bhuvnesh Kumar Date: Thu, 16 Aug 2018 12:28:15 -0700 Subject: [PATCH 01/11] dashboard and controllerInformation --- pom.xml | 4 +- .../AccountMetricStatisticsCollector.java | 25 ++++- .../NamespaceMetricStatisticsCollector.java | 13 ++- .../extensions/aws/config/Configuration.java | 23 +++++ .../aws/config/ControllerInformation.java | 91 +++++++++++++++++++ .../aws/config/DashboardConfig.java | 63 +++++++++++++ ...amespaceMetricStatisticsCollectorTest.java | 19 ++-- 7 files changed, 223 insertions(+), 15 deletions(-) create mode 100644 src/main/java/com/appdynamics/extensions/aws/config/ControllerInformation.java create mode 100644 src/main/java/com/appdynamics/extensions/aws/config/DashboardConfig.java diff --git a/pom.xml b/pom.xml index 59202e9..7635e53 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.appdynamics.extensions aws-cloudwatch-exts-commons - 2.0.1 + 2.0.2 jar aws-cloudwatch-exts-commons @@ -43,7 +43,7 @@ com.appdynamics appd-exts-commons - 2.1.0 + 2.1.1 com.fasterxml.woodstox diff --git a/src/main/java/com/appdynamics/extensions/aws/collectors/AccountMetricStatisticsCollector.java b/src/main/java/com/appdynamics/extensions/aws/collectors/AccountMetricStatisticsCollector.java index d5723a0..6302826 100644 --- a/src/main/java/com/appdynamics/extensions/aws/collectors/AccountMetricStatisticsCollector.java +++ b/src/main/java/com/appdynamics/extensions/aws/collectors/AccountMetricStatisticsCollector.java @@ -17,10 +17,7 @@ import com.amazonaws.auth.AWSCredentials; import com.appdynamics.extensions.MonitorExecutorService; import com.appdynamics.extensions.MonitorThreadPoolExecutor; -import com.appdynamics.extensions.aws.config.Account; -import com.appdynamics.extensions.aws.config.CredentialsDecryptionConfig; -import com.appdynamics.extensions.aws.config.MetricsTimeRange; -import com.appdynamics.extensions.aws.config.ProxyConfig; +import com.appdynamics.extensions.aws.config.*; import com.appdynamics.extensions.aws.exceptions.AwsException; import com.appdynamics.extensions.aws.metric.AccountMetricStatistics; import com.appdynamics.extensions.aws.metric.RegionMetricStatistics; @@ -72,6 +69,10 @@ public class AccountMetricStatisticsCollector implements Callable private LongAdder awsRequestsCounter = new LongAdder(); private String metricPrefix; + private DashboardConfig dashboardConfig; + private ControllerInformation controllerInformation; private NamespaceMetricStatisticsCollector(Builder builder) { this.accounts = builder.accounts; @@ -72,6 +76,9 @@ private NamespaceMetricStatisticsCollector(Builder builder) { this.credentialsDecryptionConfig = builder.credentialsDecryptionConfig; this.proxyConfig = builder.proxyConfig; this.metricPrefix = builder.metricPrefix; + this.dashboardConfig = builder.dashboardConfig; + this.controllerInformation = builder.controllerInfo; + } /** @@ -198,16 +205,20 @@ public static class Builder { private CredentialsDecryptionConfig credentialsDecryptionConfig; private ProxyConfig proxyConfig; private String metricPrefix; + private DashboardConfig dashboardConfig; + private ControllerInformation controllerInfo; public Builder(List accounts, ConcurrencyConfig concurrencyConfig, MetricsConfig metricsConfig, - MetricsProcessor metricsProcessor, String metricPrefix) { + MetricsProcessor metricsProcessor, String metricPrefix, DashboardConfig dashboardConfig, ControllerInformation controllerInformation) { this.accounts = accounts; this.concurrencyConfig = concurrencyConfig; this.metricsConfig = metricsConfig; this.metricsProcessor = metricsProcessor; this.metricPrefix = metricPrefix; + this.dashboardConfig = dashboardConfig; + this.controllerInfo = controllerInformation; } public Builder withCredentialsDecryptionConfig(CredentialsDecryptionConfig credentialsDecryptionConfig) { diff --git a/src/main/java/com/appdynamics/extensions/aws/config/Configuration.java b/src/main/java/com/appdynamics/extensions/aws/config/Configuration.java index 8e6d30c..229ed17 100644 --- a/src/main/java/com/appdynamics/extensions/aws/config/Configuration.java +++ b/src/main/java/com/appdynamics/extensions/aws/config/Configuration.java @@ -7,6 +7,8 @@ package com.appdynamics.extensions.aws.config; +import com.appdynamics.extensions.conf.ControllerInfo; + import java.util.List; import java.util.Map; @@ -37,6 +39,27 @@ public class Configuration { private List dimensions; + private ControllerInformation controllerInfo; + + public DashboardConfig getCustomDashboard() { + return customDashboard; + } + + public void setCustomDashboard(DashboardConfig dashboardConfig) { + this.customDashboard = dashboardConfig; + } + + private DashboardConfig customDashboard; + + public ControllerInformation getControllerInfo() { + return controllerInfo; + } + + public void setControllerInfo(ControllerInformation controllerInformation) { + this.controllerInfo = controllerInformation; + } + + public List getAccounts() { return accounts; } diff --git a/src/main/java/com/appdynamics/extensions/aws/config/ControllerInformation.java b/src/main/java/com/appdynamics/extensions/aws/config/ControllerInformation.java new file mode 100644 index 0000000..afa01eb --- /dev/null +++ b/src/main/java/com/appdynamics/extensions/aws/config/ControllerInformation.java @@ -0,0 +1,91 @@ +/* + * Copyright 2018 . AppDynamics LLC and its affiliates. + * All Rights Reserved. + * This is unpublished proprietary source code of AppDynamics LLC and its affiliates. + * The copyright notice above does not evidence any actual or intended publication of such source code. + * + */ + +package com.appdynamics.extensions.aws.config; + +/** + * Created by bhuvnesh.kumar on 8/16/18. + */ +public class ControllerInformation { + + private String host; + private Integer port; + private String account; + private String username; + private String password; + private String useSsl; + private String encryptedPassword; + private String encryptionKey; + + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public Integer getPort() { + return port; + } + + public void setPort(Integer port) { + this.port = port; + } + + public String getAccount() { + return account; + } + + public void setAccount(String account) { + this.account = account; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getUseSsl() { + return useSsl; + } + + public void setUseSsl(String useSsl) { + this.useSsl = useSsl; + } + + public String getEncryptedPassword() { + return encryptedPassword; + } + + public void setEncryptedPassword(String encryptedPassword) { + this.encryptedPassword = encryptedPassword; + } + + public String getEncryptionKey() { + return encryptionKey; + } + + public void setEncryptionKey(String encryptionKey) { + this.encryptionKey = encryptionKey; + } + + +} diff --git a/src/main/java/com/appdynamics/extensions/aws/config/DashboardConfig.java b/src/main/java/com/appdynamics/extensions/aws/config/DashboardConfig.java new file mode 100644 index 0000000..c11c801 --- /dev/null +++ b/src/main/java/com/appdynamics/extensions/aws/config/DashboardConfig.java @@ -0,0 +1,63 @@ +/* + * Copyright 2018 . AppDynamics LLC and its affiliates. + * All Rights Reserved. + * This is unpublished proprietary source code of AppDynamics LLC and its affiliates. + * The copyright notice above does not evidence any actual or intended publication of such source code. + * + */ + +package com.appdynamics.extensions.aws.config; + +/** + * Created by bhuvnesh.kumar on 8/16/18. + */ +public class DashboardConfig { + + private Boolean enabled ; + private String dashboardName; + private Integer executionFrequencyMinutes ; + private String pathToSIMDashboard; + private String pathToNormalDashboard; + + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public String getDashboardName() { + return dashboardName; + } + + public void setDashboardName(String dashboardName) { + this.dashboardName = dashboardName; + } + + public Integer getExecutionFrequencyMinutes() { + return executionFrequencyMinutes; + } + + public void setExecutionFrequencyMinutes(Integer executionFrequencyMinutes) { + this.executionFrequencyMinutes = executionFrequencyMinutes; + } + + public String getPathToSIMDashboard() { + return pathToSIMDashboard; + } + + public void setPathToSIMDashboard(String pathToSIMDashboard) { + this.pathToSIMDashboard = pathToSIMDashboard; + } + + public String getPathToNormalDashboard() { + return pathToNormalDashboard; + } + + public void setPathToNormalDashboard(String pathToNormalDashboard) { + this.pathToNormalDashboard = pathToNormalDashboard; + } + + +} diff --git a/src/test/java/com/appdynamics/extensions/aws/collectors/NamespaceMetricStatisticsCollectorTest.java b/src/test/java/com/appdynamics/extensions/aws/collectors/NamespaceMetricStatisticsCollectorTest.java index 911e506..4a81b56 100644 --- a/src/test/java/com/appdynamics/extensions/aws/collectors/NamespaceMetricStatisticsCollectorTest.java +++ b/src/test/java/com/appdynamics/extensions/aws/collectors/NamespaceMetricStatisticsCollectorTest.java @@ -17,13 +17,7 @@ import static org.mockito.Mockito.when; import static org.powermock.api.mockito.PowerMockito.whenNew; -import com.appdynamics.extensions.aws.config.Account; -import com.appdynamics.extensions.aws.config.ConcurrencyConfig; -import com.appdynamics.extensions.aws.config.CredentialsDecryptionConfig; -import com.appdynamics.extensions.aws.config.IncludeMetric; -import com.appdynamics.extensions.aws.config.MetricsConfig; -import com.appdynamics.extensions.aws.config.MetricsTimeRange; -import com.appdynamics.extensions.aws.config.ProxyConfig; +import com.appdynamics.extensions.aws.config.*; import com.appdynamics.extensions.aws.dto.AWSMetric; import com.appdynamics.extensions.aws.metric.AccountMetricStatistics; import com.appdynamics.extensions.aws.metric.MetricStatistic; @@ -64,6 +58,13 @@ public class NamespaceMetricStatisticsCollectorTest { @Mock private ConcurrencyConfig mockConcurrencyConfig; + @Mock + private DashboardConfig mockDashboardConfig; + + @Mock + private ControllerInformation mockControllerInformation; + + @SuppressWarnings("unchecked") @Test public void testMetricsRetrievalIsSuccessful() throws Exception { @@ -96,6 +97,8 @@ public void testMetricsRetrievalIsSuccessful() throws Exception { when(mockBuilder.withRateLimiter(any(RateLimiter.class))).thenReturn(mockBuilder); when(mockBuilder.withAWSRequestCounter(any(LongAdder.class))).thenReturn(mockBuilder); when(mockBuilder.withPrefix(anyString())).thenReturn(mockBuilder); + when(mockBuilder.withDashboardConfig(any(DashboardConfig.class))).thenReturn(mockBuilder); + when(mockBuilder.withControllerInformation(any(ControllerInformation.class))).thenReturn(mockBuilder); when(mockBuilder.build()).thenReturn(mockAccountStatsCollector1, mockAccountStatsCollector2); @@ -112,7 +115,7 @@ public void testMetricsRetrievalIsSuccessful() throws Exception { classUnderTest = new NamespaceMetricStatisticsCollector.Builder(testAccounts, mockConcurrencyConfig, mockMetricsConfig, - mockMetricsProcessor, "Test|Prefix") + mockMetricsProcessor, "Test|Prefix", mockDashboardConfig, mockControllerInformation) .build(); classUnderTest.call(); From d998d2b3db3c65644bb99af533019dede5ad517a Mon Sep 17 00:00:00 2001 From: Bhuvnesh Kumar Date: Mon, 24 Sep 2018 14:06:37 -0700 Subject: [PATCH 02/11] Updates to get dashboard and controllerInfo data for other modules --- .gitignore | 1 + aws-cloudwatch-exts-commons.iml | 58 +++++++++++++++++++ pom.xml | 2 +- .../AccountMetricStatisticsCollector.java | 44 ++++---------- .../NamespaceMetricStatisticsCollector.java | 24 ++------ .../extensions/aws/config/Configuration.java | 2 - ...amespaceMetricStatisticsCollectorTest.java | 2 - 7 files changed, 76 insertions(+), 57 deletions(-) create mode 100644 aws-cloudwatch-exts-commons.iml diff --git a/.gitignore b/.gitignore index ad1c6a2..bf0f551 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ target/ class_diagram.ucls .idea +.iml \ No newline at end of file diff --git a/aws-cloudwatch-exts-commons.iml b/aws-cloudwatch-exts-commons.iml new file mode 100644 index 0000000..dcfe831 --- /dev/null +++ b/aws-cloudwatch-exts-commons.iml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 7635e53..6753ad6 100644 --- a/pom.xml +++ b/pom.xml @@ -43,7 +43,7 @@ com.appdynamics appd-exts-commons - 2.1.1 + 2.1.3 com.fasterxml.woodstox diff --git a/src/main/java/com/appdynamics/extensions/aws/collectors/AccountMetricStatisticsCollector.java b/src/main/java/com/appdynamics/extensions/aws/collectors/AccountMetricStatisticsCollector.java index 6302826..d2f872d 100644 --- a/src/main/java/com/appdynamics/extensions/aws/collectors/AccountMetricStatisticsCollector.java +++ b/src/main/java/com/appdynamics/extensions/aws/collectors/AccountMetricStatisticsCollector.java @@ -7,17 +7,14 @@ package com.appdynamics.extensions.aws.collectors; -import static com.appdynamics.extensions.aws.Constants.DEFAULT_MAX_ERROR_RETRY; -import static com.appdynamics.extensions.aws.Constants.DEFAULT_NO_OF_THREADS; -import static com.appdynamics.extensions.aws.util.AWSUtil.createAWSClientConfiguration; -import static com.appdynamics.extensions.aws.util.AWSUtil.createAWSCredentials; -import static com.appdynamics.extensions.aws.validators.Validator.validateAccount; - import com.amazonaws.ClientConfiguration; import com.amazonaws.auth.AWSCredentials; import com.appdynamics.extensions.MonitorExecutorService; import com.appdynamics.extensions.MonitorThreadPoolExecutor; -import com.appdynamics.extensions.aws.config.*; +import com.appdynamics.extensions.aws.config.Account; +import com.appdynamics.extensions.aws.config.CredentialsDecryptionConfig; +import com.appdynamics.extensions.aws.config.MetricsTimeRange; +import com.appdynamics.extensions.aws.config.ProxyConfig; import com.appdynamics.extensions.aws.exceptions.AwsException; import com.appdynamics.extensions.aws.metric.AccountMetricStatistics; import com.appdynamics.extensions.aws.metric.RegionMetricStatistics; @@ -29,14 +26,15 @@ import java.util.List; import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.FutureTask; -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; +import java.util.concurrent.*; import java.util.concurrent.atomic.LongAdder; +import static com.appdynamics.extensions.aws.Constants.DEFAULT_MAX_ERROR_RETRY; +import static com.appdynamics.extensions.aws.Constants.DEFAULT_NO_OF_THREADS; +import static com.appdynamics.extensions.aws.util.AWSUtil.createAWSClientConfiguration; +import static com.appdynamics.extensions.aws.util.AWSUtil.createAWSCredentials; +import static com.appdynamics.extensions.aws.validators.Validator.validateAccount; + /** * Collects statistics (of specified regions) for specified account * @@ -69,10 +67,6 @@ public class AccountMetricStatisticsCollector implements Callable Date: Mon, 24 Sep 2018 14:11:38 -0700 Subject: [PATCH 03/11] Deleting the IML file --- aws-cloudwatch-exts-commons.iml | 58 --------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 aws-cloudwatch-exts-commons.iml diff --git a/aws-cloudwatch-exts-commons.iml b/aws-cloudwatch-exts-commons.iml deleted file mode 100644 index dcfe831..0000000 --- a/aws-cloudwatch-exts-commons.iml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 07c0901d84d13bfec565a1bcf1d3aab33c15ad69 Mon Sep 17 00:00:00 2001 From: Bhuvnesh Kumar Date: Mon, 24 Sep 2018 14:21:32 -0700 Subject: [PATCH 04/11] updating pom.xml version --- aws-cloudwatch-exts-commons.iml | 58 +++++++++++++++++++++++++++++++++ pom.xml | 2 +- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 aws-cloudwatch-exts-commons.iml diff --git a/aws-cloudwatch-exts-commons.iml b/aws-cloudwatch-exts-commons.iml new file mode 100644 index 0000000..dcfe831 --- /dev/null +++ b/aws-cloudwatch-exts-commons.iml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 6753ad6..c3eef2f 100644 --- a/pom.xml +++ b/pom.xml @@ -43,7 +43,7 @@ com.appdynamics appd-exts-commons - 2.1.3 + 2.1.2 com.fasterxml.woodstox From 4a2788139185209ed36f7ced01036ec812e2b73f Mon Sep 17 00:00:00 2001 From: Bhuvnesh Kumar Date: Thu, 27 Sep 2018 14:49:03 -0700 Subject: [PATCH 05/11] adding test to verify the configuration object is created as expected with the new addition of ControllerInfo and dashboard fields --- src/main/resources/conf/config-sample.yaml | 26 +- src/main/resources/conf/config-template.yaml | 26 +- .../ControllerInfoAndDashboardConfigTest.java | 46 ++++ .../test-controllerInfo-dashboard-config.yml | 237 ++++++++++++++++++ 4 files changed, 333 insertions(+), 2 deletions(-) create mode 100644 src/test/java/com/appdynamics/extensions/aws/config/ControllerInfoAndDashboardConfigTest.java create mode 100644 src/test/resources/conf/test-controllerInfo-dashboard-config.yml diff --git a/src/main/resources/conf/config-sample.yaml b/src/main/resources/conf/config-sample.yaml index 05e1499..300d096 100644 --- a/src/main/resources/conf/config-sample.yaml +++ b/src/main/resources/conf/config-sample.yaml @@ -105,4 +105,28 @@ metricsConfig: #This will create it in specific Tier/Component. Make sure to replace with the appropriate one from your environment. #To find the in your environment, please follow the screenshot https://docs.appdynamics.com/display/PRO42/Build+a+Monitoring+Extension+Using+Java -metricPrefix: "Server|Component:|Custom Metrics|Amazon EC2|" \ No newline at end of file +metricPrefix: "Server|Component:|Custom Metrics|Amazon EC2|" + +# Generate a custom dashboard based on the provided template +customDashboard: + enabled: true + dashboardName: "AWS ELB Monitor Dashboard" + + # Update the path to the dashboard file. + pathToSIMDashboard: "monitors/AWSELBMonitor/normalDashboard.json" + pathToNormalDashboard: "monitors/AWSELBMonitor/normalDashboard.json" + +# To upload the dashboard, please create a user from Controller UI or +# add the credentials of an existing user. + +controllerInfo: + host: "" + port: "" + account: "" + username: "" + password: "" + # OPTIONAL Items + encryptedPassword: "" + encryptionKey: "" + controllerSslEnabled: "" + diff --git a/src/main/resources/conf/config-template.yaml b/src/main/resources/conf/config-template.yaml index a03da6e..3f75219 100644 --- a/src/main/resources/conf/config-template.yaml +++ b/src/main/resources/conf/config-template.yaml @@ -110,4 +110,28 @@ metricsConfig: #This will create it in specific Tier/Component. Make sure to replace with the appropriate one from your environment. #To find the in your environment, please follow the screenshot https://docs.appdynamics.com/display/PRO42/Build+a+Monitoring+Extension+Using+Java -metricPrefix: "Server|Component:|Custom Metrics|Amazon EC2|" \ No newline at end of file +metricPrefix: "Server|Component:|Custom Metrics|Amazon EC2|" + +# Generate a custom dashboard based on the provided template +customDashboard: + enabled: true + dashboardName: "AWS ELB Monitor Dashboard" + + # Update the path to the dashboard file. + pathToSIMDashboard: "monitors/AWSELBMonitor/normalDashboard.json" + pathToNormalDashboard: "monitors/AWSELBMonitor/normalDashboard.json" + +# To upload the dashboard, please create a user from Controller UI or +# add the credentials of an existing user. + +controllerInfo: + host: "" + port: "" + account: "" + username: "" + password: "" + # OPTIONAL Items + encryptedPassword: "" + encryptionKey: "" + controllerSslEnabled: "" + diff --git a/src/test/java/com/appdynamics/extensions/aws/config/ControllerInfoAndDashboardConfigTest.java b/src/test/java/com/appdynamics/extensions/aws/config/ControllerInfoAndDashboardConfigTest.java new file mode 100644 index 0000000..fb3a18d --- /dev/null +++ b/src/test/java/com/appdynamics/extensions/aws/config/ControllerInfoAndDashboardConfigTest.java @@ -0,0 +1,46 @@ +/* + * Copyright 2018 . AppDynamics LLC and its affiliates. + * All Rights Reserved. + * This is unpublished proprietary source code of AppDynamics LLC and its affiliates. + * The copyright notice above does not evidence any actual or intended publication of such source code. + * + */ + +package com.appdynamics.extensions.aws.config; + +import org.junit.Assert; +import org.junit.Test; +import org.yaml.snakeyaml.Yaml; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; + +/** + * Created by bhuvnesh.kumar on 9/27/18. + */ +public class ControllerInfoAndDashboardConfigTest { + + // this test verifies that a valid Configuration object is created when using the config with sections of controllerInfo and customDashboard present + + @Test + public void ConfigAndDashboardPresentTest() throws IOException { + + Yaml yaml = new Yaml(); + File file = new File("src/test/resources/conf/test-controllerInfo-dashboard-config.yml"); + Configuration config = yaml.loadAs(new FileInputStream(file), Configuration.class); + + Assert.assertTrue(config.getCustomDashboard().getEnabled() == true); + Assert.assertTrue(config.getCustomDashboard().getDashboardName().equals("AWS ELB Monitor Dashboard")); + Assert.assertTrue(config.getCustomDashboard().getPathToNormalDashboard().equals("monitors/AWSELBMonitor/normalDashboard.json")); + Assert.assertTrue(config.getCustomDashboard().getPathToSIMDashboard().equals("monitors/AWSELBMonitor/simDashboard.json")); + + Assert.assertTrue(config.getControllerInfo().getAccount().equals("account")); + Assert.assertTrue(config.getControllerInfo().getUsername().equals("admin")); + Assert.assertTrue(config.getControllerInfo().getPassword().equals("root")); + Assert.assertTrue(config.getControllerInfo().getHost().equals("host")); + Assert.assertTrue(config.getControllerInfo().getPort().equals(9000)); + + } + +} diff --git a/src/test/resources/conf/test-controllerInfo-dashboard-config.yml b/src/test/resources/conf/test-controllerInfo-dashboard-config.yml new file mode 100644 index 0000000..028d1e7 --- /dev/null +++ b/src/test/resources/conf/test-controllerInfo-dashboard-config.yml @@ -0,0 +1,237 @@ + +#This will create this metric in all the tiers, under this path. Please make sure to have a trailing | +#metricPrefix: "Custom Metrics|Amazon ELB|" + +#This will create it in specific Tier aka Component. Replace . Please make sure to have a trailing |. +#To find out the COMPONENT_ID, please see the screen shot here https://docs.appdynamics.com/display/PRO42/Build+a+Monitoring+Extension+Using+Java + +# Metric list can be found here : https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/elb-metricscollected.html + +metricPrefix: "Server|Component:29|Custom Metrics|Amazon ELB|" + +accounts: + - awsAccessKey: "" + awsSecretKey: "7ETG/" + displayAccountName: "Appd" + + # Regions where cloudwatch is registered + # Allowed values: ap-southeast-1, ap-southeast-2, ap-northeast-1, eu-central-1, + # us-east-1, eu-west-1, us-west-1, us-west-2, sa-east-1 + # + regions: ["us-east-1"] + +#Provide Encryption key for Encrypted password. +credentialsDecryptionConfig: + enableDecryption: "false" + encryptionKey: + +proxyConfig: + host: + port: + username: + password: + +# Classic (namespace : "AWS/ELB") +# Dimensions : AvailabilityZone, LoadBalancerName + +# dimensions: +# - name: "LoadBalancerName" +# displayName: "Load Balancer Name" +# values: [] +# - name: "AvailabilityZone" +# displayName: "Availability Zone" +# values: [] + +dimensions: + - name: "LoadBalancerName" + displayName: "LoadBalancer Name" + values: [".*"] + - name: "AvailabilityZone" + displayName: "Availability Zone" + values: [".*"] + +# Global metrics config for all accounts +metricsConfig: + + # By default, all metrics retrieved from cloudwatch are 'Average' values. + # This option allows you to override the metric type. + # + # Allowed statTypes are: ave, max, min, sum, samplecount + # + # Note: Irrespective of the metric type, value will still be reported as + # Observed value to the Controller + includeMetrics: + - name: "BackendConnectionErrors" + alias: "Backend Connection Errors" + statType: "sum" + aggregationType: "AVERAGE" + timeRollUpType: "AVERAGE" + clusterRollUpType: "INDIVIDUAL" + delta: false + multiplier: 1 + - name: "HealthyHostCount" + alias: "Healthy Host Count" + statType: "ave" + aggregationType: "AVERAGE" + timeRollUpType: "AVERAGE" + clusterRollUpType: "INDIVIDUAL" + delta: false + multiplier: 1 + - name: "HTTPCode_Backend_2XX" + alias: "HTTPCode_Backend_2XX" + statType: "sum" + aggregationType: "AVERAGE" + timeRollUpType: "AVERAGE" + clusterRollUpType: "INDIVIDUAL" + delta: false + multiplier: 1 + - name: "HTTPCode_Backend_3XX" + alias: "HTTPCode_Backend_3XX" + statType: "sum" + aggregationType: "AVERAGE" + timeRollUpType: "AVERAGE" + clusterRollUpType: "INDIVIDUAL" + delta: false + multiplier: 1 + - name: "HTTPCode_Backend_4XX" + alias: "HTTPCode_Backend_4XX" + statType: "sum" + aggregationType: "AVERAGE" + timeRollUpType: "AVERAGE" + clusterRollUpType: "INDIVIDUAL" + delta: false + multiplier: 1 + - name: "HTTPCode_Backend_5XX" + alias: "HTTPCode_Backend_5XX" + statType: "sum" + aggregationType: "AVERAGE" + timeRollUpType: "AVERAGE" + clusterRollUpType: "INDIVIDUAL" + delta: false + multiplier: 1 + - name: "HTTPCode_ELB_4XX" + alias: "HTTPCode_ELB_4XX" + statType: "sum" + aggregationType: "AVERAGE" + timeRollUpType: "AVERAGE" + clusterRollUpType: "INDIVIDUAL" + delta: false + multiplier: 1 + - name: "HTTPCode_ELB_5XX" + alias: "HTTPCode_ELB_5XX" + statType: "sum" + aggregationType: "AVERAGE" + timeRollUpType: "AVERAGE" + clusterRollUpType: "INDIVIDUAL" + delta: false + multiplier: 1 + - name: "Latency" + alias: "Latencyx1000" + statType: "ave" + aggregationType: "AVERAGE" + timeRollUpType: "AVERAGE" + clusterRollUpType: "INDIVIDUAL" + delta: false + multiplier: 1000 + - name: "RequestCount" + alias: "Request Count" + statType: "sum" + aggregationType: "AVERAGE" + timeRollUpType: "AVERAGE" + clusterRollUpType: "INDIVIDUAL" + delta: false + multiplier: 1 + - name: "SpilloverCount" + alias: "Spillover Count" + statType: "sum" + aggregationType: "AVERAGE" + timeRollUpType: "AVERAGE" + clusterRollUpType: "INDIVIDUAL" + delta: false + multiplier: 1 + - name: "SurgeQueueLength" + alias: "Surge Queue Length" + statType: "ave" + aggregationType: "AVERAGE" + timeRollUpType: "AVERAGE" + clusterRollUpType: "INDIVIDUAL" + delta: false + multiplier: 1 + - name: "UnHealthyHostCount" + alias: "UnHealthy Host Count" + statType: "ave" + aggregationType: "AVERAGE" + timeRollUpType: "AVERAGE" + clusterRollUpType: "INDIVIDUAL" + delta: false + multiplier: 1 + + + metricsTimeRange: + startTimeInMinsBeforeNow: 5 + endTimeInMinsBeforeNow: 0 + + # Rate limit ( per second ) for GetMetricStatistics, default value is 400. https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_limits.html + getMetricStatisticsRateLimit: 400 + + # + # The max number of retry attempts for failed retryable requests + # (ex: 5xx error responses from a service) or throttling errors + # + maxErrorRetrySize: 3 + +#Allowed values are Basic and Detailed. Refer https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-cloudwatch-new.html for more information +# Basic will fire CloudWatch API calls every 5 minutes +# Detailed will fire CloudWatch API calls every 1 minutes +cloudWatchMonitoring: "Basic" + +concurrencyConfig: + noOfAccountThreads: 3 + noOfRegionThreadsPerAccount: 3 + noOfMetricThreadsPerRegion: 3 + #Thread timeout in seconds + threadTimeOut: 30 + +# Generate a custom dashboard based on the provided template +customDashboard: + enabled: true + dashboardName: "AWS ELB Monitor Dashboard" + + # Update the path to the dashboard file. + pathToSIMDashboard: "monitors/AWSELBMonitor/simDashboard.json" + pathToNormalDashboard: "monitors/AWSELBMonitor/normalDashboard.json" + +# To upload the dashboard, please create a user from Controller UI or +# add the credentials of an existing user. + +controllerInfo: + host: "host" + port: 9000 + account: "account" + username: "admin" + password: "root" + # OPTIONAL Items + encryptedPassword: "" + encryptionKey: "" + + +regionEndPoints: + us-east-1 : monitoring.us-east-1.amazonaws.com + us-east-2 : monitoring.us-east-2.amazonaws.com + us-west-1 : monitoring.us-west-1.amazonaws.com + us-west-2 : monitoring.us-west-2.amazonaws.com + ap-northeast-1 : monitoring.ap-northeast-1.amazonaws.com + ap-northeast-2: monitoring.ap-northeast-2.amazonaws.com + ap-northeast-3 : monitoring.ap-northeast-3.amazonaws.com + ap-south-1 : monitoring.ap-south-1.amazonaws.com + ap-southeast-1 : monitoring.ap-southeast-1.amazonaws.com + ap-southeast-2 : monitoring.ap-southeast-2.amazonaws.com + ca-central-1 : monitoring.ca-central-1.amazonaws.com + cn-north-1 : monitoring.cn-north-1.amazonaws.com.cn + cn-northwest-1 : monitoring.cn-northwest-1.amazonaws.com.cn + eu-central-1 : monitoring.eu-central-1.amazonaws.com + eu-west-1 : monitoring.eu-west-1.amazonaws.com + eu-west-2 : monitoring.eu-west-2.amazonaws.com + eu-west-3 : monitoring.eu-west-3.amazonaws.com + sa-east-1 : monitoring.sa-east-1.amazonaws.com + us-gov-west-1 : monitoring.us-gov-west-1.amazonaws.com From 226b575363cb793644155fbed904f8296e04f47e Mon Sep 17 00:00:00 2001 From: Bhuvnesh Kumar Date: Wed, 24 Oct 2018 12:11:35 -0700 Subject: [PATCH 06/11] adding the dashboard presence period field in the config --- aws-cloudwatch-exts-commons.iml | 2 +- .../extensions/aws/config/DashboardConfig.java | 13 +++++++++++-- .../ControllerInfoAndDashboardConfigTest.java | 1 + .../conf/test-controllerInfo-dashboard-config.yml | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/aws-cloudwatch-exts-commons.iml b/aws-cloudwatch-exts-commons.iml index dcfe831..b346dac 100644 --- a/aws-cloudwatch-exts-commons.iml +++ b/aws-cloudwatch-exts-commons.iml @@ -1,5 +1,5 @@ - + diff --git a/src/main/java/com/appdynamics/extensions/aws/config/DashboardConfig.java b/src/main/java/com/appdynamics/extensions/aws/config/DashboardConfig.java index c11c801..ea76b50 100644 --- a/src/main/java/com/appdynamics/extensions/aws/config/DashboardConfig.java +++ b/src/main/java/com/appdynamics/extensions/aws/config/DashboardConfig.java @@ -13,11 +13,20 @@ */ public class DashboardConfig { - private Boolean enabled ; + private Boolean enabled; private String dashboardName; - private Integer executionFrequencyMinutes ; + private Integer executionFrequencyMinutes; private String pathToSIMDashboard; private String pathToNormalDashboard; + private Integer periodToCheckDashboardPresenceInSeconds; + + public Integer getPeriodToCheckDashboardPresenceInSeconds() { + return periodToCheckDashboardPresenceInSeconds; + } + + public void setPeriodToCheckDashboardPresenceInSeconds(Integer periodToCheckDashboardPresenceInSeconds) { + this.periodToCheckDashboardPresenceInSeconds = periodToCheckDashboardPresenceInSeconds; + } public Boolean getEnabled() { return enabled; diff --git a/src/test/java/com/appdynamics/extensions/aws/config/ControllerInfoAndDashboardConfigTest.java b/src/test/java/com/appdynamics/extensions/aws/config/ControllerInfoAndDashboardConfigTest.java index fb3a18d..b2ec50e 100644 --- a/src/test/java/com/appdynamics/extensions/aws/config/ControllerInfoAndDashboardConfigTest.java +++ b/src/test/java/com/appdynamics/extensions/aws/config/ControllerInfoAndDashboardConfigTest.java @@ -34,6 +34,7 @@ public void ConfigAndDashboardPresentTest() throws IOException { Assert.assertTrue(config.getCustomDashboard().getDashboardName().equals("AWS ELB Monitor Dashboard")); Assert.assertTrue(config.getCustomDashboard().getPathToNormalDashboard().equals("monitors/AWSELBMonitor/normalDashboard.json")); Assert.assertTrue(config.getCustomDashboard().getPathToSIMDashboard().equals("monitors/AWSELBMonitor/simDashboard.json")); + Assert.assertTrue(config.getCustomDashboard().getPeriodToCheckDashboardPresenceInSeconds().equals(300)); Assert.assertTrue(config.getControllerInfo().getAccount().equals("account")); Assert.assertTrue(config.getControllerInfo().getUsername().equals("admin")); diff --git a/src/test/resources/conf/test-controllerInfo-dashboard-config.yml b/src/test/resources/conf/test-controllerInfo-dashboard-config.yml index 028d1e7..832f62b 100644 --- a/src/test/resources/conf/test-controllerInfo-dashboard-config.yml +++ b/src/test/resources/conf/test-controllerInfo-dashboard-config.yml @@ -200,6 +200,7 @@ customDashboard: # Update the path to the dashboard file. pathToSIMDashboard: "monitors/AWSELBMonitor/simDashboard.json" pathToNormalDashboard: "monitors/AWSELBMonitor/normalDashboard.json" + periodToCheckDashboardPresenceInSeconds: 300 # To upload the dashboard, please create a user from Controller UI or # add the credentials of an existing user. From 6c4f9484d45a357ad83d2895dfa82a063f1dc22b Mon Sep 17 00:00:00 2001 From: Bhuvnesh Kumar Date: Fri, 26 Oct 2018 18:15:01 -0700 Subject: [PATCH 07/11] change variable name in dashboard config --- aws-cloudwatch-exts-commons.iml | 6 +++--- .../extensions/aws/config/DashboardConfig.java | 11 ++++++----- .../config/ControllerInfoAndDashboardConfigTest.java | 2 +- .../conf/test-controllerInfo-dashboard-config.yml | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/aws-cloudwatch-exts-commons.iml b/aws-cloudwatch-exts-commons.iml index b346dac..e0ae638 100644 --- a/aws-cloudwatch-exts-commons.iml +++ b/aws-cloudwatch-exts-commons.iml @@ -23,9 +23,9 @@ - - - + + + diff --git a/src/main/java/com/appdynamics/extensions/aws/config/DashboardConfig.java b/src/main/java/com/appdynamics/extensions/aws/config/DashboardConfig.java index ea76b50..fb7c9ab 100644 --- a/src/main/java/com/appdynamics/extensions/aws/config/DashboardConfig.java +++ b/src/main/java/com/appdynamics/extensions/aws/config/DashboardConfig.java @@ -18,14 +18,15 @@ public class DashboardConfig { private Integer executionFrequencyMinutes; private String pathToSIMDashboard; private String pathToNormalDashboard; - private Integer periodToCheckDashboardPresenceInSeconds; + private Integer periodicDashboardCheckInSeconds; - public Integer getPeriodToCheckDashboardPresenceInSeconds() { - return periodToCheckDashboardPresenceInSeconds; + + public Integer getPeriodicDashboardCheckInSeconds() { + return periodicDashboardCheckInSeconds; } - public void setPeriodToCheckDashboardPresenceInSeconds(Integer periodToCheckDashboardPresenceInSeconds) { - this.periodToCheckDashboardPresenceInSeconds = periodToCheckDashboardPresenceInSeconds; + public void setPeriodicDashboardCheckInSeconds(Integer periodicDashboardCheckInSeconds) { + this.periodicDashboardCheckInSeconds = periodicDashboardCheckInSeconds; } public Boolean getEnabled() { diff --git a/src/test/java/com/appdynamics/extensions/aws/config/ControllerInfoAndDashboardConfigTest.java b/src/test/java/com/appdynamics/extensions/aws/config/ControllerInfoAndDashboardConfigTest.java index b2ec50e..688fe25 100644 --- a/src/test/java/com/appdynamics/extensions/aws/config/ControllerInfoAndDashboardConfigTest.java +++ b/src/test/java/com/appdynamics/extensions/aws/config/ControllerInfoAndDashboardConfigTest.java @@ -34,7 +34,7 @@ public void ConfigAndDashboardPresentTest() throws IOException { Assert.assertTrue(config.getCustomDashboard().getDashboardName().equals("AWS ELB Monitor Dashboard")); Assert.assertTrue(config.getCustomDashboard().getPathToNormalDashboard().equals("monitors/AWSELBMonitor/normalDashboard.json")); Assert.assertTrue(config.getCustomDashboard().getPathToSIMDashboard().equals("monitors/AWSELBMonitor/simDashboard.json")); - Assert.assertTrue(config.getCustomDashboard().getPeriodToCheckDashboardPresenceInSeconds().equals(300)); + Assert.assertTrue(config.getCustomDashboard().getPeriodicDashboardCheckInSeconds().equals(300)); Assert.assertTrue(config.getControllerInfo().getAccount().equals("account")); Assert.assertTrue(config.getControllerInfo().getUsername().equals("admin")); diff --git a/src/test/resources/conf/test-controllerInfo-dashboard-config.yml b/src/test/resources/conf/test-controllerInfo-dashboard-config.yml index 832f62b..099ef65 100644 --- a/src/test/resources/conf/test-controllerInfo-dashboard-config.yml +++ b/src/test/resources/conf/test-controllerInfo-dashboard-config.yml @@ -200,7 +200,7 @@ customDashboard: # Update the path to the dashboard file. pathToSIMDashboard: "monitors/AWSELBMonitor/simDashboard.json" pathToNormalDashboard: "monitors/AWSELBMonitor/normalDashboard.json" - periodToCheckDashboardPresenceInSeconds: 300 + periodicDashboardCheckInSeconds: 300 # To upload the dashboard, please create a user from Controller UI or # add the credentials of an existing user. From f164e6ae662828cc1b82cbb109671bad64bbbed9 Mon Sep 17 00:00:00 2001 From: Bhuvnesh Kumar Date: Mon, 26 Nov 2018 12:48:00 -0800 Subject: [PATCH 08/11] updating config files --- src/main/resources/conf/config-sample.yaml | 1 + src/main/resources/conf/config-template.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/resources/conf/config-sample.yaml b/src/main/resources/conf/config-sample.yaml index 300d096..d26496e 100644 --- a/src/main/resources/conf/config-sample.yaml +++ b/src/main/resources/conf/config-sample.yaml @@ -115,6 +115,7 @@ customDashboard: # Update the path to the dashboard file. pathToSIMDashboard: "monitors/AWSELBMonitor/normalDashboard.json" pathToNormalDashboard: "monitors/AWSELBMonitor/normalDashboard.json" + periodicDashboardCheckInSeconds: 300 # To upload the dashboard, please create a user from Controller UI or # add the credentials of an existing user. diff --git a/src/main/resources/conf/config-template.yaml b/src/main/resources/conf/config-template.yaml index 3f75219..3235c57 100644 --- a/src/main/resources/conf/config-template.yaml +++ b/src/main/resources/conf/config-template.yaml @@ -120,6 +120,7 @@ customDashboard: # Update the path to the dashboard file. pathToSIMDashboard: "monitors/AWSELBMonitor/normalDashboard.json" pathToNormalDashboard: "monitors/AWSELBMonitor/normalDashboard.json" + periodicDashboardCheckInSeconds: 300 # To upload the dashboard, please create a user from Controller UI or # add the credentials of an existing user. From 44eb3f66754e7a359eb2b2f3c4a5b447bb4bf6f3 Mon Sep 17 00:00:00 2001 From: Bhuvnesh Kumar Date: Tue, 11 Dec 2018 16:50:27 -0800 Subject: [PATCH 09/11] adding all fields for controller info, updating test --- .../extensions/aws/config/Configuration.java | 5 +- .../aws/config/ControllerInformation.java | 100 ++++++++++++++++-- src/main/resources/conf/config-sample.yaml | 4 +- src/main/resources/conf/config-template.yaml | 4 +- .../ControllerInfoAndDashboardConfigTest.java | 4 +- .../test-controllerInfo-dashboard-config.yml | 4 +- 6 files changed, 100 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/appdynamics/extensions/aws/config/Configuration.java b/src/main/java/com/appdynamics/extensions/aws/config/Configuration.java index 12d74f9..eaee0a9 100644 --- a/src/main/java/com/appdynamics/extensions/aws/config/Configuration.java +++ b/src/main/java/com/appdynamics/extensions/aws/config/Configuration.java @@ -39,6 +39,8 @@ public class Configuration { private ControllerInformation controllerInfo; + private DashboardConfig customDashboard; + public DashboardConfig getCustomDashboard() { return customDashboard; } @@ -47,8 +49,6 @@ public void setCustomDashboard(DashboardConfig dashboardConfig) { this.customDashboard = dashboardConfig; } - private DashboardConfig customDashboard; - public ControllerInformation getControllerInfo() { return controllerInfo; } @@ -57,7 +57,6 @@ public void setControllerInfo(ControllerInformation controllerInformation) { this.controllerInfo = controllerInformation; } - public List getAccounts() { return accounts; } diff --git a/src/main/java/com/appdynamics/extensions/aws/config/ControllerInformation.java b/src/main/java/com/appdynamics/extensions/aws/config/ControllerInformation.java index afa01eb..c9f665b 100644 --- a/src/main/java/com/appdynamics/extensions/aws/config/ControllerInformation.java +++ b/src/main/java/com/appdynamics/extensions/aws/config/ControllerInformation.java @@ -13,30 +13,79 @@ */ public class ControllerInformation { - private String host; - private Integer port; + private String controllerHost; + private Integer controllerPort; private String account; private String username; private String password; private String useSsl; private String encryptedPassword; private String encryptionKey; + private Boolean simEnabled; + private String applicationName; + private String tierName; + private String nodeName; + private Boolean controllerSslEnabled; + protected Boolean enableOrchestration; + protected String uniqueHostId; + protected String accountAccessKey; + public Boolean getEnableOrchestration() { + return enableOrchestration; + } + + public void setEnableOrchestration(Boolean enableOrchestration) { + this.enableOrchestration = enableOrchestration; + } + + public String getUniqueHostId() { + return uniqueHostId; + } + + public void setUniqueHostId(String uniqueHostId) { + this.uniqueHostId = uniqueHostId; + } + + public String getAccountAccessKey() { + return accountAccessKey; + } + + public void setAccountAccessKey(String accountAccessKey) { + this.accountAccessKey = accountAccessKey; + } + + public String getMachinePath() { + return machinePath; + } + + public void setMachinePath(String machinePath) { + this.machinePath = machinePath; + } + + protected String machinePath; + + public Boolean getControllerSslEnabled() { + return controllerSslEnabled; + } - public String getHost() { - return host; + public void setControllerSslEnabled(Boolean controllerSslEnabled) { + this.controllerSslEnabled = controllerSslEnabled; } - public void setHost(String host) { - this.host = host; + public String getControllerHost() { + return controllerHost; } - public Integer getPort() { - return port; + public void setControllerHost(String controllerHost) { + this.controllerHost = controllerHost; } - public void setPort(Integer port) { - this.port = port; + public Integer getControllerPort() { + return controllerPort; + } + + public void setControllerPort(Integer controllerPort) { + this.controllerPort = controllerPort; } public String getAccount() { @@ -87,5 +136,36 @@ public void setEncryptionKey(String encryptionKey) { this.encryptionKey = encryptionKey; } + public Boolean getSimEnabled() { + return simEnabled; + } + + public void setSimEnabled(Boolean simEnabled) { + this.simEnabled = simEnabled; + } + + public String getApplicationName() { + return applicationName; + } + + public void setApplicationName(String applicationName) { + this.applicationName = applicationName; + } + + public String getTierName() { + return tierName; + } + + public void setTierName(String tierName) { + this.tierName = tierName; + } + + public String getNodeName() { + return nodeName; + } + + public void setNodeName(String nodeName) { + this.nodeName = nodeName; + } } diff --git a/src/main/resources/conf/config-sample.yaml b/src/main/resources/conf/config-sample.yaml index d26496e..f013d37 100644 --- a/src/main/resources/conf/config-sample.yaml +++ b/src/main/resources/conf/config-sample.yaml @@ -121,8 +121,8 @@ customDashboard: # add the credentials of an existing user. controllerInfo: - host: "" - port: "" + controllerHost: "" + controllerPort: "" account: "" username: "" password: "" diff --git a/src/main/resources/conf/config-template.yaml b/src/main/resources/conf/config-template.yaml index 3235c57..f01277b 100644 --- a/src/main/resources/conf/config-template.yaml +++ b/src/main/resources/conf/config-template.yaml @@ -126,8 +126,8 @@ customDashboard: # add the credentials of an existing user. controllerInfo: - host: "" - port: "" + controllerHost: "" + controllerPort: "" account: "" username: "" password: "" diff --git a/src/test/java/com/appdynamics/extensions/aws/config/ControllerInfoAndDashboardConfigTest.java b/src/test/java/com/appdynamics/extensions/aws/config/ControllerInfoAndDashboardConfigTest.java index 688fe25..0b5207a 100644 --- a/src/test/java/com/appdynamics/extensions/aws/config/ControllerInfoAndDashboardConfigTest.java +++ b/src/test/java/com/appdynamics/extensions/aws/config/ControllerInfoAndDashboardConfigTest.java @@ -39,8 +39,8 @@ public void ConfigAndDashboardPresentTest() throws IOException { Assert.assertTrue(config.getControllerInfo().getAccount().equals("account")); Assert.assertTrue(config.getControllerInfo().getUsername().equals("admin")); Assert.assertTrue(config.getControllerInfo().getPassword().equals("root")); - Assert.assertTrue(config.getControllerInfo().getHost().equals("host")); - Assert.assertTrue(config.getControllerInfo().getPort().equals(9000)); + Assert.assertTrue(config.getControllerInfo().getControllerHost().equals("host")); + Assert.assertTrue(config.getControllerInfo().getControllerPort().equals(9000)); } diff --git a/src/test/resources/conf/test-controllerInfo-dashboard-config.yml b/src/test/resources/conf/test-controllerInfo-dashboard-config.yml index 099ef65..50eb5a4 100644 --- a/src/test/resources/conf/test-controllerInfo-dashboard-config.yml +++ b/src/test/resources/conf/test-controllerInfo-dashboard-config.yml @@ -206,8 +206,8 @@ customDashboard: # add the credentials of an existing user. controllerInfo: - host: "host" - port: 9000 + controllerHost: "host" + controllerPort: 9000 account: "account" username: "admin" password: "root" From de7a32a176ea4c2355693a771df97e2713f57080 Mon Sep 17 00:00:00 2001 From: Bhuvnesh Kumar Date: Wed, 12 Dec 2018 13:30:22 -0800 Subject: [PATCH 10/11] updating files for dashboard information --- .../aws/config/ControllerInformation.java | 11 +-------- .../aws/config/DashboardConfig.java | 17 +++++++------ src/main/resources/conf/config-sample.yaml | 23 +++++++++++------- src/main/resources/conf/config-template.yaml | 24 ++++++++++++------- 4 files changed, 39 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/appdynamics/extensions/aws/config/ControllerInformation.java b/src/main/java/com/appdynamics/extensions/aws/config/ControllerInformation.java index c9f665b..4ceeb60 100644 --- a/src/main/java/com/appdynamics/extensions/aws/config/ControllerInformation.java +++ b/src/main/java/com/appdynamics/extensions/aws/config/ControllerInformation.java @@ -18,7 +18,6 @@ public class ControllerInformation { private String account; private String username; private String password; - private String useSsl; private String encryptedPassword; private String encryptionKey; private Boolean simEnabled; @@ -29,6 +28,7 @@ public class ControllerInformation { protected Boolean enableOrchestration; protected String uniqueHostId; protected String accountAccessKey; + protected String machinePath; public Boolean getEnableOrchestration() { return enableOrchestration; @@ -62,7 +62,6 @@ public void setMachinePath(String machinePath) { this.machinePath = machinePath; } - protected String machinePath; public Boolean getControllerSslEnabled() { return controllerSslEnabled; @@ -112,14 +111,6 @@ public void setPassword(String password) { this.password = password; } - public String getUseSsl() { - return useSsl; - } - - public void setUseSsl(String useSsl) { - this.useSsl = useSsl; - } - public String getEncryptedPassword() { return encryptedPassword; } diff --git a/src/main/java/com/appdynamics/extensions/aws/config/DashboardConfig.java b/src/main/java/com/appdynamics/extensions/aws/config/DashboardConfig.java index fb7c9ab..eb2d3c3 100644 --- a/src/main/java/com/appdynamics/extensions/aws/config/DashboardConfig.java +++ b/src/main/java/com/appdynamics/extensions/aws/config/DashboardConfig.java @@ -15,11 +15,18 @@ public class DashboardConfig { private Boolean enabled; private String dashboardName; - private Integer executionFrequencyMinutes; private String pathToSIMDashboard; private String pathToNormalDashboard; private Integer periodicDashboardCheckInSeconds; + private Boolean sslCertCheckEnabled; + public Boolean getSslCertCheckEnabled() { + return sslCertCheckEnabled; + } + + public void setSslCertCheckEnabled(Boolean sslCertCheckEnabled) { + this.sslCertCheckEnabled = sslCertCheckEnabled; + } public Integer getPeriodicDashboardCheckInSeconds() { return periodicDashboardCheckInSeconds; @@ -45,13 +52,6 @@ public void setDashboardName(String dashboardName) { this.dashboardName = dashboardName; } - public Integer getExecutionFrequencyMinutes() { - return executionFrequencyMinutes; - } - - public void setExecutionFrequencyMinutes(Integer executionFrequencyMinutes) { - this.executionFrequencyMinutes = executionFrequencyMinutes; - } public String getPathToSIMDashboard() { return pathToSIMDashboard; @@ -69,5 +69,4 @@ public void setPathToNormalDashboard(String pathToNormalDashboard) { this.pathToNormalDashboard = pathToNormalDashboard; } - } diff --git a/src/main/resources/conf/config-sample.yaml b/src/main/resources/conf/config-sample.yaml index f013d37..b02e71c 100644 --- a/src/main/resources/conf/config-sample.yaml +++ b/src/main/resources/conf/config-sample.yaml @@ -111,7 +111,7 @@ metricPrefix: "Server|Component:|Custom Metrics|Amazon EC2|" customDashboard: enabled: true dashboardName: "AWS ELB Monitor Dashboard" - + sslCertCheckEnabled: false # Update the path to the dashboard file. pathToSIMDashboard: "monitors/AWSELBMonitor/normalDashboard.json" pathToNormalDashboard: "monitors/AWSELBMonitor/normalDashboard.json" @@ -121,13 +121,20 @@ customDashboard: # add the credentials of an existing user. controllerInfo: - controllerHost: "" - controllerPort: "" - account: "" - username: "" - password: "" - # OPTIONAL Items + controllerHost: "host" + controllerPort: 9090 + controllerSslEnabled: false + enableOrchestration: false + uniqueHostId: "" + username: "username" + password: "password" encryptedPassword: "" encryptionKey: "" - controllerSslEnabled: "" + accountAccessKey: "" + account: "account" + machinePath: "" + simEnabled: false + applicationName: "application" + tierName: "tier" + nodeName: "node" diff --git a/src/main/resources/conf/config-template.yaml b/src/main/resources/conf/config-template.yaml index f01277b..4226fcc 100644 --- a/src/main/resources/conf/config-template.yaml +++ b/src/main/resources/conf/config-template.yaml @@ -116,7 +116,7 @@ metricPrefix: "Server|Component:|Custom Metrics|Amazon EC2|" customDashboard: enabled: true dashboardName: "AWS ELB Monitor Dashboard" - + sslCertCheckEnabled: false # Update the path to the dashboard file. pathToSIMDashboard: "monitors/AWSELBMonitor/normalDashboard.json" pathToNormalDashboard: "monitors/AWSELBMonitor/normalDashboard.json" @@ -126,13 +126,19 @@ customDashboard: # add the credentials of an existing user. controllerInfo: - controllerHost: "" - controllerPort: "" - account: "" - username: "" - password: "" - # OPTIONAL Items + controllerHost: "host" + controllerPort: 9090 + controllerSslEnabled: false + enableOrchestration: false + uniqueHostId: "" + username: "username" + password: "password" encryptedPassword: "" encryptionKey: "" - controllerSslEnabled: "" - + accountAccessKey: "" + account: "account" + machinePath: "" + simEnabled: false + applicationName: "application" + tierName: "tier" + nodeName: "node" From 99bbe1fcc7b0ddc02555f274427ae22b070a9fe0 Mon Sep 17 00:00:00 2001 From: "satish.muddam" Date: Thu, 24 Jan 2019 11:08:02 +0530 Subject: [PATCH 11/11] Code changes to fix password encryption issue. --- .../extensions/aws/util/AWSUtil.java | 7 ++- .../extensions/aws/util/AWSUtilTest.java | 57 +++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 src/test/java/com/appdynamics/extensions/aws/util/AWSUtilTest.java diff --git a/src/main/java/com/appdynamics/extensions/aws/util/AWSUtil.java b/src/main/java/com/appdynamics/extensions/aws/util/AWSUtil.java index 4d96cdd..2a8e657 100644 --- a/src/main/java/com/appdynamics/extensions/aws/util/AWSUtil.java +++ b/src/main/java/com/appdynamics/extensions/aws/util/AWSUtil.java @@ -7,6 +7,9 @@ package com.appdynamics.extensions.aws.util; +import static com.appdynamics.extensions.TaskInputArgs.ENCRYPTED_PASSWORD; +import static com.appdynamics.extensions.TaskInputArgs.ENCRYPTION_KEY; + import com.amazonaws.ClientConfiguration; import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.BasicAWSCredentials; @@ -55,8 +58,8 @@ public static AWSCredentials createAWSCredentials(Account account, private static String getDecryptedPassword(String encryptedPassword, String encryptionKey) { Map cryptoMap = Maps.newHashMap(); - cryptoMap.put("password-encrypted", encryptedPassword); - cryptoMap.put("encryption-key", encryptionKey); + cryptoMap.put(ENCRYPTED_PASSWORD, encryptedPassword); + cryptoMap.put(ENCRYPTION_KEY, encryptionKey); return CryptoUtil.getPassword(cryptoMap); } diff --git a/src/test/java/com/appdynamics/extensions/aws/util/AWSUtilTest.java b/src/test/java/com/appdynamics/extensions/aws/util/AWSUtilTest.java new file mode 100644 index 0000000..9b590e0 --- /dev/null +++ b/src/test/java/com/appdynamics/extensions/aws/util/AWSUtilTest.java @@ -0,0 +1,57 @@ +package com.appdynamics.extensions.aws.util; + +import com.amazonaws.auth.AWSCredentials; +import com.appdynamics.extensions.aws.config.Account; +import com.appdynamics.extensions.aws.config.CredentialsDecryptionConfig; +import com.appdynamics.extensions.crypto.Encryptor; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; + +/** + * @author Satish Muddam + */ + +@RunWith(MockitoJUnitRunner.class) +public class AWSUtilTest { + + @Mock + private Account account; + + @Mock + private CredentialsDecryptionConfig credentialsDecryptionConfig; + + @Test + public void testCreateAWSCredentialsWithoutEncryption() { + + Mockito.when(account.getAwsAccessKey()).thenReturn("accessKey1"); + Mockito.when(account.getAwsSecretKey()).thenReturn("secretKey1"); + + AWSCredentials awsCredentials = AWSUtil.createAWSCredentials(account, null); + + Assert.assertEquals("accessKey1", awsCredentials.getAWSAccessKeyId()); + Assert.assertEquals("secretKey1", awsCredentials.getAWSSecretKey()); + } + + @Test + public void testCreateAWSCredentialsWithEncryption() { + + + Encryptor encryptor = new Encryptor("test"); + + Mockito.when(account.getAwsAccessKey()).thenReturn(encryptor.encrypt("accessKey1")); + Mockito.when(account.getAwsSecretKey()).thenReturn(encryptor.encrypt("secretKey1")); + + + Mockito.when(credentialsDecryptionConfig.isDecryptionEnabled()).thenReturn(true); + Mockito.when(credentialsDecryptionConfig.getEncryptionKey()).thenReturn("test"); + + AWSCredentials awsCredentials = AWSUtil.createAWSCredentials(account, credentialsDecryptionConfig); + + Assert.assertEquals("accessKey1", awsCredentials.getAWSAccessKeyId()); + Assert.assertEquals("secretKey1", awsCredentials.getAWSSecretKey()); + } +}