Home > Blockchain >  What is the integration service name for CloudWatch
What is the integration service name for CloudWatch

Time:11-05

I am trying to create AWS API gateway with AWS service integration with cloudwatch using AWS cdk/ cloudformation. But I am getting errors like "AWS service of type cloudwatch not supported". When I try to use Cloud watch log then it works but not for only cloudwatch.

Code
new AwsIntegrationProps
{
Region = copilotFoundationalInfrastructure.Region,
Options = new IntegrationOptions {
PassthroughBehavior = PassthroughBehavior.WHEN_NO_TEMPLATES,
CredentialsRole = Role.FromRoleArn(this,"CloudWatchAccessRole", "arn:aws:iam::800524210815:role/APIGatewayCloudWatchRole"),
RequestParameters = new Dictionary\<string, string\>()
{
{ "integration.request.header.Content-Encoding", "'amz-1.0'" },
{ "integration.request.header.Content-Type", "'application/json'" },
{ "integration.request.header.X-Amz-Target", "'GraniteServiceVersion20100801.PutMetricData'" },  
},
},
IntegrationHttpMethod = "POST",
Service = "cloudwatch", // this is working with s3 and logs
Action = "PutMetricData"
}

What is the correct service name for cloudwatch to putmetricsdata?

new AwsIntegrationProps
                {
                    Region = copilotFoundationalInfrastructure.Region,
                    Options = new IntegrationOptions {
                        PassthroughBehavior = PassthroughBehavior.WHEN_NO_TEMPLATES,
                        CredentialsRole = Role.FromRoleArn(this,"CloudWatchAccessRole", "arn:aws:iam::800524210815:role/APIGatewayCloudWatchRole"),
                        RequestParameters = new Dictionary<string, string>() 
                        { 
                            { "integration.request.header.Content-Encoding", "'amz-1.0'" },
                            { "integration.request.header.Content-Type", "'application/json'" },
                            { "integration.request.header.X-Amz-Target", "'GraniteServiceVersion20100801.PutMetricData'" },    
                        },
                    },
                    IntegrationHttpMethod = "POST",
                    Service = "", // What will be the correct value for cloudwatch
                    Action = "PutMetricData"
                }

What will be the correct value for cloudwatch

CodePudding user response:

For CloudWatch logs you put logs right? So for CloudWatch, it is monitoring... I got it from a github code but cannot find it anymore.

CodePudding user response:

There are several ways to configure CloudWatch to monitor your API Gateway. First, you can create an AWS CloudWatch metric to monitor specific outputs produced by your API Gateway - see an example here. The second way is to use the default configuration - see here.

  • Related