Revolutionize DevOps with ML capabilities
Introduction to DevOps Guru and CodeGuru
Vadym Kazulkin, ip.labs, 15 March 2022
Contact
Vadym Kazulkin
ip.labs GmbH Bonn, Germany
Co-Organizer of the Java User Group Bonn
and Serverless Bonn Meetup
v.kazulkin@gmail.com
@VKazulkin
https://www.linkedin.com/in/vadymkazulkin
https://www.iplabs.de/
ip.labs
https://www.iplabs.de/
AWS DevOps Guru
What is AWS DevOps Guru
Amazon DevOps Guru is a service powered by machine learning
(ML) that is designed to make it easy to improve an application’s
operational performance and availability
DevOps Guru helps detect behaviors that deviate from normal
operating patterns so you can identify operational issues long
before they impact your customers
• increased latency
• error rates (timeouts, throttles)
• resource constraints
https://aws.amazon.com/devops-guru
Benefits of DevOps Guru
https://aws.amazon.com/devops-guru
How DevOps Guru work
https://aws.amazon.com/devops-guru
DevOps Guru integration in 3rd party incident
management tools
https://aws.amazon.com/devops-guru
• PagerDuty
• Atlassian Opsgenie
DevOps Guru Example Application
DevOps Guru Set Up
DevOps Guru Integration with PagerDuty
https://www.pagerduty.com/docs/guides/amazon-devops-guru-integration-guide/
DevOps Guru Integration with PagerDuty
DevOps Guru Dashboard
DevOps Guru Dashboard
DevOps Guru Insights
DevOps Guru PagerDuty Incidents
• Design test experiment to provoke errors
and latency increase
• Reduce the service quote of the AWS
service (API Gateway, Lambda,
DynamoDB)
• Low service quotas for the sake of
reducing AWS costs only
• Stress test with JMeter to run into the
operational issues
• See if the DevOps Guru recognized the
operational issues
DevOps Guru Examples
| CONFIDENTIAL
21
DevOps Guru: Recognize operational issues
in DynamoDB
DevOps Guru Examples: DynamoDB Throttling
DevOps Guru Examples: DynamoDB Throttling
stress test and empty burst credits
DevOps Guru Examples: DynamoDB Throttling
DevOps Guru: Recognize operational issues
in API Gateway
DevOps Guru Examples: API Gateway Throttling
DevOps Guru Examples: API Gateway Throttling
DevOps Guru: Recognize operational issues
in Lambda
DevOps Guru Examples: Lambda Throttling
DevOps Guru Examples: Lambda Throttling
DevOps Guru Examples: Lambda Timeout Error
Add 11 sec
sleep in the
code of the
Lambda
function
DevOps Guru Examples: Lambda Timeout Error
DevOps Guru Examples: Lambda Memory Error
Java
runtime
requires 256
MB to start
and execute
this code
DevOps Guru Examples: Lambda Memory Error
DevOps Guru Examples: Lambda Increased
Latency
Add 9.5 sec
sleep in the
code of the
Lambda
function
DevOps Guru Examples: Lambda Increased
Latency
DevOps Guru Conclusions
• All errors have been correctly recognized so far
• It took several minutes to create an incident after
anomaly appeared
• Tested mainly in the context of AWS Serverless stack
• AWS is responsible for monitoring those services
• Not all PagerDuty alarms have been automatically closed
after the incident resolution
• Especially in case there have been several anomalies
within one incident
DevOps Guru for RDS
https://aws.amazon.com/devops-guru/features/devops-guru-for-rds/
AWS CodeGuru
What is AWS CodeGuru
Amazon CodeGuru is a developer tool that provides intelligent
recommendations to improve code quality and identify an
application’s most expensive lines of code
• CodeGuru Reviewer uses machine learning and automated
reasoning to identify critical issues, security vulnerabilities,
and hard-to-find bugs during application development and
provides recommendations to improve code quality
• CodeGuru Profiler helps developers find an application’s
most expensive lines of code by helping them understand
the runtime behavior of their applications, identify and
remove code inefficiencies and improve performance
https://aws.amazon.com/codeguru
Benefits of CodeGuru
• CodeGuru Reviewer benefits
• Catch code problems before they hit production
• Proactively improve code quality with continuous
monitoring
• CodeGuru Profiler benefits
• Troubleshoot performance issues
• Discover anomalies and common issues in your
application performance
• Catch your most expensive line of code
https://aws.amazon.com/codeguru
How CodeGuru work
https://aws.amazon.com/codeguru
CodeGuru Programming Language Support
• Java
• Python
CodeGuru
CodeGuru Reviewer in Java
CodeGuru Setup
CodeGuru Setup
CodeGuru Reviewer Scans
• Full repository analysis
• Incremental code reviews (pull requests)
Java Code for CodeGuru Analysis
CodeGuru Reviewer Recommendation
The recommendations for Java fall into the following categories:
• AWS best practices
• Security
• Resource leaks
• Concurrency
• Integration with Infer (https://fbinfer.com/)
• detect null pointer dereferences, thread safety violations
and improper use of synchronization locks
• Other specialized categories such as sensitive information
leaks, input validation, and code clones
• General best practices on data structures, control flow,
exception handling, and more
https://aws.amazon.com/de/blogs/devops/improving-aws-java-applications-with-amazon-codeguru-reviewer/
CodeGuru Review Full Repository Analysis
CodeGuru Review AWS Best Practices with
Java SDK V1
CodeGuru Review AWS Best Practices with
Java SDK V1
CodeGuru Review AWS Best Practices with
Java SDK V1
CodeGuru Review AWS Best Practices with
Java SDK V2
CodeGuru Review other AWS Best Practices
CodeGuru Review Concurrency
CodeGuru Review Concurrency
CodeGuru Review Resource Leak
CodeGuru Review Security
CodeGuru Review Security
CodeGuru Incremental Review
Occurs automatically when creating a pull request with CodeGuru associated
with CodeCommit repository
CodeGuru Review Expected, but No Findings
https://aws.amazon.com/de/blogs/devops/tightening-application-security-with-amazon-codeguru/
CodeGuru Reviewer AWS CI/CD Integration
CodeGuru Reviewer CI/CD Integration
For CodeBuild add to buildspec.yaml
pre_build:
commands:
- pip3 install awscli --upgrade --user
- export TAG=${CODEBUILD_RESOLVED_SOURCE_VERSION}
- aws codeguru-reviewer create-code-review --name your-
codeguru-review-name$TAG
--repository-association-arn arn:aws:codeguru-
reviewer:eu-central-1:your-codeguru-arn
--type
RepositoryAnalysis={RepositoryHead={BranchName=main}}
CodeGuru Reviewer GitHub CI/CD Integration
https://aws.amazon.com/about-aws/whats-new/2021/06/amazon-codeguru-reviewer-announces-ci-cd-integration-github-actions-new-security-detectors-for-java/?nc1=h_ls
CodeGuru vs SonarQube
CodeGuru vs SonarQube
• CodeGuru currently support only 2 languages vs SonarQube
supporting 20+
• CodeGuru is much powerful in detecting AWS best practices
(including AWS security best practices)
• SonarQube is much more powerful detecting common Java
issues
CodeGuru Conclusions
• Very good findings for AWS best practices when using Java
SDK V1
• Many missing findings with Java SDK V2 compared to 1
• Many officially described security findings are not detected
in my examples
• Full repository scans are very expensive
• Use incremental code reviews (pull requests) scan as
much as possible
• Use CodeGuru in conjunction with SonarQube
www.iplabs.de
Accelerate Your Photo Business
Get in Touch

Revolutionize DevOps with ML capabilities. Introduction to Amazon CodeGuru and DevOps Guru at JavaLand 2022

  • 1.
    Revolutionize DevOps withML capabilities Introduction to DevOps Guru and CodeGuru Vadym Kazulkin, ip.labs, 15 March 2022
  • 2.
    Contact Vadym Kazulkin ip.labs GmbHBonn, Germany Co-Organizer of the Java User Group Bonn and Serverless Bonn Meetup v.kazulkin@gmail.com @VKazulkin https://www.linkedin.com/in/vadymkazulkin https://www.iplabs.de/
  • 3.
  • 4.
  • 5.
    What is AWSDevOps Guru Amazon DevOps Guru is a service powered by machine learning (ML) that is designed to make it easy to improve an application’s operational performance and availability DevOps Guru helps detect behaviors that deviate from normal operating patterns so you can identify operational issues long before they impact your customers • increased latency • error rates (timeouts, throttles) • resource constraints https://aws.amazon.com/devops-guru
  • 6.
    Benefits of DevOpsGuru https://aws.amazon.com/devops-guru
  • 7.
    How DevOps Guruwork https://aws.amazon.com/devops-guru
  • 8.
    DevOps Guru integrationin 3rd party incident management tools https://aws.amazon.com/devops-guru • PagerDuty • Atlassian Opsgenie
  • 9.
  • 10.
  • 11.
    DevOps Guru Integrationwith PagerDuty https://www.pagerduty.com/docs/guides/amazon-devops-guru-integration-guide/
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
    • Design testexperiment to provoke errors and latency increase • Reduce the service quote of the AWS service (API Gateway, Lambda, DynamoDB) • Low service quotas for the sake of reducing AWS costs only • Stress test with JMeter to run into the operational issues • See if the DevOps Guru recognized the operational issues DevOps Guru Examples | CONFIDENTIAL 21
  • 18.
    DevOps Guru: Recognizeoperational issues in DynamoDB
  • 19.
    DevOps Guru Examples:DynamoDB Throttling
  • 20.
    DevOps Guru Examples:DynamoDB Throttling stress test and empty burst credits
  • 21.
    DevOps Guru Examples:DynamoDB Throttling
  • 22.
    DevOps Guru: Recognizeoperational issues in API Gateway
  • 23.
    DevOps Guru Examples:API Gateway Throttling
  • 24.
    DevOps Guru Examples:API Gateway Throttling
  • 25.
    DevOps Guru: Recognizeoperational issues in Lambda
  • 26.
    DevOps Guru Examples:Lambda Throttling
  • 27.
    DevOps Guru Examples:Lambda Throttling
  • 28.
    DevOps Guru Examples:Lambda Timeout Error Add 11 sec sleep in the code of the Lambda function
  • 29.
    DevOps Guru Examples:Lambda Timeout Error
  • 30.
    DevOps Guru Examples:Lambda Memory Error Java runtime requires 256 MB to start and execute this code
  • 31.
    DevOps Guru Examples:Lambda Memory Error
  • 32.
    DevOps Guru Examples:Lambda Increased Latency Add 9.5 sec sleep in the code of the Lambda function
  • 33.
    DevOps Guru Examples:Lambda Increased Latency
  • 34.
    DevOps Guru Conclusions •All errors have been correctly recognized so far • It took several minutes to create an incident after anomaly appeared • Tested mainly in the context of AWS Serverless stack • AWS is responsible for monitoring those services • Not all PagerDuty alarms have been automatically closed after the incident resolution • Especially in case there have been several anomalies within one incident
  • 35.
    DevOps Guru forRDS https://aws.amazon.com/devops-guru/features/devops-guru-for-rds/
  • 36.
  • 37.
    What is AWSCodeGuru Amazon CodeGuru is a developer tool that provides intelligent recommendations to improve code quality and identify an application’s most expensive lines of code • CodeGuru Reviewer uses machine learning and automated reasoning to identify critical issues, security vulnerabilities, and hard-to-find bugs during application development and provides recommendations to improve code quality • CodeGuru Profiler helps developers find an application’s most expensive lines of code by helping them understand the runtime behavior of their applications, identify and remove code inefficiencies and improve performance https://aws.amazon.com/codeguru
  • 38.
    Benefits of CodeGuru •CodeGuru Reviewer benefits • Catch code problems before they hit production • Proactively improve code quality with continuous monitoring • CodeGuru Profiler benefits • Troubleshoot performance issues • Discover anomalies and common issues in your application performance • Catch your most expensive line of code https://aws.amazon.com/codeguru
  • 39.
  • 40.
    CodeGuru Programming LanguageSupport • Java • Python
  • 41.
  • 42.
  • 43.
  • 44.
    CodeGuru Reviewer Scans •Full repository analysis • Incremental code reviews (pull requests)
  • 45.
    Java Code forCodeGuru Analysis
  • 46.
    CodeGuru Reviewer Recommendation Therecommendations for Java fall into the following categories: • AWS best practices • Security • Resource leaks • Concurrency • Integration with Infer (https://fbinfer.com/) • detect null pointer dereferences, thread safety violations and improper use of synchronization locks • Other specialized categories such as sensitive information leaks, input validation, and code clones • General best practices on data structures, control flow, exception handling, and more https://aws.amazon.com/de/blogs/devops/improving-aws-java-applications-with-amazon-codeguru-reviewer/
  • 47.
    CodeGuru Review FullRepository Analysis
  • 48.
    CodeGuru Review AWSBest Practices with Java SDK V1
  • 49.
    CodeGuru Review AWSBest Practices with Java SDK V1
  • 50.
    CodeGuru Review AWSBest Practices with Java SDK V1
  • 51.
    CodeGuru Review AWSBest Practices with Java SDK V2
  • 52.
    CodeGuru Review otherAWS Best Practices
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
    CodeGuru Incremental Review Occursautomatically when creating a pull request with CodeGuru associated with CodeCommit repository
  • 59.
    CodeGuru Review Expected,but No Findings https://aws.amazon.com/de/blogs/devops/tightening-application-security-with-amazon-codeguru/
  • 60.
    CodeGuru Reviewer AWSCI/CD Integration
  • 61.
    CodeGuru Reviewer CI/CDIntegration For CodeBuild add to buildspec.yaml pre_build: commands: - pip3 install awscli --upgrade --user - export TAG=${CODEBUILD_RESOLVED_SOURCE_VERSION} - aws codeguru-reviewer create-code-review --name your- codeguru-review-name$TAG --repository-association-arn arn:aws:codeguru- reviewer:eu-central-1:your-codeguru-arn --type RepositoryAnalysis={RepositoryHead={BranchName=main}}
  • 62.
    CodeGuru Reviewer GitHubCI/CD Integration https://aws.amazon.com/about-aws/whats-new/2021/06/amazon-codeguru-reviewer-announces-ci-cd-integration-github-actions-new-security-detectors-for-java/?nc1=h_ls
  • 63.
  • 64.
    CodeGuru vs SonarQube •CodeGuru currently support only 2 languages vs SonarQube supporting 20+ • CodeGuru is much powerful in detecting AWS best practices (including AWS security best practices) • SonarQube is much more powerful detecting common Java issues
  • 65.
    CodeGuru Conclusions • Verygood findings for AWS best practices when using Java SDK V1 • Many missing findings with Java SDK V2 compared to 1 • Many officially described security findings are not detected in my examples • Full repository scans are very expensive • Use incremental code reviews (pull requests) scan as much as possible • Use CodeGuru in conjunction with SonarQube
  • 67.