diff --git a/content/en/getting_started/serverless/_index.md b/content/en/getting_started/serverless/_index.md index 720b8dcef4752..662e824bcf6c6 100644 --- a/content/en/getting_started/serverless/_index.md +++ b/content/en/getting_started/serverless/_index.md @@ -14,87 +14,51 @@ further_reading: _Serverless_ is a model where developers build and run applications and services using a cloud provider, rather than managing infrastructure themselves. Datadog [Serverless Monitoring][1] collects metrics, logs, and traces from your serverless infrastructure, enabling you to monitor your application's health and performance. -This guide makes use of a serverless [sample app][2] that you can launch with one click. This app has Serverless Monitoring preconfigured. Follow this guide to see how you might troubleshoot a problem in your sample app, and what kinds of visibility Serverless Monitoring can provide. +This guide makes use of a serverless [sample app][2] that you can launch using a programming language and infrastructure as code (IaC) tool you are familiar with. This app has Serverless Monitoring preconfigured. Follow this guide to see how you might troubleshoot a problem in your sample app, and what kinds of visibility Serverless Monitoring can provide. -### Install the sample app +### Deploy the sample app -1. [Launch the CloudFormation Stack][3]. This link brings you to a **Create stack** page in CloudFormation. -2. Enter your [Datadog API key][4] and [Datadog site][5] ({{< region-param key="dd_site" code="true" >}}). +1. Clone the [sample app][3] repository to your local machine. +2. Choose a runtime and IaC tool of your choice and follow the link to the specific deployment instructions +3. Find your [Datadog API key][4] and [Datadog site][5] ({{< region-param key="dd_site" code="true" >}}). You will need them for the next step. +4. Follow the runtime and IaC specific instructions to deploy the sample application. +5. After the deployment completes, you can either use the Postman collection in the root of the repository or run the [load test][6]. - {{< img src="getting_started/serverless/aws_create_stack.png" alt="Close-up of two functions" style="width:80%;">}} +You can [see your sample app functions in Serverless View][7]. - Then, acknowledge IAM capabilities and click **Create Stack**. - -3. After the stack has been created, open the Outputs tab. - - {{< img src="getting_started/serverless/aws_outputs.png" alt="Close-up of two functions" style="width:80%;">}} - - Invoke your sample app a few times by visiting the `ApiGatewayInvokeURL`. This returns a "Sent message to SNS" success message. - -Each invocation executes the following: - -```python -import boto3, os - -def handler(event, context): - sns = boto3.client('sns') - - sns.publish( - TopicArn=os.environ.get("SNS_TOPIC_ARN"), - Message='Message sent to SNS' - ) - - return { - "body": "Sent message to SNS", - "statusCode": 200 - } -``` - -You can [see your sample app functions in Serverless View][6]. - -{{< img src="getting_started/serverless/serverless_view_2024.png" alt="Serverless Monitoring: Serverless View, an explorer page" style="width:80%;">}} +{{< img src="getting_started/serverless/serverless_view_2024_2.png" alt="Serverless Monitoring: Serverless View, an explorer page" style="width:80%;">}} ## Serverless View The Serverless View displays telemetry from all serverless resources in your AWS environment. You can use this page as a starting point for monitoring, debugging, and optimizing your applications. -If you have invoked your sample app at least once, you will see `datadog-sample-entry-function` and `datadog-sample-sqs-consumer-function`: +The Serverless View groups your resources by the `SERVICE_NAME`. If you have invoked your functions at least once, you will see a seperate service group for each of the individual backend services. -{{< img src="getting_started/serverless/functions_view.png" alt="Close-up of two functions" style="width:80%;">}} +{{< img src="getting_started/serverless/functions_view_2.png" alt="Close-up of two functions" style="width:80%;">}} ### Serverless Insights -In Serverless View, the rightmost column is titled **Insights**. Datadog automatically highlights potential issues in your serverless applications, such as [high errors][7] and [high duration][8]; these issues appear in the Insights column. - -For your serverless sample application, Datadog has likely detected a [cold start][9]. Cold starts occur when your serverless application receives a sudden increase in traffic. This can happen if the function was previously receiving a relatively constant number of requests and abruptly started receiving more—or, as in this case, when the function was previously inactive and has been invoked for the first time. - -## Create an error to investigate +In Serverless View, the rightmost column is titled **Insights**. Datadog automatically highlights potential issues in your serverless applications, such as [high errors][8] and [high duration][9]; these issues appear in the Insights column. -You can intentionally cause an error by editing the `datadog-sample-entry-function` in the sample app stack. +For your serverless sample application, Datadog has likely detected a [cold start][10]. Cold starts occur when your serverless application receives a sudden increase in traffic. This can happen if the function was previously receiving a relatively constant number of requests and abruptly started receiving more—or, as in this case, when the function was previously inactive and has been invoked for the first time. -```python - # Entry Lambda Function Code - def handler(event, context): +## Investigate Errors - raise Exception('Throw an error.') -``` - -{{< img src="getting_started/serverless/aws_error.png" alt="Close-up of two functions" style="width:80%;">}} +The sample application periodically generates errors and has a slow response. This causes Lambda timeouts in the product pricing service. +{{< img src="getting_started/serverless/dd_serverless_view_error_2.png" alt="Close-up of two functions" style="width:80%;">}} -Deploy this change and invoke your sample app again to see how you can investigate this error in Datadog. +Notice that both of the services under the `product-pricing-service` have errors. The Issues & Insights section at the top also identifies that one of your services has issues with timeouts. -{{< img src="getting_started/serverless/dd_serverless_view_error.png" alt="Close-up of two functions" style="width:80%;">}} - -Notice that `datadog-sample-entry-function` has five errors. +{{< img src="getting_started/serverless/insights_and_issues.png" alt="Insights and issues view in serverless view" style="width:80%;">}} ## Function details Click on your function to see more details regarding invocations and recent deployments. -{{< img src="getting_started/serverless/details_error.png" alt="Close-up of two functions" style="width:80%;">}} +{{< img src="getting_started/serverless/details_error_2.png" alt="Close-up of two functions" style="width:80%;">}} -The detailed view, as shown above, contains three graphs. You can set these to display any available metric; by default, they show three [enhanced Lambda metrics][10]: invocations, errors, and duration. +The detailed view, as shown above, contains three graphs. You can set these to display any available metric; by default, they show three [enhanced Lambda metrics][11]: invocations, errors, and duration. -Datadog generates enhanced Lambda metrics out-of-the-box with low latency, several second granularity, and detailed metadata for cold starts and custom tags. You can also view the default [enhanced Lambda metrics dashboard][11]. +Datadog generates enhanced Lambda metrics out-of-the-box with low latency, several second granularity, and detailed metadata for cold starts and custom tags. You can also view the default [enhanced Lambda metrics dashboard][12]. ### Invocations @@ -102,23 +66,23 @@ The **Invocations** tab displays your function's latest invocations. Each invocation is associated with a trace. Click on **Open Trace** to see the trace for each invocation: -{{< img src="getting_started/serverless/dd_flame_graph.png" alt="Close-up of two functions" style="width:80%;">}} +{{< img src="getting_started/serverless/dd_flame_graph_2.png" alt="Close-up of two functions" style="width:80%;">}} + +The **Flame Graph** tab shows exactly what happened during the duration of this invocation, including which services had the highest percentage of the total execution time. The flame graph displays the request as it travels from APIGateway, through your `create-product-function`. -The **Flame Graph** tab shows exactly what happened during the duration of this invocation, including which services had the highest percentage of the total execution time. The flame graph displays the request as it travels from APIGateway, through your `datadog-sample-entry-function`, through SNS, SQS, and finally your `datadog-sample-sqs-function`. +If you zoom out, you will also see the entire end to end trace through all of the downstream services. -{{< img src="getting_started/serverless/trace_map.png" alt="Close-up of two functions" style="width:80%;">}} +{{< img src="getting_started/serverless/trace_map_2.png" alt="Close-up of two functions" style="width:80%;">}} The **Trace Map** tab visualizes the flow of your services and how they connect to each other. -The lower half of the detailed trace view displays a stack trace, which reveals the line of code responsible for throwing the error: +If you are viewing a trace with an error, the lower half of the detailed trace view shows the details: ``` -Traceback (most recent call last): - File /opt/python/lib/python3.9/site-packages/datadog_lambda/wrapper.py, line 142, in __call__ - self.response = self.func(event, context, **kwargs) -File /var/task/index.py, line 17, in handler - raise Exception('Throw an error.') -Exception: Throw an error. +Error: Failure generating prices + at PricingService.calculate (/var/task/index.js:94382:13) + at ProductUpdatedEventHandler.handle (/var/task/index.js:95826:51) + at handler (/var/task/index.js:95854:34) ``` Underneath, you can also examine your Lambda request and response payloads. Datadog collects event payloads for every Lambda invocation. @@ -127,20 +91,21 @@ Underneath, you can also examine your Lambda request and response payloads. Data The serverless sample app has logs enabled by default. You can see each function's logs under its **Logs** tab. -{{< img src="getting_started/serverless/dd_logs_view.png" alt="Close-up of two functions" style="width:80%;">}} +{{< img src="getting_started/serverless/dd_logs_view_2.png" alt="Close-up of two functions" style="width:80%;">}} -You can filter these logs to only see errors, or view them in the [Log Explorer][12]. +You can filter these logs to only see errors, or view them in the [Log Explorer][13]. [1]: /serverless [2]: https://github.com/DataDog/serverless-sample-app -[3]: https://console.aws.amazon.com/cloudformation/home#/stacks/create/review?stackName=datadog-serverless-sample-app&templateURL=https://datadog-cloudformation-template.s3.amazonaws.com/aws/serverless-sample-app/latest.yaml +[3]: https://github.com/DataDog/serverless-sample-app?tab=readme-ov-file#implementations [4]: https://app.datadoghq.com/organization-settings/api-keys [5]: https://docs.datadoghq.com/getting_started/site -[6]: https://app.datadoghq.com/functions?cloud=aws&text_search=datadog-serverless-sample-app -[7]: https://docs.datadoghq.com/serverless/guide/insights/#high-errors -[8]: https://docs.datadoghq.com/serverless/guide/insights/#high-duration -[9]: https://docs.datadoghq.com/serverless/guide/insights/#cold-starts -[10]: https://docs.datadoghq.com/serverless/enhanced_lambda_metrics -[11]: https://app.datadoghq.com/screen/integration/30306?_gl=1*19700i3*_ga*OTk0Mjg4Njg4LjE2NDIwOTM2OTY.*_ga_KN80RDFSQK*MTY0OTI3NzAyMC4xNTAuMS4xNjQ5MjgzMjI1LjA. -[12]: https://docs.datadoghq.com/logs/explorer/ +[6]: https://github.com/DataDog/serverless-sample-app/tree/main?tab=readme-ov-file#load-tests +[7]: https://app.datadoghq.com/functions?cloud=aws&text_search=product +[8]: https://docs.datadoghq.com/serverless/guide/insights/#high-errors +[9]: https://docs.datadoghq.com/serverless/guide/insights/#high-duration +[10]: https://docs.datadoghq.com/serverless/guide/insights/#cold-starts +[11]: https://docs.datadoghq.com/serverless/enhanced_lambda_metrics +[12]: https://app.datadoghq.com/screen/integration/30306?_gl=1*19700i3*_ga*OTk0Mjg4Njg4LjE2NDIwOTM2OTY.*_ga_KN80RDFSQK*MTY0OTI3NzAyMC4xNTAuMS4xNjQ5MjgzMjI1LjA. +[13]: https://docs.datadoghq.com/logs/explorer/ \ No newline at end of file diff --git a/content/en/serverless/aws_lambda/installation/_index.md b/content/en/serverless/aws_lambda/installation/_index.md index 2579d8d936216..3016ed027952b 100644 --- a/content/en/serverless/aws_lambda/installation/_index.md +++ b/content/en/serverless/aws_lambda/installation/_index.md @@ -16,10 +16,16 @@ further_reading: If you are new to Datadog, [sign up for a Datadog account][1], then follow the Datadog Agent installation instructions for [AWS Lambda][2] to instrument your Lambda function for a quick start with Datadog. Completing the steps configures your Lambda functions to send real-time metrics, logs, and traces to Datadog. +{{< beta-callout-private url="https://docs.google.com/forms/d/e/1FAIpQLScw8XBxCyN_wjBVU2tWm-zX5oPIGF7BwUKcLSHY6MJsem259g/viewform?usp=sf_link" >}} +Interested in bulk-instrumenting AWS Lambdas directly from the Datadog UI? To participate, request access to the upcoming remote Lambda instrumentation private beta. +{{< /beta-callout-private >}} + {{< callout url="https://www.datadoghq.com/product-preview/lambda-remote-instrumentation/" >}} Interested in bulk-instrumenting AWS Lambdas directly from the Datadog UI? To participate, request access to the upcoming remote Lambda instrumentation Preview. {{< /callout >}} +