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

Enable step function tracing at forwarder level #831

Merged
merged 15 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 13 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
23 changes: 13 additions & 10 deletions aws/logs_monitoring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Starting version 3.107.0 a new feature is added to enable Lambda function to sto

### Upgrade an older version to +3.106.0

Starting version 3.106.0 Lambda function has been updated to add a prefix to cache filenames stored in the S3 bucket configured in `DD_S3_BUCKET_NAME`. This allows to use the same bucket to store cache files from several functions.
Starting version 3.106.0 Lambda function has been updated to add a prefix to cache filenames stored in the S3 bucket configured in `DD_S3_BUCKET_NAME`. This allows to use the same bucket to store cache files from several functions.
Additionally, starting this version, the forwarder will attach custom S3 bucket tags by default to all logs exported to S3. For example, if a service is configured to send logs to a destiantion S3 bucket, the forwarder will add the bucket's tags to the logs while pulling and forwarding the logs.

### Upgrade an older version to +3.99.0
Expand Down Expand Up @@ -388,15 +388,6 @@ SSL encrypted TCP connection, set this parameter to true.
`DdForwardLog`
: Set to false to disable log forwarding, while continuing to forward other observability data, such as metrics and traces from Lambda functions.

`DdFetchLambdaTags`
: Let the Forwarder fetch Lambda tags using GetResources API calls and apply them to logs, metrics, and traces. If set to true, permission `tag:GetResources` will be automatically added to the Lambda execution IAM role.

`DdFetchLogGroupTags`
: Let the forwarder fetch Log Group tags using ListTagsLogGroup and apply them to logs, metrics, and traces. If set to true, permission `logs:ListTagsLogGroup` will be automatically added to the Lambda execution IAM role.

`DdFetchStepFunctionsTags`
: Let the Forwarder fetch Step Functions tags using GetResources API calls and apply them to logs and traces (if Step Functions tracing is enabled). If set to true, permission `tag:GetResources` will be automatically added to the Lambda execution IAM role.

### Log scrubbing (optional)

`RedactIp`
Expand Down Expand Up @@ -433,6 +424,18 @@ To test different patterns against your logs, turn on [debug logs](#troubleshoot

### Advanced (optional)

`DdFetchLambdaTags`
: Let the Forwarder fetch Lambda tags using GetResources API calls and apply them to logs, metrics, and traces. If set to true, permission `tag:GetResources` will be automatically added to the Lambda execution IAM role.

`DdFetchLogGroupTags`
: Let the forwarder fetch Log Group tags using ListTagsLogGroup and apply them to logs, metrics, and traces. If set to true, permission `logs:ListTagsLogGroup` will be automatically added to the Lambda execution IAM role.

`DdFetchStepFunctionsTags`
: Let the Forwarder fetch Step Functions tags using GetResources API calls and apply them to logs and traces (if Step Functions tracing is enabled). If set to true, permission `tag:GetResources` will be automatically added to the Lambda execution IAM role.

`DdStepFunctionTraceEnabled`
: Set to true to enable tracing for all Step Functions.

`SourceZipUrl`
: Do not change unless you know what you are doing. Override the default location of the function source code.

Expand Down
7 changes: 7 additions & 0 deletions aws/logs_monitoring/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ def get_env_var(envvar, default, boolean=False):
#
DD_FORWARD_LOG = get_env_var("DD_FORWARD_LOG", "true", boolean=True)

## @param DD_STEP_FUNCTION_TRACE_ENABLED - boolean - optional - default: true
## Set this variable to `True` to enable log to trace conversion for Step Functions.
#
DD_STEP_FUNCTION_TRACE_ENABLED = get_env_var(
"DD_STEP_FUNCTION_TRACE_ENABLED", default="false", boolean=True
)

## @param DD_USE_TCP - boolean - optional -default: false
## Change this value to `true` to send your logs and metrics using the TCP network client
## By default, it uses the HTTP client.
Expand Down
7 changes: 7 additions & 0 deletions aws/logs_monitoring/steps/handlers/awslogs_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
DD_SOURCE,
DD_HOST,
DD_CUSTOM_TAGS,
DD_STEP_FUNCTION_TRACE_ENABLED,
)

RDS_REGEX = re.compile("/aws/rds/(instance|cluster)/(?P<host>[^/]+)/(?P<name>[^/]+)")
Expand Down Expand Up @@ -184,6 +185,12 @@ def handle_step_function_source(self):
+ ",".join(formatted_stepfunctions_tags)
)

if DD_STEP_FUNCTION_TRACE_ENABLED:
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

self.metadata[DD_CUSTOM_TAGS] = ",".join(
[self.metadata.get(DD_CUSTOM_TAGS, [])]
+ ["dd_step_function_trace_enabled:true"]
)

def handle_verified_access_source(self):
try:
message = json.loads(self.aws_attributes.get_log_events()[0].get("message"))
Expand Down
17 changes: 17 additions & 0 deletions aws/logs_monitoring/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ Parameters:
- true
- false
Description: Set to false to disable log forwarding, while continuing to forward other observability data, such as metrics and traces from Lambda functions.
DdStepFunctionTraceEnabled:
Type: String
Default: false
AllowedValues:
- true
- false
Description: Set to true to enable tracing for all Step Functions.
DdUseCompression:
Type: String
Default: true
Expand Down Expand Up @@ -391,6 +398,10 @@ Conditions:
Fn::Equals:
- Ref: DdForwardLog
- false
SetDdStepFunctionTraceEnabled:
Fn::Equals:
- Ref: DdStepFunctionTraceEnabled
- true
avedmala marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

What will be the default value in CloudFormation console (shown as below) when customer install a new DD forwarder?
It should be default false, but customers can set it to be true if they want.

Screenshot 2024-07-31 at 11 27 05 AM

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should be the default behavior, here is the flow

  • Template has the default for the DdStepFunctionTraceEnabled to be false
  • SetDdStepFunctionTraceEnabled condition will then be false because DdStepFunctionTraceEnabled != true
  • DD_STEP_FUNCTION_TRACE_ENABLED will be AWS::NoValue, which means the env var won't be set

SetDdUseCompression:
Fn::Equals:
- Ref: DdUseCompression
Expand Down Expand Up @@ -615,6 +626,11 @@ Resources:
- SetDdForwardLog
- Ref: DdForwardLog
- Ref: AWS::NoValue
DD_STEP_FUNCTION_TRACE_ENABLED:
Fn::If:
- SetDdStepFunctionTraceEnabled
- Ref: DdStepFunctionTraceEnabled
- Ref: AWS::NoValue
DD_USE_COMPRESSION:
Fn::If:
- SetDdUseCompression
Expand Down Expand Up @@ -1148,6 +1164,7 @@ Metadata:
- DdFetchLambdaTags
- DdFetchLogGroupTags
- DdFetchStepFunctionsTags
- DdStepFunctionTraceEnabled
- TagsCacheTTLSeconds
- SourceZipUrl
- InstallAsLayer
Expand Down
Loading