ECS service does not add CloudWatch metric via EMF

0

I tried to add the metric of my ECS using EMF but it does not work. When I uses for Lambda function it works, so I'd like to know if I am missing something or having the wrong parameters. The following struct is what I send:

 {
    "level": "error",
    "caller": "server/server.go:346",
    "function": "main/server.(*Server).respond",
    "msg": "xxxxx",
    "_aws": {
        "Timestamp": 1693323353466,
        "CloudWatchMetrics": [
            {
                "Namespace": "ecs_name",
                "Dimensions": [
                    [
                        "TaskDefinition"
                    ]
                ],
                "Metrics": [
                    {
                        "Name": "ecs_error",
                        "Unit": ""
                    }
                ]
            }
        ]
    },
    "ecs_error": 1,
    "TaskDefinition": "ecs_tack_name",
    "stacktrace": "xxxx"
}
2 Answers
0

Hi,

Did you set up a awslogs log driver to send EMF json file to Cloud watch Logs ? With Lambda you don't need to set up a log driver because by default STOUT is redirected to Cloud watch Logs.

profile picture
answered a year ago
  • Hi, Yes, I have in my configuration:

              LogConfiguration:
                LogDriver: awslogs
                Options:
                  awslogs-group: my_log_group
                  awslogs-region: !Ref AWS::Region
                  awslogs-stream-prefix: ecs
0

Okay, And what about Metric section ? Unit is empty, you should set something like Count or something else.

profile picture
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions