[{"data":1,"prerenderedAt":153},["ShallowReactive",2],{"content-svc-lambda-paved-path-java-replatforming-metrics":3},{"markdown":4,"frontMatterAttributes":5,"bodyRaw":25,"menu":26,"menuType":149,"isCollapseableMenu":29,"nextDocItem":142,"previousDocItem":117,"contributorPaths":150,"contentName":152,"slug":138,"readingTime":135},"\u003Cp>\u003Cstrong>Making the most of the cloud\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cp>CloudWatch Logs Insights gives you the ability to write SQL like queries to search and filter multiple log streams. To \nmake the most of this functionality, think about how to include useful data into your log messages to make them easy to \nsearch for. You might want to see all the log messages for a single customer across multiple Lambda functions, or all \nthe log messages for a group of transactions.\u003C\u002Fp>\n\u003Cp>To do this easily, you can implement structured logging. Instead of writing a log message, which is then output as part \nof a text logging pattern, you can write out the log as a JSON object. This makes it easier to include metadata to your \nmessage as attribute, value pairs.\u003C\u002Fp>\n\u003Cp>\u003Cstrong>Lambda Powertools for Java\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cp>\u003Ca href=\"https:\u002F\u002Fawslabs.github.io\u002Faws-lambda-powertools-java\u002F\">Lambda Powertools for Java\u003C\u002Fa> is a developer toolkit to implement \nServerless best practices and increase developer velocity. Powertools includes support for structured logging with Log4J.\u003C\u002Fp>\n\u003Cp>\u003Cimg src=\"\u002Fassets\u002Fexternal\u002Fservice\u002Flambda\u002Fpaved-path\u002Fjava-replatforming\u002Fassets\u002Fimage16.png\" alt=\"\">\u003C\u002Fp>\n\u003Cp>\u003Cstrong>Metrics\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cp>A common pattern to distribute application metrics is to expose a metrics endpoint as part of the application. Your \nmonitoring solution then polls each instance of the application and consumes the metrics. Lambda function instances are \nnot directly addressable. All requests made to a Lambda function are automatically load balanced to instances available.\u003C\u002Fp>\n\u003Cp>The Lambda service automatically produces function level metrics such as number of invokes, duration of execution, \nnumber of errors and more. You can find more information about the metrics produced by the service under \n\u003Ca href=\"https:\u002F\u002Fdocs.aws.amazon.com\u002Flambda\u002Flatest\u002Fdg\u002Fmonitoring-metrics.html\">Working with Lambda function metrics\u003C\u002Fa> of the \nDeveloper Guide.\u003C\u002Fp>\n\u003Cp>To measure system level metrics such as CPU time, memory, disk, and network you can enable \n\u003Ca href=\"https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudWatch\u002Flatest\u002Fmonitoring\u002FLambda-Insights.html\">CloudWatch Lambda Insights\u003C\u002Fa>.\u003C\u002Fp>\n\u003Cp>\u003Cstrong>Application Metrics with CloudWatch\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cp>You can create your own custom application metrics into CloudWatch. You can do this to record more fine-grained \nbehavior, which isn&#39;t covered by the service or system level metrics. The best practice way to do this is with \n\u003Ca href=\"https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudWatch\u002Flatest\u002Fmonitoring\u002FCloudWatch_Embedded_Metric_Format.html\">CloudWatch Embedded Metrics Format\u003C\u002Fa> (CloudWatch EMF). \nThis allows you to push metrics from each invoke of your Lambda function asynchronously. To do this you log a JSON object \nfollowing the \u003Ca href=\"https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudWatch\u002Flatest\u002Fmonitoring\u002FCloudWatch_Embedded_Metric_Format_Specification.html\">EMF specification\u003C\u002Fa> \nto standard out.\u003C\u002Fp>\n\u003Cp>To make this easier, there are two client libraries that support the creation of metrics in the EMF format:\u003C\u002Fp>\n\u003Cp>\u003Cstrong>Low Level Client Library\u003C\u002Fstrong>\n\u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fawslabs\u002Faws-embedded-metrics-java\">aws-embedded-metrics-java\u003C\u002Fa>\u003C\u002Fp>\n\u003Cp>\u003Cstrong>Lambda Powertools for Java Metrics\u003C\u002Fstrong>\n\u003Ca href=\"https:\u002F\u002Fawslabs.github.io\u002Faws-lambda-powertools-java\u002Fcore\u002Fmetrics\u002F\">https:\u002F\u002Fawslabs.github.io\u002Faws-lambda-powertools-java\u002Fcore\u002Fmetrics\u002F\u003C\u002Fa>\u003C\u002Fp>\n\u003Cp>\u003Cstrong>Avoid\u003C\u002Fstrong> using CloudWatch APIs to record metrics synchronously. This will increase the duration of your Lambda function.\u003C\u002Fp>\n\u003Cp>\u003Cstrong>Application Metrics with Partners\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cp>Many \u003Ca href=\"https:\u002F\u002Fdocs.aws.amazon.com\u002Flambda\u002Flatest\u002Fdg\u002Fextensions-api-partners.html\">AWS Partners provide extensions\u003C\u002Fa> to \nintegrate with your Lambda functions.\u003C\u002Fp>\n",{"title":6,"order":7,"callout":8,"resources":12,"learningGoals":23},"Observability - Metrics",2,{"title":9,"description":10,"link":11},"Watch the video","AWS Lambda Powertools: Lessons from the road to 10 million downloads.","https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=dH2GP6Lydj8",[13,17,20],{"link":14,"text":15,"type":16},"https:\u002F\u002Fawslabs.github.io\u002Faws-lambda-powertools-java\u002Fcore\u002Fmetrics\u002F","Lambda Powertools for Java - Metrics","Repo",{"link":18,"text":19,"type":16},"https:\u002F\u002Fawslabs.github.io\u002Faws-lambda-powertools-java\u002F","Lambda Powertools for Java",{"link":21,"text":22,"type":16},"https:\u002F\u002Fgithub.com\u002Fawslabs\u002Faws-embedded-metrics-java","EMF Client Library",[24],"How to efficiently write metrics with Lambda","**Making the most of the cloud**\n\nCloudWatch Logs Insights gives you the ability to write SQL like queries to search and filter multiple log streams. To \nmake the most of this functionality, think about how to include useful data into your log messages to make them easy to \nsearch for. You might want to see all the log messages for a single customer across multiple Lambda functions, or all \nthe log messages for a group of transactions.\n\nTo do this easily, you can implement structured logging. Instead of writing a log message, which is then output as part \nof a text logging pattern, you can write out the log as a JSON object. This makes it easier to include metadata to your \nmessage as attribute, value pairs.\n\n**Lambda Powertools for Java**\n\n[Lambda Powertools for Java](https:\u002F\u002Fawslabs.github.io\u002Faws-lambda-powertools-java\u002F) is a developer toolkit to implement \nServerless best practices and increase developer velocity. Powertools includes support for structured logging with Log4J.\n\n![](\u002Fassets\u002Fexternal\u002Fservice\u002Flambda\u002Fpaved-path\u002Fjava-replatforming\u002Fassets\u002Fimage16.png)\n\n**Metrics**\n\nA common pattern to distribute application metrics is to expose a metrics endpoint as part of the application. Your \nmonitoring solution then polls each instance of the application and consumes the metrics. Lambda function instances are \nnot directly addressable. All requests made to a Lambda function are automatically load balanced to instances available.\n\nThe Lambda service automatically produces function level metrics such as number of invokes, duration of execution, \nnumber of errors and more. You can find more information about the metrics produced by the service under \n[Working with Lambda function metrics](https:\u002F\u002Fdocs.aws.amazon.com\u002Flambda\u002Flatest\u002Fdg\u002Fmonitoring-metrics.html) of the \nDeveloper Guide.\n\nTo measure system level metrics such as CPU time, memory, disk, and network you can enable \n[CloudWatch Lambda Insights](https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudWatch\u002Flatest\u002Fmonitoring\u002FLambda-Insights.html).\n\n**Application Metrics with CloudWatch**\n\nYou can create your own custom application metrics into CloudWatch. You can do this to record more fine-grained \nbehavior, which isn't covered by the service or system level metrics. The best practice way to do this is with \n[CloudWatch Embedded Metrics Format](https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudWatch\u002Flatest\u002Fmonitoring\u002FCloudWatch_Embedded_Metric_Format.html) (CloudWatch EMF). \nThis allows you to push metrics from each invoke of your Lambda function asynchronously. To do this you log a JSON object \nfollowing the [EMF specification](https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudWatch\u002Flatest\u002Fmonitoring\u002FCloudWatch_Embedded_Metric_Format_Specification.html) \nto standard out.\n\nTo make this easier, there are two client libraries that support the creation of metrics in the EMF format:\n\n**Low Level Client Library**\n[aws-embedded-metrics-java](https:\u002F\u002Fgithub.com\u002Fawslabs\u002Faws-embedded-metrics-java)\n\n**Lambda Powertools for Java Metrics**\n[https:\u002F\u002Fawslabs.github.io\u002Faws-lambda-powertools-java\u002Fcore\u002Fmetrics\u002F](https:\u002F\u002Fawslabs.github.io\u002Faws-lambda-powertools-java\u002Fcore\u002Fmetrics\u002F)\n\n**Avoid** using CloudWatch APIs to record metrics synchronously. This will increase the duration of your Lambda function.\n\n**Application Metrics with Partners**\n\nMany [AWS Partners provide extensions](https:\u002F\u002Fdocs.aws.amazon.com\u002Flambda\u002Flatest\u002Fdg\u002Fextensions-api-partners.html) to \nintegrate with your Lambda functions.\n",[27,50,68,97,114,126,139],{"title":28,"collapsible":29,"isCollapsed":30,"content":31},"Introduction",false,true,[32],{"title":28,"order":33,"callout":34,"prerequisite":38,"resources":41,"time":46,"path":47,"id":48,"link":49},1,{"title":35,"description":36,"link":37},"Workshop","The workshop gives you a step-by-step guide of how to migrate a Spring Boot application to Lambda using the AWS Serverless Java Container library.","https:\u002F\u002Fcatalog.workshops.aws\u002Fjava-on-aws-lambda\u002Fen-US\u002F01-migration",[39,40],"Some understanding of Java","Some Understanding of AWS Lambda",[42],{"link":43,"text":44,"type":45},"https:\u002F\u002Faws.amazon.com\u002Flambda\u002F","Learn more about Lambda","text","2 min","introduction","introduction.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fpaved-path\u002Fjava-replatforming\u002Fintroduction",{"title":51,"collapsible":29,"isCollapsed":30,"content":52},"Access patterns",[53],{"title":54,"order":7,"callout":55,"resources":56,"learningGoals":63,"time":46,"path":65,"id":66,"link":67},"Access Patterns",{"title":35,"description":36,"link":37},[57,60],{"link":58,"type":16,"text":59},"https:\u002F\u002Fgithub.com\u002Fawslabs\u002Faws-lambda-web-adapter","AWS Lambda Web Adapter",{"link":61,"text":62,"type":16},"https:\u002F\u002Fgithub.com\u002Fawslabs\u002Faws-serverless-java-container","AWS Serverless Java Container",[64],"To learn the different approaches to replatforming REST APIs on Lambda","access-patterns","access-patterns.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fpaved-path\u002Fjava-replatforming\u002Faccess-patterns",{"title":69,"collapsible":29,"isCollapsed":30,"content":70},"SnapStart",[71],{"title":72,"youtubeVideoID":73,"order":7,"callout":74,"resources":77,"learningGoals":92,"time":46,"path":94,"id":95,"link":96},"Performance - SnapStart","ZbnAithBNYY",{"title":35,"description":75,"link":76},"Learn how SnapStart addresses Java function performance, how to enable SnapStart with IaC, and how to customize your SnapStart behavior with runtime hooks.","https:\u002F\u002Fcatalog.workshops.aws\u002Fjava-on-aws-lambda\u002Fen-US\u002F03-snapstart",[78,82,85,89],{"link":79,"text":80,"type":81},"https:\u002F\u002Fserverlessland.com\u002Fpatterns\u002Fapigw-lambda-snapstart","API Gateway to Lambda with SnapStart","Pattern",{"link":83,"type":81,"text":84},"https:\u002F\u002Fserverlessland.com\u002Fpatterns\u002Fapigw-lambda-rds-snapstart","REST API with Amazon API Gateway, Amazon RDS and AWS Lambda with SnapStart",{"link":86,"type":87,"text":88},"https:\u002F\u002Faws.amazon.com\u002Fblogs\u002Fcompute\u002Fstarting-up-faster-with-aws-lambda-snapstart\u002F?ref=serverlessland","Blog","Starting up faster with AWS Lambda SnapStart",{"link":90,"type":87,"text":91},"https:\u002F\u002Faws.amazon.com\u002Fblogs\u002Fcompute\u002Freducing-java-cold-starts-on-aws-lambda-functions-with-snapstart\u002F?ref=serverlessland","Reducing Java cold starts on AWS Lambda functions with SnapStart",[93],"Learn how Lambda SnapStart improves first invoke latency","snapstart","snapstart.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fpaved-path\u002Fjava-replatforming\u002Fsnapstart",{"title":98,"collapsible":29,"isCollapsed":30,"content":99},"Performance",[100],{"title":98,"youtubeVideoID":101,"order":7,"callout":102,"resources":104,"learningGoals":108,"time":110,"path":111,"id":112,"link":113},"sVJOJUD0fhQ",{"title":35,"description":103,"link":37},"Learn how to optimize Java Lambda functions.",[105],{"link":106,"type":87,"text":107},"https:\u002F\u002Faws.amazon.com\u002Fblogs\u002Fcompute\u002Foptimizing-aws-lambda-function-performance-for-java\u002F?ref=serverlessland","Optimizing AWS Lambda function performance for Java",[109],"How to optimization your Java function","1 min","performance","performance.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fpaved-path\u002Fjava-replatforming\u002Fperformance",{"title":115,"collapsible":29,"isCollapsed":30,"content":116},"Observability - Logging ",[117],{"title":118,"order":7,"callout":119,"learningGoals":120,"time":122,"path":123,"id":124,"link":125},"Observability - Logging",{"title":35,"description":36,"link":37},[121],"How to meet your logging requirements with Lambda","4 min","observability-and-logging","observability-and-logging.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fpaved-path\u002Fjava-replatforming\u002Fobservability-and-logging",{"title":6,"collapsible":29,"isCollapsed":29,"content":127},[128],{"title":6,"order":7,"callout":129,"resources":130,"learningGoals":134,"time":135,"path":136,"id":137,"link":138},{"title":9,"description":10,"link":11},[131,132,133],{"link":14,"text":15,"type":16},{"link":18,"text":19,"type":16},{"link":21,"text":22,"type":16},[24],"3 min","metrics","metrics.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fpaved-path\u002Fjava-replatforming\u002Fmetrics",{"title":140,"collapsible":29,"isCollapsed":30,"content":141},"Health checks",[142],{"title":143,"order":7,"learningGoals":144,"time":110,"path":146,"id":147,"link":148},"Health Checks",[145],"To understand when to use health checks with Lambda","health-checks","health-checks.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fpaved-path\u002Fjava-replatforming\u002Fhealth-checks","LESSON",[151],"content\u002Fcontributors\u002Fmark-sailes.json","Java Replatforming",1792578874734]