如何在AWS ApiGateway中为AWS APIGateway阶段设置CloudWatch设置

如何在AWS ApiGateway中为AWS APIGateway阶段设置CloudWatch设置

问题描述:

,使用JAVA API部署新阶段后,如何使用Java API而不是通过aws控制台启用CloudWatch设置?如何在AWS ApiGateway中为AWS APIGateway阶段设置CloudWatch设置

对于create-stage,我可以CreateStage输出下获得的MethodSetting的CloudWatch的设置,但是当我创建的阶段,我不能设置设置或创建部署。

你应该能够用patch requestupdate-stage operation

这里来更新你的舞台在CloudWatch的设置是一个示例代码段(我没有实际测试过这一点;但基本原则应该工作):

AmazonApiGateway apiGateway = ...; 
UpdateStageRequest req = new UpdateStageRequest().withRestApiId(<api-id>). 
      withStageName(<stage-name>). 
      withPatchOperations(
       new PatchOperation().withPath("*/*/metrics/enabled") 
            .withOp("replace") 
            .withValue("true")); 

apiGateway.upate(req); 
+0

谢谢,它的工作原理,但为什么aws更喜欢使用补丁操作,而不是其他更明显的api – Jie