[小ネタ] AWS App RunnerのECSタスクメタデータを調べてみた

[小ネタ] AWS App RunnerのECSタスクメタデータを調べてみた

Clock Icon2022.02.18

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

しばたです。

App Runnerの学習がてらコンテナからどこまで情報を取れるのか試してみました。

今回Distrolessgcr.io/distroless/python3イメージに簡単なFlask + gunicornなアプリケーションを作りコンテナ内部の情報を取得しています。
アプリケーションのソースコードについてはもう少し整理してから公開しようと思います。

コンテナ環境変数の取得

まずはコンテナ内部の環境変数を取得してみました。
コードとしてはざっくり以下の単純な形で取得しています。

# コード例
import os

def get_environment_variables():
    return os.environ

結果からイメージ依存の環境変数を除外すると以下の様になり、ECS関連の環境変数が取得できました。

名前 備考
PORT 5000 App Runnerにより付与される
AWS_REGION ap-northeast-1
AWS_DEFAULT_REGION ap-northeast-1
AWS_EXECUTION_ENV AWS_ECS_FARGATE
ECS_CONTAINER_METADATA_URI http://169.254.170.2/v3/98715bab14334bf19670cec71e5fca81-193386898 ランダム値はコンテナID
ECS_CONTAINER_METADATA_URI_V4 http://169.254.170.2/v4/98715bab14334bf19670cec71e5fca81-193386898 ランダム値はコンテナID
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI /v2/credentials/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 念のためマスク

AWS_EXECUTION_ENV環境変数がAWS_ECS_FARGATEであったりECS_CONTAINER_METADATA_URI環境変数が存在するなど、実装としてはごく普通のECS + Fargate環境となっています。
こちらはいくつかのドキュメントやブログ記事で公開されている通りですね。
(個人的にはもう少し情報が隠匿されているかな?とは思ってましたが...)

ちなみにPORT環境変数はApp Runner独自のもので公開ポートが設定されます。

ECSタスクメタデータ

ECS_CONTAINER_METADATA_URIおよびECS_CONTAINER_METADATA_URI_V4環境変数が取得できるのでECSタスクメタデータも取得してみました。

コードとしては以下の様な関数を使っていますが、まあ、ざっくりcurl $ECS_CONTAINER_METADATA_URI_V4した結果だと思っていただく方が手っ取り早いでしょう。

# コード例
import os
import requests
import json

def get_ecs_task_metadata_base_url():
    try:
        return os.environ["ECS_CONTAINER_METADATA_URI_V4"]
    except:
        return ""

def get_ecs_task_metadata(base_url, path):
    try:
        url = base_url
        if path != "":
            url = "{0}/{1}".format(base_url, path)
        response = requests.get(url)
        if response.status_code == 200:
            return json.dumps(json.loads(response.text), indent=2)
        else:
            return "{0} : {1}".format(response.status_code, response.text)
    except Exception as e:
        return e

1. ECS_CONTAINER_METADATA_URI_V4

最初にECS_CONTAINER_METADATA_URI_V4にアクセスしてタスク情報を取得した結果です。

結果のうち私のAWSアカウントIDはxxxxxxxxxxxxで、他にAWS管理と思われるアカウントIDはyyyyyyyyyyyyおよびzzzzzzzzzzzzでマスクしています。

