This product is not supported for your selected Datadog site. ().

You can enable App and API Protection for Java services with the following setup options:

  1. If your Java service already has APM tracing set up and running, then skip to service configuration.
  2. If your Java service doesn't have APM tracing set up, you can easily enable App and API Protection with Datadog's Automatic Installation.
  3. Otherwise, continue reading the manual setup instructions below.

Overview

App and API Protection leverages the Datadog Java library to monitor and secure your Java service. The library integrates seamlessly with your existing application without requiring code changes.

For detailed compatibility information, including supported Java versions, frameworks, and deployment environments, see Java Compatibility Requirements.

This guide explains how to set up App and API Protection (AAP) for Java applications. The setup involves:

  1. Installing the Datadog Agent.
  2. Enabling App and API Protection monitoring.
  3. Running your Java application with the Datadog Agent.
  4. Verifying the setup.

前提条件

  • Linux オペレーティングシステム
  • Java アプリケーション
  • root 権限または sudo 権限
  • Systemd (サービス管理用)
  • Datadog API キー
  • Datadog Java SDK (バージョン要件はこちらを参照してください)

1. Datadog Agent をインストールする

Linux ホストのセットアップ手順に従って Datadog Agent をインストールします。

2. App and API Protection モニタリングを有効にする

Automatically enabling App and API Protection through Remote Configuration

You can enable services with remote configuration on your services dashboard. Check the box for the service you want to enable App and API Protection for under Activate on your APM services.

App and API Protection モニタリングを手動で有効にする

Datadog Java ライブラリの最新版をダウンロードします。

wget -O dd-java-agent.jar 'https://dtdg.co/latest-java-tracer'

システムプロパティを使用して、Datadog Agent と App and API Protection を有効にした状態で Java アプリケーションを起動します。

java -javaagent:/path/to/dd-java-agent.jar -Ddd.appsec.enabled=true -Ddd.service=<MY_SERVICE> -Ddd.env=<MY_ENV> -jar path/to/app.jar

必要な環境変数を設定し、Java アプリケーションを起動します。

export DD_APPSEC_ENABLED=true
export DD_SERVICE=<YOUR_SERVICE_NAME>
export DD_ENV=<YOUR_ENVIRONMENT>

java -javaagent:/path/to/dd-java-agent.jar -jar path/to/app.jar

App and API Protection を有効にしたまま APM トレースを無効にするには、APM トレース変数を [false] に設定する必要があります。

システムプロパティを使用して、Datadog Agent と App and API Protection を有効にした状態で Java アプリケーションを起動します。

java -javaagent:/path/to/dd-java-agent.jar -Ddd.appsec.enabled=true -Ddd.apm.tracing.enabled=false -Ddd.service=<MY_SERVICE> -Ddd.env=<MY_ENV> -jar path/to/app.jar

必要な環境変数を設定し、Java アプリケーションを起動します。

export DD_APPSEC_ENABLED=true
export DD_APM_TRACING_ENABLED=false
export DD_SERVICE=<YOUR_SERVICE_NAME>
export DD_ENV=<YOUR_ENVIRONMENT>

java -javaagent:/path/to/dd-java-agent.jar -jar path/to/app.jar

3. アプリケーションを実行する

上記の設定で Java アプリケーションを起動します。

4. Verify setup

To verify that App and API Protection is working correctly:

  1. Send some traffic to your application
  2. Check the Application Signals Explorer in Datadog
  3. Look for security signals and vulnerabilities

トラブルシューティング

Java アプリケーションの App and API Protection の設定中に問題が発生した場合は、「Java App and API Protection トラブルシューティングガイド」を参照してください。

参考資料