• Home
  • Deploy Dynatrace
  • Set up Dynatrace on cloud platforms
  • Amazon Web Services
  • Integrations
  • CloudWatch Logs

CloudWatch Logs

DDU consumption for Log Monitoring

DDU pricing applies to cloud Log Monitoring. See DDUs for Log Monitoring for details.

AWS log forwarding allows you to stream logs from Amazon CloudWatch into Dynatrace logs via an ActiveGate.

Resources needed

To enable AWS log forwarding, you need to deploy our special-purpose CloudFormation stack into your AWS account. The stack consists of a Kinesis Firehose instance and a Lambda function. These resources incur AWS costs according to standard AWS billing policy. The same applies to included self-monitoring resources (CloudWatch dashboards and metrics).

Supported services

Service nameCloudWatch log forwardingLog enrichmentEntity linking
AWS Lambda✔️✔️✔️
AWS App Runner✔️✔️✔️
AWS CloudTrail 1✔️✔️-
Amazon API Gateway✔️✔️-
Amazon SNS✔️✔️✔️
Amazon RDS✔️✔️✔️
All services that write to CloudWatch✔️✔️-
1

AWS CloudTrail log group name is chosen by user. For log enrichment, start the log group name with aws-cloudtrail-logs.

Limitations

AWS log forwarder supports maximum 1 GB of data processing per hour.

Prerequisites

Note: If you're using an earlier version of Dynatrace, see Alternative deployments for instructions.

Dynatrace

  • If you are using Log Monitoring v1, enable the latest version of Dynatrace Log Monitoring
  • Enable generic log ingestion
  • Create an API token with Ingest logs (API v2) permission

CLI

  • You can run the deployment from AWS CloudShell or from any machine with AWS CLI installed that supports Bash script execution.

Note: The deployment script uses the default AWS CLI profile configuration. The profile will determine the AWS account and region. To change the account or region:

  • Use a different profile - in this case, you need to update your configuration file.
  • Overwrite the default profile temporarily (this option is limited to your shell session) using environment variables.

Permission policy

You need the following permissions to run the deployment script:

Permissions policy for deployment
json
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "cloudformation:CreateChangeSet", "cloudformation:ExecuteChangeSet", "cloudformation:DescribeChangeSet", "cloudformation:DescribeStackEvents", "cloudformation:DescribeStacks", "cloudformation:GetTemplateSummary", "ec2:DescribeImages", "s3:CreateBucket", "s3:PutLifecycleConfiguration", "s3:PutBucketPublicAccessBlock", "iam:GetRole", "iam:CreateRole", "iam:AttachRolePolicy", "iam:PutRolePolicy", "iam:GetRolePolicy", "iam:PassRole", "lambda:CreateFunction", "lambda:UpdateFunctionCode", "lambda:GetFunction", "lambda:GetFunctionCodeSigningConfig", "cloudwatch:PutDashboard", "cloudwatch:GetDashboard", "firehose:DescribeDeliveryStream", "firehose:CreateDeliveryStream", "firehose:ListTagsForDeliveryStream", "logs:DeleteSubscriptionFilter", "logs:DescribeLogGroups", "logs:PutSubscriptionFilter", "ssm:GetParameters" ], "Resource": "*" } ] }

Deploy

  1. Set the following environment variables, making sure to replace the placeholders (<...>) with your own values.

    • For TARGET_URL, enter your environment URL: https://<your_environment_ID>.live.dynatrace.com. To learn how to determine your environment ID for the SaaS or Managed deployment, see environment ID.
    • For TARGET_API_TOKEN, enter your API token. For instructions, see Prerequisites.
    • optional For STACK_NAME, the default value is dynatrace-aws-logs. To provide another name for the CloudFormation stack where you want to deploy the resources, replace the default value with your own.
    sh
    TARGET_URL=<your_environment_URL> TARGET_API_TOKEN=<your_API_token> STACK_NAME=dynatrace-aws-logs
  2. Download the script and deploy the infrastructure.

    sh
    wget -O dynatrace-aws-log-forwarder.zip https://github.com/dynatrace-oss/dynatrace-aws-log-forwarder/releases/latest/download/dynatrace-aws-log-forwarder.zip \ && unzip -qo dynatrace-aws-log-forwarder.zip \ && ./dynatrace-aws-logs.sh deploy --target-url $TARGET_URL --target-api-token $TARGET_API_TOKEN --stack-name $STACK_NAME --require-valid-certificate true

Subscribe to log groups

After deploying the infrastructure, you need to subscribe to the log groups whose logs you want to forward to Dynatrace.

To subscribe to log groups, you have the options described below.

Note: Please use parameter [--stack-name <your_stack_name>] in case you changed the default value during deployment.

Subscribe by listing log group names

Usage recommendation: Use this option if the number of log groups you'd like to subscribe to is small.

To subscribe: Run the command below, making sure to replace <your_log_group_list> with a space-separated list of the log group names you want to subscribe to.

Example list: /aws/lambda/my-lambda /aws/apigateway/my-api

sh
./dynatrace-aws-logs.sh subscribe --log-groups <your_log_group_list>

Subscribe by reading log groups from file

Usage recommendation: Use this option if the number of log groups you'd like to subscribe to is large.

  1. Create a file and enter each log group name on a separate line.
  2. Save the file.
  3. Run the command below, making sure to replace <your_file_name> with the actual file name.
    sh
    ./dynatrace-aws-logs.sh subscribe --log-groups-from-file <your_file_name>
Log groups auto-discovery

To simplify file creation, you can use the auto-discovery command below to list the names of all log groups in your account. You can adjust the list manually before subscribing.
Note: Be sure to replace <your_log_groups_file> with the name of the file to which you want to redirect the output.

sh
./dynatrace-aws-logs.sh discover-log-groups > <your_log_groups_file>

Subscribe with a subscription filter pattern

Usage recommendation: By default, you subscribe to all the logs in the log group. Use this option if you want to restrict the logs you subscribe to. See Filter and Pattern Syntax for details on the pattern syntax.

Limitation: You can use only two subscription filters per log group, so the possibility of creating multiple filters with different patterns is limited. If you create a subscription filter that exceeds the limit, an AWS LimitExceededException occurs.

To subscribe: Run the command below, making sure to replace <your_log_group_list> and <your_filter_pattern> with your own values.

sh
./dynatrace-aws-logs.sh subscribe --log-groups <your_log_group_list> --filter-pattern <your_filter_pattern>
Subscription usage and options

For additional subscription options, see the commands below.
Note: Consult the Subscription table for the commands below when replacing placeholders (<...>) with your own values.

sh
dynatrace-aws-logs.sh subscribe {--log-groups <your_log_group_list> | --log-groups-from-file <your_file_name>} [--stack-name <your_stack_name>] [--filter-pattern <your_filter_pattern>] [--role-arn ROLE_ARN] [--firehose-arn FIREHOSE_ARN]

Subscription table

Command-line parameterEnvironment variableDescriptionDefault value
--log-groupsLOG_GROUPS_LISTA space-separated list of log group names you want to subscribe to. For example:
/aws/lambda/my-lambda /aws/apigateway/my-api.
--log-groups-from-fileLOG_GROUPS_FILEA file listing the log groups you want to subscribe to. The file should contain each log group name on a separate line.
--filter-patternFILTER_PATTERNIf set, it allows you to subscribe to a filtered stream of logs.You subscribe to all logs in the log group.
--stack-nameSTACK_NAMEThe name of the CloudFormation stack where you have deployed the resources.dynatrace-aws-logs
--firehose-arnFIREHOSE_ARNSpecify to which AWS Kinesis Data Firehose the logs should be streamed by providing its ARN (Amazon Resource Name).
Usage recommendation: Set this option if you have permission or performance issues with CloudFormation.
It will be extracted from the output of the CloudFormation stack used in the deploy step: either the $DEFAULT_STACK_NAME default value or the one specified with the --stack-name <your_stack_name> option.
--role-arnROLE_ARNThe ARN of an IAM role that grants CloudWatch Logs permission to deliver ingested log events to the destination stream.
Usage recommendation: Set this option if you have permission or performance issues with CloudFormation.
It will be extracted from the output of the CloudFormation stack used in the deploy step: either the $DEFAULT_STACK_NAME default value or the one specified with the --stack-name <your_stack_name> option.

