Error while creating an cloudwatchMetricFilter with Cloudformation

0

Hi together, I'm trying to create an Cloudwatch Metric Filter with Cloudformation:

myCWMetric:
    Type: AWS::Logs::MetricFilter
    Properties:
      LogGroupName: /aws/lambda/mybackend-list
      FilterPattern: "[...,uri=%contacts%, duration,]"
      MetricTransformations:
        - MetricValue: "$.duration"
          MetricNamespace: mybackend-list/apiDurations
          MetricName: ContactMediaDuration
          Unit: Milliseconds

The ErrorMesage which is Cloudformation is throwing is the following:

Resource handler returned message: "Invalid request provided: AWS::Logs::MetricFilter. Invalid metric transformation: metric value $.duration must be a valid number

anyone have an idea how to solve this issue?

Thx :-) Oliver

1回答
1
承認された回答

Hello.

The error message suggests that the $.duration is not being interpreted as a valid number, which might be happening because of the filter pattern or a mismatch with the actual log event format.

Ensure that the duration placeholder correctly matches the actual logs. For example, if your log line is something like:

some-text uri=/contacts/123 duration=456

Then your filter pattern might look something like:

FilterPattern: "... uri=%contacts% duration=$[duration]"

Regards, Andrii

profile picture
エキスパート
回答済み 9ヶ月前
profile picture
エキスパート
レビュー済み 2ヶ月前
  • Hi Andrii, Thanks for your answer. Finaly I found the issue:

    The Attribute MetricValue must be $duration instead of $.duration. The AWS Documentation was in this case not so helpfull, because this case is not handled there.

    Regards Oliver

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