メインコンテンツへスキップ

Attribute Sensor for AWS Fargate(Java Edition)

このドキュメントでは、Java アプリケーション向けに AWS Fargate のタスク定義内で Attribute Sensor をインストールするために必要な情報および設定について説明します。

センサーは、アプリケーションのコンテナ内で埋め込みプロセスとして実行されます。Java アプリケーションの場合、TLS で暗号化されたトラフィックをアトリビューション可能にするために、JVM に接続される Attribute Java エージェントと組み合わせて使用します。Java にエージェントが必要となる背景については、Attribute Java Instrumentation Guide を参照してください。

ステップ 1: containerDefinitions を更新する

タスク定義内で、該当する containerDefinition を次のように変更します。

environment セクションに環境変数を追加します:

"environment": [
{
"name": "CONFIG_ZPROBE_BEARER_TOKEN",
"value": "<token>"
},
{
"name": "CONFIG_ZPROBE_OTEL_ADDR",
"value": "otel-endpoint.app.attrb.io:443"
},
{
"name": "JAVA_TOOL_OPTIONS",
"value": "-javaagent:/opt/zprobe/jagent.jar"
}
]

dependsOn セクションに依存関係を追加します:

"dependsOn": [
{
"containerName": "attribute-sensor",
"condition": "COMPLETE"
}
]

mountPoints セクションにマウントを追加します:

"mountPoints": [
{
"sourceVolume": "attribute-shared",
"containerPath": "/opt/zprobe"
}
]

コンテナの entryPointcommand を変更します:

"entryPoint": [
"/opt/zprobe/launch/ecs-fargate"
],
"command": [
"<start_command>"
]
注意

<start_command> を、アプリケーションの起動コマンドに置き換えてください。引数ごとに 1 要素となるよう配列に分割します(例:["java", "-jar", "/app/app.jar"])。

containerDefinitions に別のコンテナ定義(サイドカー)を追加します:

{
"name": "attribute-sensor",
"image": "quay.io/attribute/sensor:<tag>",
"essential": false,
"entryPoint": [
"/bin/sh",
"-c"
],
"command": [
"mkdir -p /shared && cp -r /app/* /shared/"
],
"mountPoints": [
{
"sourceVolume": "attribute-shared",
"containerPath": "/shared"
}
]
}

ステップ 2: volumes を更新する

共有ボリュームを volumes セクションに追加します:

"volumes": [
{
"name": "attribute-shared"
}
]

注意事項

  • これらの変更を行う際は、タスク定義の新しいリビジョンを作成し、その後 ECS サービスを更新することを推奨します。

  • パフォーマンスと可用性:

    • センサーはコンテナ内で埋め込みプロセスとして実行されます。パフォーマンスへの影響を最小限に抑えるため、CPU アロケーションを 1 vCPU 追加することを推奨します。
    • センサーが失敗しても、アプリケーションの機能には影響しないはずです。
    • インストール用の Terraform オートメーションがサポートされています。

付録 A: 完全なタスク定義の例

{
"family": "<family>",
"containerDefinitions": [
{
"name": "<image-name>",
"image": "<image>",
"environment": [
{
"name": "CONFIG_ZPROBE_BEARER_TOKEN",
"value": "<token>"
},
{
"name": "CONFIG_ZPROBE_OTEL_ADDR",
"value": "otel-endpoint.app.attrb.io:443"
},
{
"name": "JAVA_TOOL_OPTIONS",
"value": "-javaagent:/opt/zprobe/jagent.jar"
}
],
"workingDirectory": "/app",
"cpu": 0,
"essential": true,
"dependsOn": [
{
"containerName": "attribute-sensor",
"condition": "COMPLETE"
}
],
"entryPoint": [
"/opt/zprobe/launch/ecs-fargate"
],
"command": [
"java",
"-jar",
"/app/app.jar"
],
"mountPoints": [
{
"sourceVolume": "attribute-shared",
"containerPath": "/opt/zprobe"
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/go-zprobe-fargate",
"mode": "non-blocking",
"awslogs-create-group": "true",
"max-buffer-size": "25m",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
}
},
{
"name": "attribute-sensor",
"image": "quay.io/attribute/sensor:<tag>",
"essential": false,
"entryPoint": [
"/bin/sh",
"-c"
],
"command": [
"mkdir -p /shared && cp -r /app/* /shared/"
],
"mountPoints": [
{
"sourceVolume": "attribute-shared",
"containerPath": "/shared"
}
]
}
],
"volumes": [
{
"name": "attribute-shared"
}
],
"executionRoleArn": "<role>",
"networkMode": "awsvpc",
"placementConstraints": [],
"requiresCompatibilities": ["FARGATE"],
"cpu": "4096",
"memory": "8192",
"runtimePlatform": {
"cpuArchitecture": "X86_64",
"operatingSystemFamily": "LINUX"
},
"enableFaultInjection": false
}

商標:AWS は Amazon.com, Inc. またはその関連会社の商標です。その他すべての商標は、それぞれの所有者に帰属します。