{
  "DockerId": "98715bab14334bf19670cec71e5fca81-193386898",
  "Name": "instance",
  "DockerName": "instance",
  "Image": "zzzzzzzzzzz.dkr.ecr.ap-northeast-1.amazonaws.com/image-repo-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@sha256:4bf68a7bba7722d0e133c4754a687b09fb8c73367b717f703ab9601a8a7a14ec",
  "ImageID": "sha256:4bf68a7bba7722d0e133c4754a687b09fb8c73367b717f703ab9601a8a7a14ec",
  "Labels": {
    "com.amazonaws.ecs.cluster": "arn:aws:ecs:ap-northeast-1:yyyyyyyyyyyy:cluster/bullet-srv-xxxxxxxxxxxx",
    "com.amazonaws.ecs.container-name": "instance",
    "com.amazonaws.ecs.task-arn": "arn:aws:ecs:ap-northeast-1:yyyyyyyyyyyy:task/bullet-srv-xxxxxxxxxxxx/98715bab14334bf19670cec71e5fca81",
    "com.amazonaws.ecs.task-definition-family": "bullet-td-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-b6e0d2f036ee4e209ec66ff038646c96",
    "com.amazonaws.ecs.task-definition-version": "1"
  },
  "DesiredStatus": "RUNNING",
  "KnownStatus": "RUNNING",
  "Limits": {
    "CPU": 960
  },
  "CreatedAt": "2022-02-18T05:28:39.209549882Z",
  "StartedAt": "2022-02-18T05:28:39.209549882Z",
  "Type": "NORMAL",
  "Networks": [
    {
      "NetworkMode": "awsvpc",
      "IPv4Addresses": [
        "10.0.53.191"
      ],
      "AttachmentIndex": 0,
      "MACAddress": "06:e1:06:44:86:e5",
      "IPv4SubnetCIDRBlock": "10.0.32.0/19",
      "DomainNameServers": [
        "10.0.0.2"
      ],
      "DomainNameSearchList": [
        "ap-northeast-1.compute.internal"
      ],
      "PrivateDNSName": "ip-10-0-53-191.ap-northeast-1.compute.internal",
      "SubnetGatewayIpv4Address": "10.0.32.1/19"
    },
    {
      "NetworkMode": "awsvpc",
      "IPv4Addresses": [
        "169.254.175.252"
      ],
      "AttachmentIndex": 1,
      "MACAddress": "82:94:9e:88:82:3a",
      "IPv4SubnetCIDRBlock": "169.254.175.252/31",
      "DomainNameServers": [
        "10.0.0.2"
      ],
      "DomainNameSearchList": [
        "ap-northeast-1.compute.internal"
      ],
      "SubnetGatewayIpv4Address": "169.254.175.253/31"
    },
    {
      "NetworkMode": "awsvpc",
      "AttachmentIndex": 2,
      "DomainNameServers": [
        "10.0.0.2"
      ],
      "DomainNameSearchList": [
        "ap-northeast-1.compute.internal"
      ]
    }
  ],
  "ContainerARN": "arn:aws:ecs:ap-northeast-1:yyyyyyyyyyyy:container/bullet-srv-xxxxxxxxxxxx/98715bab14334bf19670cec71e5fca81/60822564-5723-4d92-af0b-119f1c0f83ff",
  "LogOptions": {
    "awslogs-create-group": "true",
    "awslogs-group": "/customer/xxxxxxxxxxxx/my-first-app-runner/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/application",
    "awslogs-region": "ap-northeast-1",
    "awslogs-stream": "application/instance/98715bab14334bf19670cec71e5fca81"
  },
  "LogDriver": "awslogs"
}

印象としては結構丸見えだなぁ、という感じです。

クラスタ管理のアカウント(yyyyyyyyyyyy)とECRのアカウント(zzzzzzzzzzzz)は別になっている様です。

2. ECS_CONTAINER_METADATA_URI_V4/task

次にECS_CONTAINER_METADATA_URI_V4/taskにアクセスしてコンテナレベルの情報を取得した結果です。

