Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unified service tagging for AWS Lambda #9374

Merged
merged 6 commits into from
Dec 28, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions content/en/getting_started/tagging/unified_service_tagging.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,122 @@ to configure the `service` tag only in the configuration of the process check.
{{% /tab %}}
{{< /tabs >}}

### Serverless environment

#### AWS Lambda Functions

Depending on how you build and deploy your AWS Lambda-based serverless applications, you may have several options available for applying the `env`, `service` and `version` tags to metrics, traces and logs.

Note, these tags are expected to be specified through AWS resource tags, instead of environment variables. Specifically, the `DD_ENV`, `DD_SERVICE` and `DD_VERSION` environment variables are not supported.
tianchu marked this conversation as resolved.
Show resolved Hide resolved

{{< tabs >}}

{{% tab "Serverless Framework" %}}

Tag your Lambda functions using the [tags][1] option:

```yaml
# serverless.yml
service: service-name
provider:
name: aws
# to apply the tags to all functions
tags:
env: "<ENV>"
service: "<SERVICE>"
version: "<VERSION>"

functions:
hello:
# this function will inherit the service level tags config above
handler: handler.hello
world:
# this function will overwrite the tags
handler: handler.users
tags:
env: "<ENV>"
service: "<SERVICE>"
version: "<VERSION>"
```

If you have installed the [Datadog serverless plugin][2], the plugin automatically tag the Lambda functions with the `service` and `env` tags using the `service` and `stage` values from the serverless application definition, unless a `service` or `env` tag already exists.
tianchu marked this conversation as resolved.
Show resolved Hide resolved

[1]: https://www.serverless.com/framework/docs/providers/aws/guide/functions#tags
[2]: https://docs.datadoghq.com/serverless/serverless_integrations/plugin
{{% /tab %}}

{{% tab "AWS SAM" %}}

Tag your Lambda functions using the [Tags][1] option:

```yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
MyLambdaFunction:
Type: AWS::Serverless::Function
Properties:
Tags:
env: "<ENV>"
service: "<SERVICE>"
version: "<VERSION>"
```

If you have installed the [Datadog serverless macro][2], you can also specify a `service` and `env` tag as parameters:

```yaml
Transform:
- AWS::Serverless-2016-10-31
- Name: DatadogServerless
Parameters:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we adding functionality to support adding tags on all functions in your template.yml? Without additional context, this looks like a typo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant specifically for the version tag since that's not listed in the example here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think we need to update the macro to support the version tag first, and then come back to update this doc, since the version tag is not yet supported by the macro?

service: "<SERVICE>"
env: "<ENV>"
```

[1]: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html#sam-function-tags
[2]: https://docs.datadoghq.com/serverless/serverless_integrations/macro

{{% /tab %}}

{{% tab "AWS CDK" %}}

Tag your app, stack or individual Lambda functions using the [Tags class][1]. If you have installed the [Datadog serverless macro][2], you can also specify a `service` and `env` tag as parameters:

```javascript
import * as cdk from "@aws-cdk/core";

class CdkStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
this.addTransform("DatadogServerless");

new cdk.CfnMapping(this, "Datadog", {
mapping: {
Parameters: {
service: "<SERVICE>",
env: "<ENV>",
},
},
});
}
}
```

[1]: https://docs.aws.amazon.com/cdk/latest/guide/tagging.html
[2]: https://docs.datadoghq.com/serverless/serverless_integrations/macro

{{% /tab %}}

{{% tab "Custom" %}}

Apply the `env`, `service` and `version` tags following the AWS instructions for [Tagging Lambda Functions][1].

[1]: https://docs.aws.amazon.com/lambda/latest/dg/configuration-tags.html

{{% /tab %}}

{{< /tabs >}}

## Further Reading