Unsubscribe from log groups

If you don't want to forward logs to Dynatrace anymore, use one of the two options below to unsubscribe from log groups.

Unsubscribe by listing the log group names

Run the command below, making sure to replace <your_log_group_list> with a space-separated list of the log group names you want to unsubscribe from.

sh
./dynatrace-aws-logs.sh unsubscribe --log-groups <your_log_group_list>

Unsubscribe by reading log groups from a file

Run the command below, making sure to replace <your_file_name> with the file name you created to subscribe by reading log groups from file.

sh
./dynatrace-aws-logs.sh unsubscribe --log-groups-from-file <your_file_name>
Unsubscribe usage and options

For additional unsubscribe options, see the commands below.

Note: Consult the Unsubscribe table for the commands below when replacing the placeholders (<...>) with your own values.

sh
dynatrace-aws-logs.sh unsubscribe {--log-groups <your_log_group_list> | --log-groups-from-file <your_file_name>} [--stack-name <your_stack_name>]

Unsubscribe table

Command-line parameterEnvironment variableDescriptionDefault value
--log-groupsLOG_GROUPS_LISTA space-separated list of log group names you want to unsubscribe from. For example:
/aws/lambda/my-lambda /aws/apigateway/my-api.
--log-groups-from-fileLOG_GROUPS_FILEA file listing log groups you want to unsubscribe from, with each log group name on a separate line.
--stack-nameSTACK_NAMEThe name of the CloudFormation stack where you have deployed the resources.dynatrace-aws-logs

Update to new version

To replace your old stack with a new version of the AWS log forwarder stack, deploy the new stack using the same parameters that you used before (especially the stack name, if you changed it from the default value).

Alternative deployments

If you don't want to use direct ingest through the Cluster API, you have to use an existing ActiveGate (version 1.217+ required). The ActiveGate has to be available publicly. The stack will be created without a dedicated ActiveGate if you choose this option.

See below for instructions:

Deploy with existing ActiveGate

Prerequisites

Dynatrace version 1.217+

  • Dynatrace requirements
  • CLI requirements
  • You need the following permission policy:
Permissions policy for deployment with an existing ActiveGate
json
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "cloudformation:CreateChangeSet", "cloudformation:ExecuteChangeSet", "cloudformation:DescribeChangeSet", "cloudformation:DescribeStackEvents", "cloudformation:DescribeStacks", "cloudformation:GetTemplateSummary", "ec2:DescribeImages", "s3:CreateBucket", "s3:PutLifecycleConfiguration", "s3:PutBucketPublicAccessBlock", "iam:GetRole", "iam:CreateRole", "iam:AttachRolePolicy", "iam:PutRolePolicy", "iam:GetRolePolicy", "iam:PassRole", "lambda:CreateFunction", "lambda:UpdateFunctionCode", "lambda:GetFunction", "lambda:GetFunctionCodeSigningConfig", "cloudwatch:PutDashboard", "cloudwatch:GetDashboard", "firehose:DescribeDeliveryStream", "firehose:CreateDeliveryStream", "firehose:ListTagsForDeliveryStream", "logs:DeleteSubscriptionFilter", "logs:DescribeLogGroups", "logs:PutSubscriptionFilter", "ssm:GetParameters" ], "Resource": "*" } ] }
  1. Set the following environment variables, making sure to replace the placeholders (<...>) with your own values, as follows.

    • For TARGET_URL, enter the API URL of your ActiveGate endpoint: https://<your_activegate_IP_or_hostname>:9999/e/<your_environment_ID>. To learn how to determine your environment ID, see environment ID.
    • For TARGET_API_TOKEN, enter your API token. For instructions, see Prerequisites.

    Note: If you want Dynatrace to verify the SSL certificate of your Dynatrace environment URL, you can set REQUIRE_VALID_CERTIFICATE to true.

    sh
    TARGET_URL=<your_API_URL> TARGET_API_TOKEN=<your_API_token> REQUIRE_VALID_CERTIFICATE=false
  2. Download the script and deploy the infrastructure.

    sh
    wget -O dynatrace-aws-log-forwarder.zip https://github.com/dynatrace-oss/dynatrace-aws-log-forwarder/releases/latest/download/dynatrace-aws-log-forwarder.zip \ && unzip -qo dynatrace-aws-log-forwarder.zip \ && ./dynatrace-aws-logs.sh deploy --target-url $TARGET_URL --target-api-token $TARGET_API_TOKEN --require-valid-certificate $REQUIRE_VALID_CERTIFICATE