{
  "Cluster": "arn:aws:ecs:ap-northeast-1:yyyyyyyyyyyy:cluster/bullet-srv-xxxxxxxxxxxx",
  "TaskARN": "arn:aws:ecs:ap-northeast-1:yyyyyyyyyyyy:task/bullet-srv-xxxxxxxxxxxx/98715bab14334bf19670cec71e5fca81",
  "Family": "bullet-td-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-b6e0d2f036ee4e209ec66ff038646c96",
  "Revision": "1",
  "DesiredStatus": "RUNNING",
  "KnownStatus": "RUNNING",
  "Limits": {
    "CPU": 1,
    "Memory": 2048
  },
  "PullStartedAt": "2022-02-18T05:28:30.315279074Z",
  "PullStoppedAt": "2022-02-18T05:28:35.479519683Z",
  "AvailabilityZone": "ap-northeast-1a",
  "Containers": [
    {
      "DockerId": "98715bab14334bf19670cec71e5fca81-193386898",
      "Name": "instance",
      "DockerName": "instance",
      "Image": "zzzzzzzzzzz.dkr.ecr.ap-northeast-1.amazonaws.com/image-repo-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa@sha256:4bf68a7bba7722d0e133c4754a687b09fb8c73367b717f703ab9601a8a7a14ec",
      "ImageID": "sha256:4bf68a7bba7722d0e133c4754a687b09fb8c73367b717f703ab9601a8a7a14ec",
      "Labels": {
        "com.amazonaws.ecs.cluster": "arn:aws:ecs:ap-northeast-1:yyyyyyyyyyyy:cluster/bullet-srv-xxxxxxxxxxxx",
        "com.amazonaws.ecs.container-name": "instance",
        "com.amazonaws.ecs.task-arn": "arn:aws:ecs:ap-northeast-1:yyyyyyyyyyyy:task/bullet-srv-xxxxxxxxxxxx/98715bab14334bf19670cec71e5fca81",
        "com.amazonaws.ecs.task-definition-family": "bullet-td-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-b6e0d2f036ee4e209ec66ff038646c96",
        "com.amazonaws.ecs.task-definition-version": "1"
      },
      "DesiredStatus": "RUNNING",
      "KnownStatus": "RUNNING",
      "Limits": {
        "CPU": 960
      },
      "CreatedAt": "2022-02-18T05:28:39.209549882Z",
      "StartedAt": "2022-02-18T05:28:39.209549882Z",
      "Type": "NORMAL",
      "Networks": [
        {
          "NetworkMode": "awsvpc",
          "IPv4Addresses": [
            "10.0.53.191"
          ],
          "AttachmentIndex": 0,
          "MACAddress": "06:e1:06:44:86:e5",
          "IPv4SubnetCIDRBlock": "10.0.32.0/19",
          "DomainNameServers": [
            "10.0.0.2"
          ],
          "DomainNameSearchList": [
            "ap-northeast-1.compute.internal"
          ],
          "PrivateDNSName": "ip-10-0-53-191.ap-northeast-1.compute.internal",
          "SubnetGatewayIpv4Address": "10.0.32.1/19"
        },
        {
          "NetworkMode": "awsvpc",
          "IPv4Addresses": [
            "169.254.175.252"
          ],
          "AttachmentIndex": 1,
          "MACAddress": "82:94:9e:88:82:3a",
          "IPv4SubnetCIDRBlock": "169.254.175.252/31",
          "DomainNameServers": [
            "10.0.0.2"
          ],
          "DomainNameSearchList": [
            "ap-northeast-1.compute.internal"
          ],
          "SubnetGatewayIpv4Address": "169.254.175.253/31"
        },
        {
          "NetworkMode": "awsvpc",
          "AttachmentIndex": 2,
          "DomainNameServers": [
            "10.0.0.2"
          ],
          "DomainNameSearchList": [
            "ap-northeast-1.compute.internal"
          ]
        }
      ],
      "ContainerARN": "arn:aws:ecs:ap-northeast-1:yyyyyyyyyyyy:container/bullet-srv-xxxxxxxxxxxx/98715bab14334bf19670cec71e5fca81/60822564-5723-4d92-af0b-119f1c0f83ff",
      "LogOptions": {
        "awslogs-create-group": "true",
        "awslogs-group": "/customer/xxxxxxxxxxxx/my-first-app-runner/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/application",
        "awslogs-region": "ap-northeast-1",
        "awslogs-stream": "application/instance/98715bab14334bf19670cec71e5fca81"
      },
      "LogDriver": "awslogs"
    },
    {
      "DockerId": "98715bab14334bf19670cec71e5fca81-329321356",
      "Name": "aws-fargate-request-proxy",
      "DockerName": "aws-fargate-request-proxy",
      "Image": "yyyyyyyyyyyy.dkr.ecr.ap-northeast-1.amazonaws.com/aws-fargate-request-proxy:cell3",
      "ImageID": "sha256:6f756ebb168f07dca3b528408c30d25c711d4147e80e42c8874e1c0259ec5ad9",
      "Labels": {
        "com.amazonaws.ecs.cluster": "arn:aws:ecs:ap-northeast-1:yyyyyyyyyyyy:cluster/bullet-srv-xxxxxxxxxxxx",
        "com.amazonaws.ecs.container-name": "aws-fargate-request-proxy",
        "com.amazonaws.ecs.task-arn": "arn:aws:ecs:ap-northeast-1:yyyyyyyyyyyy:task/bullet-srv-xxxxxxxxxxxx/98715bab14334bf19670cec71e5fca81",
        "com.amazonaws.ecs.task-definition-family": "bullet-td-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-b6e0d2f036ee4e209ec66ff038646c96",
        "com.amazonaws.ecs.task-definition-version": "1"
      },
      "DesiredStatus": "RUNNING",
      "KnownStatus": "RUNNING",
      "Limits": {
        "CPU": 64,
        "Memory": 40
      },
      "CreatedAt": "2022-02-18T05:28:40.075508886Z",
      "StartedAt": "2022-02-18T05:28:40.075508886Z",
      "Type": "NORMAL",
      "Networks": [
        {
          "NetworkMode": "awsvpc",
          "IPv4Addresses": [
            "10.0.53.191"
          ],
          "AttachmentIndex": 0,
          "MACAddress": "06:e1:06:44:86:e5",
          "IPv4SubnetCIDRBlock": "10.0.32.0/19",
          "DomainNameServers": [
            "10.0.0.2"
          ],
          "DomainNameSearchList": [
            "ap-northeast-1.compute.internal"
          ],
          "PrivateDNSName": "ip-10-0-53-191.ap-northeast-1.compute.internal",
          "SubnetGatewayIpv4Address": "10.0.32.1/19"
        },
        {
          "NetworkMode": "awsvpc",
          "IPv4Addresses": [
            "169.254.175.252"
          ],
          "AttachmentIndex": 1,
          "MACAddress": "82:94:9e:88:82:3a",
          "IPv4SubnetCIDRBlock": "169.254.175.252/31",
          "DomainNameServers": [
            "10.0.0.2"
          ],
          "DomainNameSearchList": [
            "ap-northeast-1.compute.internal"
          ],
          "SubnetGatewayIpv4Address": "169.254.175.253/31"
        },
        {
          "NetworkMode": "awsvpc",
          "AttachmentIndex": 2,
          "DomainNameServers": [
            "10.0.0.2"
          ],
          "DomainNameSearchList": [
            "ap-northeast-1.compute.internal"
          ]
        }
      ],
      "ContainerARN": "arn:aws:ecs:ap-northeast-1:yyyyyyyyyyyy:container/bullet-srv-xxxxxxxxxxxx/98715bab14334bf19670cec71e5fca81/cdbdcce7-9772-4f68-8fd0-64ce1e9ef1fe"
    }
  ],
  "LaunchType": "FARGATE",
  "ClockDrift": {
    "ClockErrorBound": 0.399981,
    "ReferenceTimestamp": "2022-02-18T06:04:22Z",
    "ClockSynchronizationStatus": "SYNCHRONIZED"
  }
}

