Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 如何通过Cloudformation模板为AWS API GW启用Cloudwatch日志记录_Amazon Web Services_Amazon Cloudformation_Aws Api Gateway_Api Gateway_Amazon Api Gateway - Fatal编程技术网

Amazon web services 如何通过Cloudformation模板为AWS API GW启用Cloudwatch日志记录

Amazon web services 如何通过Cloudformation模板为AWS API GW启用Cloudwatch日志记录,amazon-web-services,amazon-cloudformation,aws-api-gateway,api-gateway,amazon-api-gateway,Amazon Web Services,Amazon Cloudformation,Aws Api Gateway,Api Gateway,Amazon Api Gateway,我试图通过cloudformation模板为AWSAPI网关启用cloudwatch日志,但它没有启用。我已经尝试在阶段描述和方法设置中设置logginglevel to INFO。你知道我错过了什么吗 当我通过UI手动启用日志记录时,它可以工作。当我尝试通过下面的cloudformation模板启用时不工作- 注意:我只是在使用普通的cloudformation模板,我已经添加了角色ARN,该角色对我帐户中的API网关具有登录cloudwatch的权限 您是否已经按照AWS文档中的描述配置AP

我试图通过cloudformation模板为AWSAPI网关启用cloudwatch日志,但它没有启用。我已经尝试在阶段描述和方法设置中设置logginglevel to INFO。你知道我错过了什么吗

当我通过UI手动启用日志记录时,它可以工作。当我尝试通过下面的cloudformation模板启用时不工作-

注意:我只是在使用普通的cloudformation模板,我已经添加了角色ARN,该角色对我帐户中的API网关具有登录cloudwatch的权限


您是否已经按照AWS文档中的描述配置API网关RestApi以将日志写入CloudWatch:


请注意,您必须为CloudWatch日志设置权限。

请在阶段说明中将MetricsEnabled属性添加到阶段级别的enabled CloudWatch日志中。如果要在方法级别启用CloudWatch日志,请在MethodSettigns中添加MetricsEnabled属性。在下面的示例中,我在这两个位置都启用了日志

TestDeployment:
  Type: AWS::ApiGateway::Deployment
  Properties:
    Description: API Deployment
    RestApiId: testApi
    StageName: 'dev'
    StageDescription:
      Description: Stage - DEV
      LoggingLevel: INFO
      MetricsEnabled: True
      MethodSettings:
        - ResourcePath: "/testresource"
          HttpMethod: "POST"
          LoggingLevel: INFO
          MetricsEnabled: True

是的,我确实添加了在帐户级别对APIGateway具有权限的角色。问题在于部署/阶段日志记录。当我在stage中手动启用“启用CloudWatch日志”时,它就起作用了。但当我试图通过cloudformation模板启用时,它不起作用。我试过了。它不起作用。我联系了AWS支持团队,他们要求我采取以下措施解决问题-方法设置:-ResourcePath:“/*”HttpMethod:“*”LoggingLevel:INFO。
TestDeployment:
  Type: AWS::ApiGateway::Deployment
  Properties:
    Description: API Deployment
    RestApiId: testApi
    StageName: 'dev'
    StageDescription:
      Description: Stage - DEV
      LoggingLevel: INFO
      MetricsEnabled: True
      MethodSettings:
        - ResourcePath: "/testresource"
          HttpMethod: "POST"
          LoggingLevel: INFO
          MetricsEnabled: True