0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Amazon ECS(Fargate): Firelensの[FILTER]に、name ecsを設定した場合としない場合のログ形式の違い

Posted at

はじめに

Fluent BitのFILTERには、ECSというものがあります。
Amazon ECS(Fargate)からログを出力するときに、FILTERにECSを設定した場合としない場合で、
どのような違いがあるかを調べてみました。

confファイル

今回の検証で使ったconfファイルです。
FILTERをコメントアウトした場合としない場合で、テストしました

# Fluent Bit 設定ファイル
[SERVICE]
    Flush               5
    Grace               30
    Log_Level           info

# # 
# [FILTER]
#     Name                ecs
#     Match               *

# CloudWatch Logs にログを出力
[OUTPUT]
    Name                cloudwatch_logs
    Match               *
    region              ap-northeast-1
    log_group_name      /ecs/learn-backend-prod
    log_stream_prefix   backend/
    auto_create_group   true    

ログ形式

ログの形式を確認したところ、同じ形式でした

  • [FILTER] ecsが存在する場合
{
  "container_id": "8f7a73b5da1f4d62a641ed763edb4656-1955534044",
  "container_name": "learn-backend-container-prod",
  "source": "stdout",
  "log": "[GIN] 2024/09/22 - 01:52:44 | 422 |    1.182171ms |    1.73.152.207 | POST     \"/query\"",
  "ecs_cluster": "learn-backend-ecs-cluster-prod",
  "ecs_task_arn": "arn:aws:ecs:ap-northeast-1:${AWS ACCOUNT ID}:task/learn-backend-ecs-cluster-prod/8f7a73b5da1f4d62a641ed763edb4656",
  "ecs_task_definition": "learn-backend-task-definition-prod:52"
}
  • [FILTER] ecsが存在しない場合
{
  "container_id": "f5427818b40547ff952af8aab9f77ba4-1955534044",
  "container_name": "learn-backend-container-prod",
  "source": "stdout",
  "log": "[GIN] 2024/09/22 - 01:58:01 | 422 |    1.423036ms |    1.73.152.207 | POST     \"/query\"",
  "ecs_cluster": "learn-backend-ecs-cluster-prod",
  "ecs_task_arn": "arn:aws:ecs:ap-northeast-1:${AWS ACCOUNT ID}:task/learn-backend-ecs-cluster-prod/f5427818b40547ff952af8aab9f77ba4",
  "ecs_task_definition": "learn-backend-task-definition-prod:52"
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?