Search code examples
amazon-web-servicesaws-cliamazon-cloudwatch

aws cloudwatch cli put-metric-data to AWS namespace


I would like to test some AWS CloudWatch alarms linked to some AWS metrics(ApiGateway • 5XXError). I try to manually add data to this, without messing up my API. I try the command:

aws cloudwatch put-metric-data --namespace AWS/ApiGateway --metric-name 5XXError --dimensions ApiName=SpacesApi --value 1

But I get the response:

An error occurred (InvalidParameterValue) when calling the PutMetricData operation: The value AWS/ for parameter Namespace is invalid.

I'm pretty sure this is possible, since I've done this in the past, but I can't make it work.


Solution

  • As per AWS documentation:

    A number of AWS services publish their own metrics in namespaces beginning with " AWS " You can also publish custom metric data using your own namespace (as long as it doesn’t begin with " AWS ").

    Note:

    You cannot specify a namespace that begins with " AWS ". Namespaces that begin with " AWS " are reserved for use by Amazon Web Services products.

    In your case, AWS/ApiGateway namespace is reserved for Amazon API Gateway to publish metrics to CloudWatch, so it's not possible.

    References: Publishing custom metric data to CloudWatch