# Run yc-360 Script in Sidecar Container on AWS Fargate

You can deploy the yc-360 script alongside your Java application in the same Fargate Task using a sidecar container. This approach provides clear separation of concerns and simplifies observability integration.

Follow the steps below to run the yc-360 script as a sidecar in an AWS Fargate ECS Task.

# 1. Create Secrets for yc-360 Script Configuration

The yc-360 script requires a configuration file named yc-config.yaml. In ECS, you can store it in AWS Secrets Manager or SSM Parameter Store and reference it in the task definition.

The script supports multiple execution modes tailored for various monitoring needs. Select your preferred mode below to see how to configure the script.

Not sure what these modes mean? Learn more about Execution Modes

    # 2. Deploy BuggyApp and yc-360 Script on ECS Fargate

    In this step, you’ll deploy both the Java application (BuggyApp) and the yc-360 script as containers in the same ECS task.

    # Overview

    This deployment includes:

    # Key Points

    • Task Definition: Both containers (BuggyApp and yc-360) run under the same Fargate Task.
    • Volumes: Shared /tmp directory between containers for temporary data.
    • Ports:
      • yc-360 Script listens on 8085.
      • BuggyApp listens on 9010.

    # ECS Task Definition (Example)



     




















































     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     























    {
        "family": "task-buggyapp-yc360",
        "pidMode": "task",
        "containerDefinitions": [
            {
                "command": [
                    "-showversion",
                    "-verbose:gc",
                    "-Xmx256m",
                    "-Xlog:gc:jvm_gc.%p.log",
                    "-DlogDir=.",
                    "-DuploadDir=.",
                    "-Dapp=BuggyApp",
                    "-jar",
                    "buggyApp.jar",
                    "sample"
                ],
                "cpu": 256,
                "environment": [],
                "environmentFiles": [],
                "essential": true,
                "image": "ycrash/buggyapp:latest",
                "user": "0",
                "logConfiguration": {
                    "logDriver": "awslogs",
                    "options": 
                    {
                        "awslogs-create-group": "true",
                        "awslogs-group": "/ecs/yc-apps",
                        "awslogs-region": "us-west-1",
                        "awslogs-stream-prefix": "ba"
                    }
                },
                "memory": 1024,
                "memoryReservation": 1024,
                "mountPoints": [
                    {
                        "containerPath": "/tmp",
                        "readOnly": false,
                        "sourceVolume": "shared-tmp"
                    }
                ],
                "name": "buggyapp",
                "portMappings": [
                    {
                        "appProtocol": "http",
                        "containerPort": 8080,
                        "name": "buggyapp-8080-tcp",
                        "protocol": "tcp"
                    }
                ],
                "systemControls": [],
                "ulimits": [],
                "volumesFrom": []
            },
            {
                "command": [
                    "-s",
                    "{YC_SERVER_URL}}",
                    "-j",
                    "/opt/java/openjdk",
                    "-k",
                    "{API_KEY}",
                    "-m3",
                    "-processTokens",
                    "{JAVA_PROCESS_IDENTIFIER}${APP_NAME}}",
                    "-m3Frequency", 
                    "3m",
                    "-kubernetes",
                    "-address",
                    "0.0.0.0",
                    "-port",
                    "8085",
                    "-tags",
                    "{TAG_NAME}"
                ],
                "cpu": 256,
                "entryPoint": [
                    "./yc"
                ],
                "environment": [],
                "environmentFiles": [],
                "essential": false,
                "image": "ycrash/yc-agent:latest",
                "user": "0",
                "logConfiguration": {
                    "logDriver": "awslogs",
                    "options": 
                    {
                        "awslogs-create-group": "true",
                        "awslogs-group": "/ecs/yc-apps",
                        "awslogs-region": "us-west-1",
                        "awslogs-stream-prefix": "yc"
                    }
                },
                "memory": 1024,
                "memoryReservation": 1024,
                "mountPoints": [
                    {
                        "containerPath": "/tmp",
                        "readOnly": false,
                        "sourceVolume": "shared-tmp"
                    }
                ],
                "name": "yc-360-script",
                "portMappings": [
                    {
                        "appProtocol": "http",
                        "containerPort": 8085,
                        "name": "yc360-8085-tcp",
                        "protocol": "tcp"
                    }
                ],
                "systemControls": [],
                "volumesFrom": []
            }
        ],
        "taskRoleArn": "arn:aws:iam::{AWS_ACCOUNT_ID}:role/ecsTaskExecutionRole",
        "executionRoleArn": "arn:aws:iam::{AWS_ACCOUNT_ID}:role/ecsTaskExecutionRole",
        "networkMode": "awsvpc",
        "volumes": [
            {
                "host": {},
                "name": "shared-tmp"
            }
        ],
        "placementConstraints": [],
        "requiresCompatibilities": [
            "FARGATE"
        ],
        "cpu": "512",
        "memory": "2048",
        "runtimePlatform": {
            "cpuArchitecture": "ARM64",
            "operatingSystemFamily": "LINUX"
        },
        "enableFaultInjection": false
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138

    # Deploy the ECS Task

    1. Register the task definition:
    aws ecs register-task-definition --cli-input-json file://task-buggyapp-yc360.json
    
    1
    1. Run the task in a Fargate cluster:
    aws ecs run-task \
      --cluster yc-fargate-cluster \
      --launch-type FARGATE \
      --network-configuration "awsvpcConfiguration={subnets=[subnet-12345678],assignPublicIp=ENABLED}" \
      --task-definition task-buggyapp-yc360
    
    1
    2
    3
    4
    5

    Notes

    • Ensure the ECS Task Execution Role has permissions to pull images and write logs to CloudWatch.
    • The shared /tmp volume allows the yc-360 script to interact with the BuggyApp container.
    • Adjust CPU and memory values based on your application’s resource requirements.

    # 3. Execute yc-360 Script

    The script supports multiple execution modes tailored for various monitoring needs. Select your preferred mode below to see how to configure the script.

    Not sure what these modes mean? Learn more about Execution Modes

      IMPORTANT NOTE

      • To detect memory-related issues, GC logging must be enabled for your application. You can enable GC logging by using the JVM arguments listed here.

      • The yc-360 script doesn't capture heap dump by default. Pass -hd argument to capture heap dump. For more information, please visit How to Capture Heap Dump?