# Set up Datadog

This guide helps you set up Datadog integration in your AWS accounts to enable observability for your applications and infrastructure. Once configured, you'll collect logs, metrics, and traces from applications and AWS services in your accounts.

## Before you begin

Make sure that TEK or Team Utviklerflyt has created a team for you in the [`dig-datadog-iac`](https://github.com/oslokommune/dig-datadog-iac/tree/main/teams) repository.

Need help? Contact Team Utviklerflyt in [the `#utviklerflyt-support` Slack channel](https://oslokommune.slack.com/archives/CV9EGL9UG).

You might need to update your privacy assessment for medium and low risk, PLM (_personvernvurdering på lav og middels risiko_). Check with your lawyer and information security people wether the new data flows created for Datadog require changes in your team's PLM.

## Step 1: Install the `datadog-common` template

The `datadog-common` template sets up the necessary shared resources for Datadog integration in each AWS account.

1. Navigate to the root of an environment in your infrastructure repository, such as `stacks/dev`.
1. Add the `datadog-common` package to your environment:

   ```sh
   ok pkg add datadog-common
   ```

1. Open `package-config.yml` and set a name for the stack:

   ```diff title="stacks/dev/datadog-common/package-config.yml"
   +StackName: datadog-common
   ```

1. Install the template:

   ```sh title="stacks/dev/datadog-common/"
   ok pkg install
   ```

1. Review the generated Terraform configuration and apply the changes:

   ```sh title="stacks/dev/datadog-common/"
   terraform plan
   terraform apply
   ```

## Step 2: Verify the setup

Verify that the Datadog integration is working:

1. Log in to Datadog using your Microsoft email: [https://app.datadoghq.eu/account/login/by_email](https://app.datadoghq.eu/account/login/by_email).
1. Select the `Digitaliseringsetaten` organization if prompted.
1. Navigate to [Integrations > Amazon Web Services](https://app.datadoghq.eu/integrations?integrationId=amazon-web-services).
1. Verify that your AWS account is listed without errors.

## Next steps

With the basic Datadog integration in place, you can now:

- [Instrument Java applications](../observability/instrument-a-java-container-for-datadog.md) to collect application metrics, logs, and traces.
- [Forward CloudWatch and ALB logs](../observability/forward-logs-from-cloudwatch-and-s3-to-datadog.md) to Datadog for centralized log management.

If you have questions about or issues with any of this, please reach out in the [`#utviklerflyt-support`](https://oslokommune.slack.com/archives/CV9EGL9UG) Slack channel for help!

## End of setup guide

This marks the end of the [Initial setup of your AWS environment](index.md) guide. To delete parts of what you created, see the [guide for deleting environments](../terraform/delete/delete-environment.md). You can also [delete a remote state bucket](../terraform/delete/delete-remote-state-bucket.md).

## Next guide

A next step could be to [create a new application](../application/container/create-new-application/index.md).
