Skip to content

Commit 694e1ea

Browse files
authored
[AWSX] feat(logs forwarder): update template and document custom source overriding (#1037)
1 parent 319a81c commit 694e1ea

File tree

2 files changed

+63
-47
lines changed

2 files changed

+63
-47
lines changed

aws/logs_monitoring/README.md

Lines changed: 53 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ aliases:
1212

1313
The Datadog Forwarder is an AWS Lambda function that ships logs from AWS to Datadog, specifically:
1414

15-
- Forward CloudWatch and S3 logs.
16-
- Forward logs from SNS, and Kinesis events to Datadog.
17-
- Kinesis data stream events support CloudWatch logs only.
18-
- Forward metrics, traces, and logs from AWS Lambda functions to Datadog. Datadog recommends to use [Datadog Lambda Extension][1] to monitor Lambda functions.
15+
- Forward CloudWatch and S3 logs.
16+
- Forward logs from SNS, and Kinesis events to Datadog.
17+
- Kinesis data stream events support CloudWatch logs only.
18+
- Forward metrics, traces, and logs from AWS Lambda functions to Datadog. Datadog recommends to use [Datadog Lambda Extension][1] to monitor Lambda functions.
1919

2020
For Serverless customers using the Forwarder to forward metrics, traces, and logs from AWS Lambda logs to Datadog, you should [migrate to the Datadog Lambda Extension][3] to collect telemetry directly from the Lambda execution environments. The Forwarder is still available for use in Serverless Monitoring, but will not be updated to support the latest features.
2121

@@ -60,23 +60,23 @@ If you're using AWS Organizations, you can use CloudFormation StackSets to deplo
6060
1. Deploy the Forwarder template using [CloudFormation StackSets][151] in the AWS Console.
6161
2. In the **Permissions** section, optionally provide an IAM admin role ARN, or leave the default IAM execution role name (`AWSCloudFormationStackSetExecutionRole`).
6262
3. In the **Specify template** section:
63-
1. Select **Amazon S3 URL**.
64-
1. Enter the Forwarder template URL: `https://datadog-cloudformation-template.s3.amazonaws.com/aws/forwarder/latest.yaml`.
65-
1. Click **Next**.
63+
1. Select **Amazon S3 URL**.
64+
1. Enter the Forwarder template URL: `https://datadog-cloudformation-template.s3.amazonaws.com/aws/forwarder/latest.yaml`.
65+
1. Click **Next**.
6666
4. In the **Specify stack set details** section:
67-
1. Provide a stack set name.
68-
1. Provide a valid Datadog API key using **one** of the `DdApiKey`, `DdApiKeySecretArn`, or `DdApiKeySsmParameterName` fields.
69-
1. Select the appropriate Datadog site in the `DdSite` field.
70-
1. Optionally, configure other parameters.
71-
1. Click **Next**.
67+
1. Provide a stack set name.
68+
1. Provide a valid Datadog API key using **one** of the `DdApiKey`, `DdApiKeySecretArn`, or `DdApiKeySsmParameterName` fields.
69+
1. Select the appropriate Datadog site in the `DdSite` field.
70+
1. Optionally, configure other parameters.
71+
1. Click **Next**.
7272
5. In the **Configure stack set options** section:
73-
1. Optionally, configure the provided options.
74-
1. Check the box under **Capabilities**.
75-
1. Click **Next**.
73+
1. Optionally, configure the provided options.
74+
1. Check the box under **Capabilities**.
75+
1. Click **Next**.
7676
6. On the **Set deployment options** page:
77-
1. Select **Deploy stacks in accounts** and enter your AWS account IDs.
78-
1. Under **Specify regions**, add target regions where you want to deploy the Forwarder.
79-
1. Click **Next**.
77+
1. Select **Deploy stacks in accounts** and enter your AWS account IDs.
78+
1. Under **Specify regions**, add target regions where you want to deploy the Forwarder.
79+
1. Click **Next**.
8080
7. Review the details, and click **Submit**.
8181

8282
#### Multiple accounts
@@ -87,15 +87,15 @@ If you're using AWS Organizations, you can use CloudFormation StackSets to deplo
8787
2. Deploy from the organization management account using [CloudFormation StackSets][151].
8888
3. In the **Permissions** section, choose **Service-managed permissions**. This option allows CloudFormation StackSets to create the necessary IAM roles in target accounts automatically.
8989
4. In the **Specify template** section:
90-
1. Select **Amazon S3 URL**.
91-
1. Enter the Forwarder template URL: `https://datadog-cloudformation-template.s3.amazonaws.com/aws/forwarder/latest.yaml`.
92-
1. Click **Next**.
90+
1. Select **Amazon S3 URL**.
91+
1. Enter the Forwarder template URL: `https://datadog-cloudformation-template.s3.amazonaws.com/aws/forwarder/latest.yaml`.
92+
1. Click **Next**.
9393
5. In the **Specify stack set details** section:
94-
1. Provide a stack set name.
95-
1. Provide a valid Datadog API key using **one** of the `DdApiKey`, `DdApiKeySecretArn`, or `DdApiKeySsmParameterName` fields.
96-
1. Select the appropriate Datadog site in the `DdSite` field.
97-
1. Optionally, configure other parameters.
98-
1. Click **Next**.
94+
1. Provide a stack set name.
95+
1. Provide a valid Datadog API key using **one** of the `DdApiKey`, `DdApiKeySecretArn`, or `DdApiKeySsmParameterName` fields.
96+
1. Select the appropriate Datadog site in the `DdSite` field.
97+
1. Optionally, configure other parameters.
98+
1. Click **Next**.
9999
6. Choose **Deploy to organization** and specify target organizational units (OUs) or individual accounts, along with the regions where you want to deploy the Forwarder.
100100

101101
**Note**: Regardless of whether you specify organizational units or individual accounts, you must [set up triggers][155] after the Forwarder is deployed.
@@ -184,10 +184,10 @@ If you encounter issues upgrading to the latest version, check the Troubleshooti
184184

185185
Key breaking changes in v5.0.0:
186186

187-
- **Log filtering behavior changed**: `IncludeAtMatch` and `ExcludeAtMatch` now match against the log message only, not the entire JSON structure
188-
- **TCP transport removed**: `DD_USE_TCP` parameter removed, all logs must use HTTP/HTTPS
189-
- **PrivateLink variable removed**: `DD_USE_PRIVATE_LINK` removed (PrivateLink is still supported via `DdUseVPC`)
190-
- **New tag enrichment**: Backend-based tag enrichment enabled by default via `DdEnrichS3Tags` and `DdEnrichCloudwatchTags`, reducing forwarder costs
187+
- **Log filtering behavior changed**: `IncludeAtMatch` and `ExcludeAtMatch` now match against the log message only, not the entire JSON structure
188+
- **TCP transport removed**: `DD_USE_TCP` parameter removed, all logs must use HTTP/HTTPS
189+
- **PrivateLink variable removed**: `DD_USE_PRIVATE_LINK` removed (PrivateLink is still supported via `DdUseVPC`)
190+
- **New tag enrichment**: Backend-based tag enrichment enabled by default via `DdEnrichS3Tags` and `DdEnrichCloudwatchTags`, reducing forwarder costs
191191

192192
### Upgrade an older version to 4.13.0+
193193

@@ -361,13 +361,13 @@ If you must deploy the Forwarder to a VPC without direct public internet access,
361361
4. Ensure the `DdFetchLambdaTags`, `DdFetchStepFunctionsTags`, and `DdFetchS3Tags` options are disabled, because AWS VPC does not yet offer an endpoint for the Resource Groups Tagging API.
362362
5. If you are using HAProxy or NGINX:
363363
364-
- Set `DdApiUrl` to `http://<proxy_host>:3834` or `https://<proxy_host>:3834`.
365-
- Set `DdTraceIntakeUrl` to `http://<proxy_host>:3835` or `https://<proxy_host>:3835`.
366-
- Set `DdUrl` to `<proxy_host>` and `DdPort` to `3837`.
364+
- Set `DdApiUrl` to `http://<proxy_host>:3834` or `https://<proxy_host>:3834`.
365+
- Set `DdTraceIntakeUrl` to `http://<proxy_host>:3835` or `https://<proxy_host>:3835`.
366+
- Set `DdUrl` to `<proxy_host>` and `DdPort` to `3837`.
367367
368368
Otherwise, if you are using Web Proxy:
369369
370-
- Set `DdHttpProxyURL` to your proxy endpoint, for example: `http://<proxy_host>:<port>`, or, if your proxy has a username and password, `http://<username>:<password>@<proxy_host>:<port>`.
370+
- Set `DdHttpProxyURL` to your proxy endpoint, for example: `http://<proxy_host>:<port>`, or, if your proxy has a username and password, `http://<username>:<password>@<proxy_host>:<port>`.
371371
372372
7. Set `DdNoSsl` to `true` if connecting to the proxy using `http`.
373373
8. Set `DdSkipSslValidation` to `true` if connecting to the proxy using `https` with a self-signed certificate.
@@ -423,6 +423,9 @@ Datadog recommends using at least 10 reserved concurrency, but this defaults to
423423
`DdTags`
424424
: Add custom tags to forwarded logs, comma-delimited string, no trailing comma, such as `env:prod,stack:classic`.
425425
426+
`DdSource`
427+
: Override the `ddsource` attribute for all logs forwarded by Lambda Forwarder. By default, the Forwarder automatically detects the source based on the log origin (for example: `lambda`, `s3`, `cloudwatch`, `rds`). When set, all logs will use the specified source value instead, and a `source_overridden:true` tag will be added to the logs.
428+
426429
`DdMultilineLogRegexPattern`
427430
: Use the supplied regular expression to detect for a new log line for multiline logs from S3, such as `\d{2}\/\d{2}\/\d{4}` for multiline logs beginning with pattern "11/10/2014".
428431
@@ -473,10 +476,10 @@ Filtering rules are applied to the log message. However, transformations applied
473476
474477
Some examples of regular expressions that can be used for log filtering:
475478
476-
- Include (or exclude) Lambda platform logs: `(START|END) RequestId:\s`. Datadog recommends keeping the `REPORT` logs, as they are used to populate the invocations list in the serverless function views.
477-
- Include CloudTrail error messages only: `errorMessage`.
478-
- Include only logs containing an HTTP 4XX or 5XX error code: `\b[4|5][0-9][0-9]\b`.
479-
- Include only CloudWatch logs where the `message` field contains a specific JSON key/value pair: `"awsRegion":"us-east-1"`.
479+
- Include (or exclude) Lambda platform logs: `(START|END) RequestId:\s`. Datadog recommends keeping the `REPORT` logs, as they are used to populate the invocations list in the serverless function views.
480+
- Include CloudTrail error messages only: `errorMessage`.
481+
- Include only logs containing an HTTP 4XX or 5XX error code: `\b[4|5][0-9][0-9]\b`.
482+
- Include only CloudWatch logs where the `message` field contains a specific JSON key/value pair: `"awsRegion":"us-east-1"`.
480483
481484
To test different patterns against your logs, turn on [debug logs](#troubleshooting).
482485
@@ -601,6 +604,9 @@ Datadog recommends using at least 10 reserved concurrency, but this defaults to
601604
`DD_TAGS`
602605
: Add custom tags to forwarded logs, comma-delimited string, no trailing comma, such as `env:prod,stack:classic`.
603606
607+
`DD_SOURCE`
608+
: Override the `ddsource` attribute for all logs forwarded by Lambda Forwarder. By default, the Forwarder automatically detects the source based on the log origin (for example: `lambda`, `s3`, `cloudwatch`, `rds`). When set, all logs will use the specified source value instead, and a `source_overridden:true` tag will be added to the logs.
609+
604610
`DD_MULTILINE_LOG_REGEX_PATTERN`
605611
: Use the supplied regular expression to detect for a new log line for multiline logs from S3, such as `\d{2}\/\d{2}\/\d{4}` for multiline logs beginning with pattern "11/10/2014".
606612
@@ -651,10 +657,10 @@ Filtering rules are applied to the log message as read by the forwarder. Using a
651657
652658
Some examples of regular expressions that can be used for log filtering:
653659
654-
- Include (or exclude) Lambda platform logs: `(START|END) RequestId:\s`. Datadog recommends keeping the `REPORT` logs, as they are used to populate the invocations list in the serverless function views.
655-
- Include CloudTrail error messages only: `errorMessage`.
656-
- Include only logs containing an HTTP 4XX or 5XX error code: `\b[4|5][0-9][0-9]\b`.
657-
- Include only CloudWatch logs where the `message` field contains a specific JSON key/value pair: `"awsRegion":"us-east-1"`.
660+
- Include (or exclude) Lambda platform logs: `(START|END) RequestId:\s`. Datadog recommends keeping the `REPORT` logs, as they are used to populate the invocations list in the serverless function views.
661+
- Include CloudTrail error messages only: `errorMessage`.
662+
- Include only logs containing an HTTP 4XX or 5XX error code: `\b[4|5][0-9][0-9]\b`.
663+
- Include only CloudWatch logs where the `message` field contains a specific JSON key/value pair: `"awsRegion":"us-east-1"`.
658664
659665
To test different patterns against your logs, turn on [debug logs](#troubleshooting).
660666
@@ -756,12 +762,12 @@ To deploy the CloudFormation Stack with the default options, you need to have th
756762

757763
The following capabilities are required when creating a CloudFormation stack:
758764

759-
- CAPABILITY_AUTO_EXPAND, because the forwarder template uses macros such as the [AWS SAM macro][23].
760-
- CAPABILTY_IAM/NAMED_IAM, because the Forwarder creates IAM roles.
765+
- CAPABILITY_AUTO_EXPAND, because the forwarder template uses macros such as the [AWS SAM macro][23].
766+
- CAPABILTY_IAM/NAMED_IAM, because the Forwarder creates IAM roles.
761767

762768
The CloudFormation Stack creates following IAM roles:
763769

764-
- ForwarderRole: The execution role for the Forwarder Lambda function to read logs from S3, fetch your Datadog API key from Secrets Manager, and write its own logs.
770+
- ForwarderRole: The execution role for the Forwarder Lambda function to read logs from S3, fetch your Datadog API key from Secrets Manager, and write its own logs.
765771

766772
**IAM statements**
767773

@@ -789,7 +795,7 @@ The CloudFormation Stack creates following IAM roles:
789795
]
790796
```
791797

792-
- `ForwarderZipCopierRole`: The execution role for the ForwarderZipCopier Lambda function to download the Forwarder deployment ZIP file to a S3 bucket.
798+
- `ForwarderZipCopierRole`: The execution role for the ForwarderZipCopier Lambda function to download the Forwarder deployment ZIP file to a S3 bucket.
793799

794800
**IAM statements**:
795801

@@ -826,7 +832,7 @@ The value of the `service` tag is determined based on multiple inputs. These inp
826832

827833
Additional helpful documentation, links, and articles:
828834

829-
- [Send AWS Services Logs With The Datadog Lambda Function][2]
835+
- [Send AWS Services Logs With The Datadog Lambda Function][2]
830836

831837
[1]: https://github.com/DataDog/datadog-lambda-extension
832838
[2]: https://docs.datadoghq.com/logs/guide/send-aws-services-logs-with-the-datadog-lambda-function/

aws/logs_monitoring/template.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ Parameters:
7575
Type: String
7676
Default: ""
7777
Description: Add custom tags to forwarded logs, comma-delimited string, no trailing comma, e.g., env:prod,stack:classic
78+
DdSource:
79+
Type: String
80+
Default: ""
81+
Description: Override the source attribute for all logs forwarded by Lambda Forwarder. By default, the Forwarder automatically detects the source based on the log origin (e.g., lambda, s3, cloudwatch, rds). When set, all logs will use the specified source value instead, and a source_overridden:true tag will be added to the logs.
7882
DdEnrichS3Tags:
7983
Type: String
8084
Default: true
@@ -325,6 +329,8 @@ Conditions:
325329
SetS3SourceZip: !Equals [!Select [0, !Split [/, !Ref SourceZipUrl]], "s3:"]
326330
SetDdTags: !Not
327331
- !Equals [!Ref DdTags, ""]
332+
SetDdSource: !Not
333+
- !Equals [!Ref DdSource, ""]
328334
SetDdNoSsl: !Equals [!Ref DdNoSsl, true]
329335
SetDdUrl: !Not
330336
- !Equals [!Ref DdUrl, ""]
@@ -477,6 +483,10 @@ Resources:
477483
- SetDdTags
478484
- !Ref DdTags
479485
- !Ref AWS::NoValue
486+
DD_SOURCE: !If
487+
- SetDdSource
488+
- !Ref DdSource
489+
- !Ref AWS::NoValue
480490
DD_TAGS_CACHE_TTL_SECONDS: !Ref TagsCacheTTLSeconds
481491
DD_ENRICH_S3_TAGS: !Ref DdEnrichS3Tags
482492
DD_ENRICH_CLOUDWATCH_TAGS: !Ref DdEnrichCloudwatchTags

0 commit comments

Comments
 (0)