forked from DataDog/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update serverless tagging doc (DataDog#9383)
- Loading branch information
Showing
2 changed files
with
32 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,130 +1,58 @@ | ||
--- | ||
title: Serverless Tagging | ||
kind: documentation | ||
further_reading: | ||
- link: "/getting_started/tagging/unified_service_tagging/#aws-lambda-functions" | ||
tag: "Documentation" | ||
text: "Unified Service Tagging" | ||
--- | ||
|
||
{{< img src="serverless/serverless_tagging.mp4" video="true" alt="Unified Serverless Tagging" >}} | ||
|
||
## Overview | ||
|
||
Any tag applied to your AWS Lambda function automatically becomes a new dimension on which you can slice and dice your traces. | ||
Any tag applied to your AWS Lambda function automatically becomes a new dimension on which you can slice and dice your metrics, traces and logs. | ||
|
||
Tags are especially powerful when consistent across the Datadog platform. First-class support is offered for the following tags: `env` and `service`. | ||
Tags are especially powerful when consistent across the Datadog platform. First-class support is offered for the following tags: `env`, `service` and `version`. | ||
|
||
With these two tags, you can: | ||
With these tags, you can: | ||
|
||
- Navigate seamlessly across metrics, traces, and logs with consistent tags | ||
- View service data based on environment or version in a unified fashion within the Datadog app | ||
- Filter your functions on the Serverless Homepage | ||
- View service data based on environment or version in a unified fashion within the Datadog app | ||
- Organize your service map by service and environment | ||
|
||
There are a few best practices Datadog recommends for tagging in your serverless environment to keep tags consistent across your traces, metrics, and logs. | ||
|
||
## Directly tag your serverless functions | ||
|
||
To surface tags from your Lambda functions across metrics, traces, and logs, Datadog recommends that you directly tag your Lambda functions with the appropriate `env` and `service`. Below are some sample tagging configurations for common serverless developer tools: | ||
|
||
{{< tabs >}} | ||
{{% tab "Serverless Framework" %}} | ||
|
||
If you are using the Serverless Framework, you can choose one of several options to apply tags across Datadog: | ||
|
||
1. Tags directly added at the provider scope will be applied across Datadog: | ||
|
||
```yaml | ||
provider: | ||
name: aws | ||
runtime: nodejs12.x | ||
tags: | ||
service: shopist-cart-confirmation | ||
env: prod | ||
version: 1.01 | ||
``` | ||
2. Tags directly added on each individual Lambda resource will be applied across Datadog: | ||
```yaml | ||
functions: | ||
confirmCart: | ||
handler: cart.confirm | ||
tags: | ||
service: shopist-cart-confirmation | ||
env: prod | ||
version: 1.01 | ||
events: | ||
- http: | ||
path: ping | ||
method: get | ||
|
||
``` | ||
|
||
3. If you are using the Datadog Serverless Framework Plugin, native Serverless Framework `service` and `stage` tags will be surfaced as `service` and `env` across Datadog: | ||
|
||
```yaml | ||
service: shopist-cart-confirmation | ||
|
||
provider: | ||
name: aws | ||
runtime: nodejs12.x | ||
stage: prod | ||
``` | ||
{{% /tab %}} | ||
{{% tab "AWS SAM" %}} | ||
If you are using the AWS SAM, you can choose one of several options to apply tags across Datadog: | ||
To tag your serverless application with `env`, `service` and `version`, see the [unified service tagging documentation][1]. | ||
|
||
1. Tags directly added on each individual Lambda resource will be applied across Datadog: | ||
### The env tag | ||
|
||
```yaml | ||
Resources: | ||
confirmCart: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
Handler: src/handlers/cart.confirm | ||
Tags: | ||
env: prod | ||
service: shopist-cart-confirmation | ||
``` | ||
Use `env` to separate out your staging, development, and production environments. This works for any kind of infrastructure, not just for your serverless functions. As an example, you could tag your production EU Lambda functions with `env:prod-eu`. | ||
|
||
2. If you are using the Datadog CloudFormation Macro, tags directly added in the `Transform` scope will be applied across Datadog: | ||
By default, AWS Lambda functions are tagged with `env:none` in Datadog. Add your own tag to override this. | ||
|
||
```yaml | ||
Transform: | ||
- AWS::Serverless-2016-10-31 | ||
- Name: DatadogServerless | ||
Parameters: | ||
nodeLayerVersion: 25 | ||
forwarderArn: "arn:aws:lambda:us-east-1:000000000000:function:datadog-forwarder" | ||
stackName: !Ref "AWS::StackName" | ||
service: "shopist-cart-confirmation" | ||
env: "prod" | ||
``` | ||
### The service tag | ||
|
||
{{% /tab %}} | ||
{{< /tabs >}} | ||
Add the `service` tag in order to group related Lambda functions into a service. | ||
|
||
The default behavior for new Datadog customers is for all Lambda functions to be grouped under the `aws.lambda` service, and represented as a single node on the Service map. Tag your functions by service to override this. | ||
|
||
### Import resource tags from your serverless Functions | ||
**Note:** For some Datadog customers, each Lambda function is treated as its own service. Add your own tag to override this, or reach out to Datadog Support if you would like to your account to adopt the new behavior. | ||
|
||
Datadog strongly recommends you enable the `DdFetchLambdaTags` option on the Datadog Forwarder. Setting the parameter `DdFetchLambdaTags` to `true` on the Forwarder CloudFormation stack will ensure your traces are tagged with the resource tags on the originating Lambda function. | ||
### The version tag | ||
|
||
Lambda function resource tags are automatically surfaced to X-Ray traces in Datadog without any additional configuration. | ||
Add the `version` tag to enable [Deployment Tracking][2]. | ||
|
||
## Organize your service map | ||
|
||
{{< img src="serverless/serverless_service_map.png" alt="Service Map" >}} | ||
|
||
### The env tag | ||
|
||
Use `env` to separate out your staging, development, and production environments. This works for any kind of infrastructure, not just for your serverless functions. As an example, you could tag your production EU Lambda functions with `env:prod-eu`. | ||
The [Service Map][3] groups services into maps by the `env` tag, and uses the `service` tag to show relationships between services and the health of their monitors. Services are represented as individual nodes on the Service Map. The color of the nodes represents the health of the associated monitors. Tag any monitor with the same `service` tag to associate. | ||
|
||
By default, AWS Lambda functions are tagged with `env:none` in Datadog. Add your own tag to override this. | ||
{{< img src="serverless/serverless_service_map.png" alt="Service Map" >}} | ||
|
||
### The service tag | ||
## Further Reading | ||
|
||
Add the `service` tag in order to group related Lambda functions into a service. The Service Map and Services List use this tag to show relationships between services and the health of their monitors. Services are represented as individual nodes on the Service Map. | ||
{{< partial name="whats-next/whats-next.html" >}} | ||
|
||
The default behavior for new Datadog customers is for all Lambda functions to be grouped under the `aws.lambda` service, and represented as a single node on the Service map. Tag your functions by service to override this. | ||
|
||
**Note:** For some Datadog customers, each Lambda function is treated as its own service. Add your own tag to override this, or reach out to Datadog Support if you would like to your account to adopt the new behavior. | ||
[1]: /getting_started/tagging/unified_service_tagging/#aws-lambda-functions | ||
[2]: /tracing/deployment_tracking/ | ||
[3]: /tracing/visualization/services_map/ |