Deployment usage and options

For additional deployment options, see the command below.

sh
dynatrace-aws-logs.sh deploy --target-url <your_API_URL> --target-api-token <your_API_token> [--target-paas-token <your_PaaS_token>] [--require-valid-certificate {true|false}] [--stack-name <your_stack_name>] [--max-log-length <max_log_content_length>] [--tags <value> [<value>...] ]

For a complete list of parameters, see the deploy table below.

Deploy table

Command-line parameterEnvironment variableDescriptionDefault value
--target-urlTARGET_URLrequired The API URL to your Dynatrace SaaS environment logs ingest target.
If you choose to use an existing environment ActiveGate, set it to your ActiveGate endpoint: https://<your_activegate_IP_or_hostname>:9999/e/<your_environment_ID>
Note: To determine <your_environment_ID>, see environment ID.
--target-api-tokenTARGET_API_TOKENrequired Your API token. For instructions, see Prerequisites.
--require-valid-certificateREQUIRE_VALID_CERTIFICATEoptional If true, the log forwarder Lambda function verifies the SSL certificate of your Dynatrace environment URL.false
--stack-nameSTACK_NAMEoptional The name of the CloudFormation stack where you want to deploy the resources.dynatrace-aws-logs
--max-log-lengthMAX_LOG_CONTENT_LENGTHoptional Log content's max length. If log exceeds this length it will be truncated. For values over 8192 there's also a change in Dynatrace settings needed - you need to contact Dynatrace One for that.8192
--tagsTAGSoptional A list of tags to associate with the stack that is created or updated. Syntax: TagKey1=TagValue1 TagKey2=TagValue2 …

Troubleshooting

Deployment status

To verify deployment correctness

  1. In AWS Console, go to CloudFormation.
  2. Select your log forwarder stack from the list on the left by stack name (the default value is dynatrace-aws-logs).
  3. If you find any issues or discrepancies in any of the fields below, select Delete to delete the stack, and then repeat the deployment process.
    • In Stack info, check the stack status; it should be CREATE_COMPLETE.
    • In Parameters, check if the parameter values are consistent with the values you provided during deployment.
    • In Events, look for any events with a failed status.

Connectivity status

To verify AWS log forwarder connectivity and inspect operational logs

  1. In AWS Console, go to CloudWatch Dashboards.
  2. Find the self-monitoring dashboard for AWS log forwarding. It will have a name like DynatraceLogForwarder-SelfMonitoring-eu-north-1-dynatrace-aws-logs, where the middle part is the AWS region and the last part is the stack name you chose (the default is dynatrace-aws-logs).
  3. Inspect the dashboard for any obvious issues.
  4. Go to CloudFormation.
  5. Select your log forwarder stack from the list on the left by stack name (the default value is dynatrace-aws-logs).
  6. Select the Resources tab and then select the link next to Lambda.
  7. On the Lambda screen, select the Monitor tab and then select Logs.
  8. Select one of the listed log streams and look for exceptions in the logs.

Uninstall AWS log forwarding

To uninstall AWS log forwarding

  1. Unsubscribe all log groups. You can use the log groups auto-discovery method described in Subscribe by reading log groups from file and pass the auto-discovery output file to the unsubscribe command. See Unsubscribe from log groups for details.
  2. In AWS Console, go to your CloudFormation stack.
  3. Select the Resources tab and navigate to the DeliveryBucket S3 bucket.
  4. Remove all objects in the bucket.
  5. Go back to the CloudFormation stack and select Delete.
Related topics
  • Amazon Web Services Integrations

    Integrate Dynatrace on AWS