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 Antworten
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
Donov
beantwortet vor 9 Monaten
  • 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
Donov
beantwortet vor 8 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen