如何在CloudWatch AWS中捕获外部端点的日志

发布于 2025-01-21 09:25:08 字数 1958 浏览 2 评论 0原文

我是AWS的新手,并试图使用事件Brigde和API目的地进行ping和端点。我成功地创建了API目的地和API连接 使用云形成模板,还可以成功地创建了IAM角色和规则,但是我想在计划表达式之后将logs在CloudWatch中触发该端点。 (没有事件触发该端点,我想在每5分钟后触发它)

是我的云形成模板

    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Principal:
              Service:
                - events.amazonaws.com
            Action:
              - sts:AssumeRole
      Path: '/jobs-role/'
      Policies:
        - PolicyName: eventbridge-api-destinations
          PolicyDocument:
            Version: '2012-10-17'
            Statement:
              - Effect: Allow
                Action:
                  - events:InvokeApiDestination
                Resource: !GetAtt Destination.Arn

  ApiConnection:
    Type: AWS::Events::Connection
    Properties:
      AuthorizationType: API_KEY
      Description: Connection to API
      AuthParameters:
        ApiKeyAuthParameters:
          ApiKeyName: authorization
          ApiKeyValue: MyAPIkey
  Destination:
    Type: AWS::Events::ApiDestination
    Properties:
      ConnectionArn: !GetAtt ApiConnection.Arn
      Description: API Destination to send events
      HttpMethod: POST
      InvocationEndpoint: !Ref ApiDestinationInvocationEndpoint
      InvocationRateLimitPerSecond: 10

  RecordsRule:
    Type: AWS::Events::Rule
    Properties:
      Description: !Sub 'Trigger ${RecordsRole} according to the specified schedule'
      State: ENABLED
      ScheduleExpression: "rate(5 minutes)"
      Targets:
        - Id: !Sub '${RecordsRole}'
          Arn: !GetAtt Destination.Arn
          RoleArn: !GetAtt RecordsRole.Arn
          HttpParameters:
            HeaderParameters:
              Content-type: application/json;charset=utf-8



Can anyone tell me what i am lacking?

Below is link to my screenshot of invocations graph in metrics


  [1]: https://i.sstatic.net/Zms44.png

Im new to aws and was trying to use Event brigde and api destination for pinging and endpoint. I am successful in creating api destination and api connection
using cloud formation template and also successfully created IAM role and rule for the same, but i want to have the logs in cloudwatch triggering that endpoint after a scheduled expression. (There is no event triggering that endpoint, i want to trigger it after every 5 min)

Below is my cloud formation template

    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Principal:
              Service:
                - events.amazonaws.com
            Action:
              - sts:AssumeRole
      Path: '/jobs-role/'
      Policies:
        - PolicyName: eventbridge-api-destinations
          PolicyDocument:
            Version: '2012-10-17'
            Statement:
              - Effect: Allow
                Action:
                  - events:InvokeApiDestination
                Resource: !GetAtt Destination.Arn

  ApiConnection:
    Type: AWS::Events::Connection
    Properties:
      AuthorizationType: API_KEY
      Description: Connection to API
      AuthParameters:
        ApiKeyAuthParameters:
          ApiKeyName: authorization
          ApiKeyValue: MyAPIkey
  Destination:
    Type: AWS::Events::ApiDestination
    Properties:
      ConnectionArn: !GetAtt ApiConnection.Arn
      Description: API Destination to send events
      HttpMethod: POST
      InvocationEndpoint: !Ref ApiDestinationInvocationEndpoint
      InvocationRateLimitPerSecond: 10

  RecordsRule:
    Type: AWS::Events::Rule
    Properties:
      Description: !Sub 'Trigger ${RecordsRole} according to the specified schedule'
      State: ENABLED
      ScheduleExpression: "rate(5 minutes)"
      Targets:
        - Id: !Sub '${RecordsRole}'
          Arn: !GetAtt Destination.Arn
          RoleArn: !GetAtt RecordsRole.Arn
          HttpParameters:
            HeaderParameters:
              Content-type: application/json;charset=utf-8



Can anyone tell me what i am lacking?

Below is link to my screenshot of invocations graph in metrics


  [1]: https://i.sstatic.net/Zms44.png

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文