ここでコンテナが配備されているAZやIPアドレスがわかります。
あと、アプリケーションコンテナ以外にaws-fargate-request-proxyという名前のコンテナがいるのが興味深いです。

3. ECS_CONTAINER_METADATA_URI_V4/stats

続けてECS_CONTAINER_METADATA_URI_V4/statsの統計情報も取ってみましたが、正直あまり面白い情報は無い感じです。

長いので展開して表示
{
  "read": "2022-02-18T06:08:29.213797375Z",
  "preread": "2022-02-18T06:07:29.213811239Z",
  "pids_stats": {},
  "blkio_stats": {
    "io_service_bytes_recursive": [
      {
        "major": 254,
        "minor": 48,
        "op": "Read",
        "value": 16384
      },
      {
        "major": 254,
        "minor": 48,
        "op": "Write",
        "value": 2384896
      },
      {
        "major": 254,
        "minor": 48,
        "op": "Sync",
        "value": 16384
      },
      {
        "major": 254,
        "minor": 48,
        "op": "Async",
        "value": 2384896
      },
      {
        "major": 254,
        "minor": 48,
        "op": "Total",
        "value": 2401280
      },
      {
        "major": 254,
        "minor": 16,
        "op": "Read",
        "value": 137289728
      },
      {
        "major": 254,
        "minor": 16,
        "op": "Write",
        "value": 0
      },
      {
        "major": 254,
        "minor": 16,
        "op": "Sync",
        "value": 137289728
      },
      {
        "major": 254,
        "minor": 16,
        "op": "Async",
        "value": 0
      },
      {
        "major": 254,
        "minor": 16,
        "op": "Total",
        "value": 137289728
      }
    ],
    "io_serviced_recursive": [
      {
        "major": 254,
        "minor": 48,
        "op": "Read",
        "value": 16
      },
      {
        "major": 254,
        "minor": 48,
        "op": "Write",
        "value": 93
      },
      {
        "major": 254,
        "minor": 48,
        "op": "Sync",
        "value": 16
      },
      {
        "major": 254,
        "minor": 48,
        "op": "Async",
        "value": 93
      },
      {
        "major": 254,
        "minor": 48,
        "op": "Total",
        "value": 109
      },
      {
        "major": 254,
        "minor": 16,
        "op": "Read",
        "value": 3702
      },
      {
        "major": 254,
        "minor": 16,
        "op": "Write",
        "value": 0
      },
      {
        "major": 254,
        "minor": 16,
        "op": "Sync",
        "value": 3702
      },
      {
        "major": 254,
        "minor": 16,
        "op": "Async",
        "value": 0
      },
      {
        "major": 254,
        "minor": 16,
        "op": "Total",
        "value": 3702
      }
    ],
    "io_queue_recursive": [],
    "io_service_time_recursive": [],
    "io_wait_time_recursive": [],
    "io_merged_recursive": [],
    "io_time_recursive": [],
    "sectors_recursive": []
  },
  "num_procs": 0,
  "storage_stats": {},
  "cpu_stats": {
    "cpu_usage": {
      "total_usage": 5679686560,
      "percpu_usage": [
        2387365503,
        1772561177
      ],
      "usage_in_kernelmode": 680000000,
      "usage_in_usermode": 3180000000
    },
    "system_cpu_usage": 4813190000000,
    "online_cpus": 2,
    "throttling_data": {
      "periods": 0,
      "throttled_periods": 0,
      "throttled_time": 0
    }
  },
  "precpu_stats": {
    "cpu_usage": {
      "total_usage": 4145635340,
      "percpu_usage": [
        2379360284,
        1766275056
      ],
      "usage_in_kernelmode": 680000000,
      "usage_in_usermode": 3170000000
    },
    "system_cpu_usage": 1200000000,
    "online_cpus": 2,
    "throttling_data": {
      "periods": 0,
      "throttled_periods": 0,
      "throttled_time": 0
    }
  },
  "memory_stats": {
    "usage": 171888640,
    "max_usage": 171888640,
    "stats": {
      "active_anon": 135852032,
      "active_file": 7200768,
      "cache": 30547968,
      "dirty": 135168,
      "hierarchical_memory_limit": 2147483648,
      "hierarchical_memsw_limit": 9223372036854771712,
      "inactive_anon": 0,
      "inactive_file": 23482368,
      "mapped_file": 11759616,
      "pgfault": 44055,
      "pgmajfault": 99,
      "pgpgin": 49005,
      "pgpgout": 8307,
      "rss": 135675904,
      "rss_huge": 0,
      "total_active_anon": 135852032,
      "total_active_file": 7200768,
      "total_cache": 30547968,
      "total_dirty": 135168,
      "total_inactive_anon": 0,
      "total_inactive_file": 23482368,
      "total_mapped_file": 11759616,
      "total_pgfault": 44055,
      "total_pgmajfault": 99,
      "total_pgpgin": 49005,
      "total_pgpgout": 8307,
      "total_rss": 135675904,
      "total_rss_huge": 0,
      "total_unevictable": 0,
      "total_writeback": 0,
      "unevictable": 0,
      "writeback": 0
    },
    "limit": 9223372036854771712
  },
  "name": "instance",
  "id": "98715bab14334bf19670cec71e5fca81-193386898",
  "networks": {
    "eth1.2": {
      "rx_bytes": 45423791,
      "rx_packets": 11826,
      "rx_errors": 0,
      "rx_dropped": 0,
      "tx_bytes": 1724103,
      "tx_packets": 7791,
      "tx_errors": 0,
      "tx_dropped": 0
    }
  },
  "network_rate_stats": {
    "rx_bytes_per_sec": 351.5500818701549,
    "tx_bytes_per_sec": 353.2834156071528
  }
}

