in aws-applicationinsights-application/src/main/java/software/amazon/applicationinsights/application/HandlerHelper.java [273:312]
public static void createDefaultComponentConfiguration(
String componentNameOrARN,
String tier,
ResourceModel model,
AmazonWebServicesClientProxy proxy,
ApplicationInsightsClient applicationInsightsClient,
Logger logger) throws IOException {
DescribeComponentConfigurationRecommendationResponse describeComponentConfigurationRecommendationResponse =
proxy.injectCredentialsAndInvokeV2(DescribeComponentConfigurationRecommendationRequest.builder()
.resourceGroupName(model.getResourceGroupName())
.componentName(componentNameOrARN)
.tier(tier)
.build(),
applicationInsightsClient::describeComponentConfigurationRecommendation);
String recomendedComponentConfigurationString =
describeComponentConfigurationRecommendationResponse.componentConfiguration();
logger.log("Component name or ARN: " + componentNameOrARN);
logger.log("Recommended Component Configuration String (DEFAULT mode): " + recomendedComponentConfigurationString);
ObjectMapper mapper = new ObjectMapper()
.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true)
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
InputComponentConfiguration recommendedInputConfig = mapper.readValue(
recomendedComponentConfigurationString, InputComponentConfiguration.class);
// same as CUSTOM branch
String inputComponentConfigurationString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(recommendedInputConfig);
logger.log("Component Configuration String (DEFAULT mode): " + inputComponentConfigurationString);
proxy.injectCredentialsAndInvokeV2(UpdateComponentConfigurationRequest.builder()
.resourceGroupName(model.getResourceGroupName())
.componentName(componentNameOrARN)
.monitor(true)
.tier(tier)
.componentConfiguration(inputComponentConfigurationString)
.build(),
applicationInsightsClient::updateComponentConfiguration);
}