{{< partial name="whats-next/whats-next.html" >}}
Expand Down
15 changes: 10 additions & 5 deletions content/en/serverless/installation/dotnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ You need to subscribe the Datadog Forwarder Lambda function to each of your func
1. [Install the Datadog Forwarder if you haven't][2].
2. [Subscribe the Datadog Forwarder to your function's log groups][5].

### Unified Service Tagging
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a section heading here? If it's just one section, we can leave this as a note or bold it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only a subsection under the Configuration section, but I can go either way.


Although it's optional, we highly recommend tagging you serverless applications with the `env`, `service`, and `version` tags following the [unified service tagging documentation][6].
tianchu marked this conversation as resolved.
Show resolved Hide resolved

## Explore Datadog Serverless Monitoring

After you have configured your function following the steps above, you should be able to view metrics, logs and traces on the [Serverless homepage][6].
After you have configured your function following the steps above, you should be able to view metrics, logs and traces on the [Serverless homepage][7].

### Monitor Custom Business Logic
## Monitor Custom Business Logic

If you would like to submit a custom metric, see the sample code below:

Expand All @@ -53,7 +57,7 @@ myMetric.Add("t", new string[] {"product:latte", "order:online"});
LambdaLogger.Log(JsonConvert.SerializeObject(myMetric));
```

For more information on custom metric submission, see [here][7].
For more information on custom metric submission, see [here][8].

## Further Reading

Expand All @@ -64,5 +68,6 @@ For more information on custom metric submission, see [here][7].
[3]: https://docs.aws.amazon.com/xray/latest/devguide/xray-services-lambda.html
[4]: https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-dotnet.html
[5]: /logs/guide/send-aws-services-logs-with-the-datadog-lambda-function/#collecting-logs-from-cloudwatch-log-group
[6]: https://app.datadoghq.com/functions
[7]: /serverless/custom_metrics?tab=otherruntimes
[6]: /getting_started/tagging/unified_service_tagging/#aws-lambda-functions
[7]: https://app.datadoghq.com/functions
[8]: /serverless/custom_metrics?tab=otherruntimes
15 changes: 10 additions & 5 deletions content/en/serverless/installation/go.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ You need to subscribe the Datadog Forwarder Lambda function to each of your func
1. [Install the Datadog Forwarder if you haven't][2].
2. [Subscribe the Datadog Forwarder to your function's log groups][5].

### Unified Service Tagging

Although it's optional, we highly recommend tagging you serverless applications with the `env`, `service`, and `version` tags following the [unified service tagging documentation][6].
tianchu marked this conversation as resolved.
Show resolved Hide resolved

## Explore Datadog Serverless Monitoring

After you have configured your function following the steps above, you should be able to view metrics, logs and traces on the [Serverless Homepage][6].
After you have configured your function following the steps above, you should be able to view metrics, logs and traces on the [Serverless Homepage][7].

### Monitor Custom Business Logic
## Monitor Custom Business Logic

If you would like to submit a custom metric, see the sample code below:

Expand Down Expand Up @@ -115,7 +119,7 @@ func myHandler(ctx context.Context, event MyEvent) (string, error) {
}
```

For more information on custom metric submission, see [here][7].
For more information on custom metric submission, see [here][8].

## Further Reading

Expand All @@ -126,5 +130,6 @@ For more information on custom metric submission, see [here][7].
[3]: https://github.com/DataDog/datadog-lambda-go
[4]: https://docs.aws.amazon.com/xray/latest/devguide/xray-services-lambda.html
[5]: /logs/guide/send-aws-services-logs-with-the-datadog-lambda-function/#collecting-logs-from-cloudwatch-log-group
[6]: https://app.datadoghq.com/functions
[7]: /serverless/custom_metrics?tab=go
[6]: /getting_started/tagging/unified_service_tagging/#aws-lambda-functions
[7]: https://app.datadoghq.com/functions
[8]: /serverless/custom_metrics?tab=go
15 changes: 10 additions & 5 deletions content/en/serverless/installation/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,15 @@ You need to subscribe the Datadog Forwarder Lambda function to each of your func
1. [Install the Datadog Forwarder if you haven't][2].
2. [Subscribe the Datadog Forwarder to your function's log groups][5].

### Unified Service Tagging

Although it's optional, we highly recommend tagging you serverless applications with the `env`, `service`, and `version` tags following the [unified service tagging documentation][6].
tianchu marked this conversation as resolved.
Show resolved Hide resolved

## Explore Datadog Serverless Monitoring

After you have configured your function following the steps above, you should be able to view metrics, logs and traces on the [Serverless Homepage][6].
After you have configured your function following the steps above, you should be able to view metrics, logs and traces on the [Serverless Homepage][7].

### Monitor Custom Business Logic
## Monitor Custom Business Logic

If you would like to submit a custom metric, see the sample code below:

Expand Down Expand Up @@ -118,7 +122,7 @@ public class Handler implements RequestHandler<APIGatewayV2ProxyRequestEvent, AP
}
```

For more information on custom metric submission, see [here][7].
For more information on custom metric submission, see [here][8].

## Further Reading

Expand All @@ -129,5 +133,6 @@ For more information on custom metric submission, see [here][7].
[3]: https://img.shields.io/bintray/v/datadog/datadog-maven/datadog-lambda-java
[4]: https://docs.aws.amazon.com/xray/latest/devguide/xray-services-lambda.html
[5]: /logs/guide/send-aws-services-logs-with-the-datadog-lambda-function/#collecting-logs-from-cloudwatch-log-group
[6]: https://app.datadoghq.com/functions
[7]: /serverless/custom_metrics?tab=java
[6]: /getting_started/tagging/unified_service_tagging/#aws-lambda-functions
[7]: https://app.datadoghq.com/functions
[8]: /serverless/custom_metrics?tab=java
43 changes: 24 additions & 19 deletions content/en/serverless/installation/nodejs.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ For example:
datadog-ci lambda instrument -f my-function -f another-function -r us-east-1 -v 26 --forwarder arn:aws:lambda:us-east-1:000000000000:function:datadog-forwarder
```

If your Lambda function is configured to use code signing, you must add Datadog's Signing Profile ARN (`arn:aws:signer:us-east-1:464622532012:/signing-profiles/DatadogLambdaSigningProfile/9vMI9ZAGLc`) to your function's [Code Signing Configuration][5] before you can instrument it with the Datadog CLI.
If your Lambda function is configured to use code signing, you must add Datadog's Signing Profile ARN (`arn:aws:signer:us-east-1:464622532012:/signing-profiles/DatadogLambdaSigningProfile/9vMI9ZAGLc`) to your function's [Code Signing Configuration][4] before you can instrument it with the Datadog CLI.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note - can we remove this from the main installation steps into a separate file? I think since this doesn't apply to most customers this will come off as confusing ("This seems complicated, I don't know if I should set this up") and makes our happy path installation instructions longer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove this for all runtimes, a potential solution is to add a new Code Signing page under the "Serverless Integrations" section.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can shorten the paragraph and link it to a separate page, but I don't think we should remove this paragraph completely here, because for customers having code signing enforcement enabled this is a must-do step. Of course, it's a relatively new feature so it's less important right now, but I don't know if it's going to be adopted more widely in the future. Either way, I think this should be a separate PR, and probably we should also consult @nhinsch's opinion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding from takes from serverless devs online is this something more niche that people in enterprises know to look for to check an audit/compliance checkbox (as opposed to something they aren't sure whether or not they need), so I think there's more benefit to putting this in a separate page so our instructions are more straightforward.


More information and additional parameters can be found in the [CLI documentation][4].
More information and additional parameters can be found in the [CLI documentation][5].

[1]: https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html
[2]: https://github.com/DataDog/datadog-lambda-js/releases
[3]: https://docs.datadoghq.com/serverless/forwarder/
[4]: https://docs.datadoghq.com/serverless/serverless_integrations/cli
[5]: https://docs.aws.amazon.com/lambda/latest/dg/configuration-codesigning.html#config-codesigning-config-update
[4]: https://docs.aws.amazon.com/lambda/latest/dg/configuration-codesigning.html#config-codesigning-config-update
[5]: https://docs.datadoghq.com/serverless/serverless_integrations/cli
{{% /tab %}}
{{% tab "Container Image" %}}

Expand Down Expand Up @@ -244,9 +244,9 @@ You need to subscribe the Datadog Forwarder Lambda function to each of your func
1. [Install the Datadog Forwarder if you haven't][1].
2. [Subscribe the Datadog Forwarder to your function's log groups][2].


[1]: https://docs.datadoghq.com/serverless/forwarder/
[2]: https://docs.datadoghq.com/logs/guide/send-aws-services-logs-with-the-datadog-lambda-function/#collecting-logs-from-cloudwatch-log-group

{{% /tab %}}
{{% tab "Custom" %}}

Expand Down Expand Up @@ -274,7 +274,7 @@ The available `RUNTIME` options are `Node10-x` and `Node12-x`. For `VERSION`, se
arn:aws:lambda:us-east-1:464622532012:layer:Datadog-Node12-x:25
```

If your Lambda function is configured to use code signing, you must add Datadog's Signing Profile ARN (`arn:aws:signer:us-east-1:464622532012:/signing-profiles/DatadogLambdaSigningProfile/9vMI9ZAGLc`) to your function's [Code Signing Configuration][6] before you can add the Datadog Lambda library as a layer.
If your Lambda function is configured to use code signing, you must add Datadog's Signing Profile ARN (`arn:aws:signer:us-east-1:464622532012:/signing-profiles/DatadogLambdaSigningProfile/9vMI9ZAGLc`) to your function's [Code Signing Configuration][3] before you can add the Datadog Lambda library as a layer.

#### Using the Package

Expand All @@ -290,7 +290,7 @@ npm install --save datadog-lambda-js
yarn add datadog-lambda-js
```

See the [latest release][3].
See the [latest release][4].

### Configure the Function

Expand All @@ -304,24 +304,28 @@ See the [latest release][3].

You need to subscribe the Datadog Forwarder Lambda function to each of your function’s log groups, in order to send metrics, traces, and logs to Datadog.

1. [Install the Datadog Forwarder if you haven't][4].
2. [Subscribe the Datadog Forwarder to your function's log groups][5].
1. [Install the Datadog Forwarder if you haven't][5].
2. [Subscribe the Datadog Forwarder to your function's log groups][6].


[1]: https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html
[2]: https://github.com/DataDog/datadog-lambda-layer-js/releases
[3]: https://www.npmjs.com/package/datadog-lambda-js
[4]: https://docs.datadoghq.com/serverless/forwarder/
[5]: https://docs.datadoghq.com/logs/guide/send-aws-services-logs-with-the-datadog-lambda-function/#collecting-logs-from-cloudwatch-log-group
[6]: https://docs.aws.amazon.com/lambda/latest/dg/configuration-codesigning.html#config-codesigning-config-update
[3]: https://docs.aws.amazon.com/lambda/latest/dg/configuration-codesigning.html#config-codesigning-config-update
[4]: https://www.npmjs.com/package/datadog-lambda-js
[5]: https://docs.datadoghq.com/serverless/forwarder/
[6]: https://docs.datadoghq.com/logs/guide/send-aws-services-logs-with-the-datadog-lambda-function/#collecting-logs-from-cloudwatch-log-group
{{% /tab %}}
{{< /tabs >}}

### Unified Service Tagging

Although it's optional, we highly recommend tagging you serverless applications with the `env`, `service`, and `version` tags following the [unified service tagging documentation][3].
tianchu marked this conversation as resolved.
Show resolved Hide resolved

## Explore Datadog Serverless Monitoring

After you have configured your function following the steps above, you can view metrics, logs and traces on the [Serverless Homepage][3].
After you have configured your function following the steps above, you can view metrics, logs and traces on the [Serverless Homepage][4].

### Monitor Custom Business Logic
## Monitor Custom Business Logic

If you would like to submit a custom metric or span, see the sample code below:

Expand Down Expand Up @@ -372,14 +376,15 @@ exports.handler = async (event) => {
};
```

For more information on custom metric submission, see [here][4]. For additional details on custom instrumentation, see the Datadog APM documentation for [custom instrumentation][5].
For more information on custom metric submission, see [here][5]. For additional details on custom instrumentation, see the Datadog APM documentation for [custom instrumentation][6].

## Further Reading

{{< partial name="whats-next/whats-next.html" >}}

[1]: /integrations/amazon_web_services/
[2]: /serverless/forwarder
[3]: https://app.datadoghq.com/functions
[4]: /serverless/custom_metrics?tab=nodejs
[5]: /tracing/custom_instrumentation/nodejs/
[3]: /getting_started/tagging/unified_service_tagging/#aws-lambda-functions
[4]: https://app.datadoghq.com/functions
[5]: /serverless/custom_metrics?tab=nodejs
[6]: /tracing/custom_instrumentation/nodejs/
Loading