4. ECS_CONTAINER_METADATA_URI_V4/task/stats

最後にECS_CONTAINER_METADATA_URI_V4/task/statsの統計情報です。

長いので展開して表示
{
  "98715bab14334bf19670cec71e5fca81-193386898": {
    "read": "2022-02-18T06:08:59.213814475Z",
    "preread": "2022-02-18T06:08:49.213784828Z",
    "pids_stats": {},
    "blkio_stats": {
      "io_service_bytes_recursive": [
        {
          "major": 254,
          "minor": 48,
          "op": "Read",
          "value": 16384
        },
        {
          "major": 254,
          "minor": 48,
          "op": "Write",
          "value": 2384896
        },
        {
          "major": 254,
          "minor": 48,
          "op": "Sync",
          "value": 16384
        },
        {
          "major": 254,
          "minor": 48,
          "op": "Async",
          "value": 2384896
        },
        {
          "major": 254,
          "minor": 48,
          "op": "Total",
          "value": 2401280
        },
        {
          "major": 254,
          "minor": 16,
          "op": "Read",
          "value": 137289728
        },
        {
          "major": 254,
          "minor": 16,
          "op": "Write",
          "value": 0
        },
        {
          "major": 254,
          "minor": 16,
          "op": "Sync",
          "value": 137289728
        },
        {
          "major": 254,
          "minor": 16,
          "op": "Async",
          "value": 0
        },
        {
          "major": 254,
          "minor": 16,
          "op": "Total",
          "value": 137289728
        }
      ],
      "io_serviced_recursive": [
        {
          "major": 254,
          "minor": 48,
          "op": "Read",
          "value": 16
        },
        {
          "major": 254,
          "minor": 48,
          "op": "Write",
          "value": 93
        },
        {
          "major": 254,
          "minor": 48,
          "op": "Sync",
          "value": 16
        },
        {
          "major": 254,
          "minor": 48,
          "op": "Async",
          "value": 93
        },
        {
          "major": 254,
          "minor": 48,
          "op": "Total",
          "value": 109
        },
        {
          "major": 254,
          "minor": 16,
          "op": "Read",
          "value": 3702
        },
        {
          "major": 254,
          "minor": 16,
          "op": "Write",
          "value": 0
        },
        {
          "major": 254,
          "minor": 16,
          "op": "Sync",
          "value": 3702
        },
        {
          "major": 254,
          "minor": 16,
          "op": "Async",
          "value": 0
        },
        {
          "major": 254,
          "minor": 16,
          "op": "Total",
          "value": 3702
        }
      ],
      "io_queue_recursive": [],
      "io_service_time_recursive": [],
      "io_wait_time_recursive": [],
      "io_merged_recursive": [],
      "io_time_recursive": [],
      "sectors_recursive": []
    },
    "num_procs": 0,
    "storage_stats": {},
    "cpu_stats": {
      "cpu_usage": {
        "total_usage": 5720675338,
        "percpu_usage": [
          2405695536,
          1784252222
        ],
        "usage_in_kernelmode": 690000000,
        "usage_in_usermode": 3210000000
      },
      "system_cpu_usage": 4898940000000,
      "online_cpus": 2,
      "throttling_data": {
        "periods": 0,
        "throttled_periods": 0,
        "throttled_time": 0
      }
    },
    "precpu_stats": {
      "cpu_usage": {
        "total_usage": 5710895416,
        "percpu_usage": [
          2403295048,
          1779489681
        ],
        "usage_in_kernelmode": 690000000,
        "usage_in_usermode": 3200000000
      },
      "system_cpu_usage": 4813190000000,
      "online_cpus": 2,
      "throttling_data": {
        "periods": 0,
        "throttled_periods": 0,
        "throttled_time": 0
      }
    },
    "memory_stats": {
      "usage": 171773952,
      "max_usage": 171888640,
      "stats": {
        "active_anon": 135901184,
        "active_file": 7200768,
        "cache": 30547968,
        "dirty": 135168,
        "hierarchical_memory_limit": 2147483648,
        "hierarchical_memsw_limit": 9223372036854771712,
        "inactive_anon": 0,
        "inactive_file": 23482368,
        "mapped_file": 11759616,
        "pgfault": 44055,
        "pgmajfault": 99,
        "pgpgin": 49005,
        "pgpgout": 8307,
        "rss": 135675904,
        "rss_huge": 0,
        "total_active_anon": 135901184,
        "total_active_file": 7200768,
        "total_cache": 30547968,
        "total_dirty": 135168,
        "total_inactive_anon": 0,
        "total_inactive_file": 23482368,
        "total_mapped_file": 11759616,
        "total_pgfault": 44055,
        "total_pgmajfault": 99,
        "total_pgpgin": 49005,
        "total_pgpgout": 8307,
        "total_rss": 135675904,
        "total_rss_huge": 0,
        "total_unevictable": 0,
        "total_writeback": 0,
        "unevictable": 0,
        "writeback": 0
      },
      "limit": 9223372036854771712
    },
    "name": "instance",
    "id": "98715bab14334bf19670cec71e5fca81-193386898",
    "networks": {
      "eth1.2": {
        "rx_bytes": 45436394,
        "rx_packets": 11912,
        "rx_errors": 0,
        "rx_dropped": 0,
        "tx_bytes": 1738123,
        "tx_packets": 7848,
        "tx_errors": 0,
        "tx_dropped": 0
      }
    },
    "network_rate_stats": {
      "rx_bytes_per_sec": 260.3992279683689,
      "tx_bytes_per_sec": 174.59948234745474
    }
  },
  "98715bab14334bf19670cec71e5fca81-329321356": {
    "read": "2022-02-18T06:08:50.080126637Z",
    "preread": "2022-02-18T06:08:30.080117019Z",
    "pids_stats": {},
    "blkio_stats": {
      "io_service_bytes_recursive": [
        {
          "major": 254,
          "minor": 48,
          "op": "Read",
          "value": 9216
        },
        {
          "major": 254,
          "minor": 48,
          "op": "Write",
          "value": 0
        },
        {
          "major": 254,
          "minor": 48,
          "op": "Sync",
          "value": 9216
        },
        {
          "major": 254,
          "minor": 48,
          "op": "Async",
          "value": 0
        },
        {
          "major": 254,
          "minor": 48,
          "op": "Total",
          "value": 9216
        },
        {
          "major": 254,
          "minor": 32,
          "op": "Read",
          "value": 42319872
        },
        {
          "major": 254,
          "minor": 32,
          "op": "Write",
          "value": 0
        },
        {
          "major": 254,
          "minor": 32,
          "op": "Sync",
          "value": 42319872
        },
        {
          "major": 254,
          "minor": 32,
          "op": "Async",
          "value": 0
        },
        {
          "major": 254,
          "minor": 32,
          "op": "Total",
          "value": 42319872
        }
      ],
      "io_serviced_recursive": [
        {
          "major": 254,
          "minor": 48,
          "op": "Read",
          "value": 9
        },
        {
          "major": 254,
          "minor": 48,
          "op": "Write",
          "value": 0
        },
        {
          "major": 254,
          "minor": 48,
          "op": "Sync",
          "value": 9
        },
        {
          "major": 254,
          "minor": 48,
          "op": "Async",
          "value": 0
        },
        {
          "major": 254,
          "minor": 48,
          "op": "Total",
          "value": 9
        },
        {
          "major": 254,
          "minor": 32,
          "op": "Read",
          "value": 708
        },
        {
          "major": 254,
          "minor": 32,
          "op": "Write",
          "value": 0
        },
        {
          "major": 254,
          "minor": 32,
          "op": "Sync",
          "value": 708
        },
        {
          "major": 254,
          "minor": 32,
          "op": "Async",
          "value": 0
        },
        {
          "major": 254,
          "minor": 32,
          "op": "Total",
          "value": 708
        }
      ],
      "io_queue_recursive": [],
      "io_service_time_recursive": [],
      "io_wait_time_recursive": [],
      "io_merged_recursive": [],
      "io_time_recursive": [],
      "sectors_recursive": []
    },
    "num_procs": 0,
    "storage_stats": {},
    "cpu_stats": {
      "cpu_usage": {
        "total_usage": 1768607551,
        "percpu_usage": [
          627376736,
          667990123
        ],
        "usage_in_kernelmode": 300000000,
        "usage_in_usermode": 390000000
      },
      "system_cpu_usage": 4898940000000,
      "online_cpus": 2,
      "throttling_data": {
        "periods": 0,
        "throttled_periods": 0,
        "throttled_time": 0
      }
    },
    "precpu_stats": {
      "cpu_usage": {
        "total_usage": 1288229008,
        "percpu_usage": [
          623767877,
          664461131
        ],
        "usage_in_kernelmode": 290000000,
        "usage_in_usermode": 390000000
      },
      "system_cpu_usage": 4813190000000,
      "online_cpus": 2,
      "throttling_data": {
        "periods": 0,
        "throttled_periods": 0,
        "throttled_time": 0
      }
    },
    "memory_stats": {
      "usage": 11706368,
      "max_usage": 11866112,
      "stats": {
        "active_anon": 3551232,
        "active_file": 49152,
        "cache": 5271552,
        "dirty": 0,
        "hierarchical_memory_limit": 41943040,
        "hierarchical_memsw_limit": 9223372036854771712,
        "inactive_anon": 0,
        "inactive_file": 7364608,
        "mapped_file": 4730880,
        "pgfault": 4917,
        "pgmajfault": 33,
        "pgpgin": 5445,
        "pgpgout": 2805,
        "rss": 5365760,
        "rss_huge": 0,
        "total_active_anon": 3551232,
        "total_active_file": 49152,
        "total_cache": 5271552,
        "total_dirty": 0,
        "total_inactive_anon": 0,
        "total_inactive_file": 7364608,
        "total_mapped_file": 4730880,
        "total_pgfault": 4917,
        "total_pgmajfault": 33,
        "total_pgpgin": 5445,
        "total_pgpgout": 2805,
        "total_rss": 5365760,
        "total_rss_huge": 0,
        "total_unevictable": 0,
        "total_writeback": 0,
        "unevictable": 0,
        "writeback": 0
      },
      "limit": 41943040
    },
    "name": "aws-fargate-request-proxy",
    "id": "98715bab14334bf19670cec71e5fca81-329321356",
    "networks": {
      "eth1.2": {
        "rx_bytes": 45433842,
        "rx_packets": 11888,
        "rx_errors": 0,
        "rx_dropped": 0,
        "tx_bytes": 1736443,
        "tx_packets": 7832,
        "tx_errors": 0,
        "tx_dropped": 0
      }
    },
    "network_rate_stats": {
      "rx_bytes_per_sec": 502.5497612637359,
      "tx_bytes_per_sec": 616.9997068942893
    }
  }
}

最後に

以上となります。

特にオチは無いのですが想像以上に普通に情報を取れた感じです。
今回の環境はVPC Connectorを有効にしており「VPC接続に関する何らかの情報も取れると嬉しいな」と考えていたのですが流石にそこまでは無理でした。

本記事の内容が誰かの役に立つ...ことは無い気がしますがとりあえず結果だけ共有しておきます。

Share this article

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.