3 Answers
- Newest
- Most votes
- Most comments
0
Oh sorry had overlooked it was a standard namespace. AWS namespaces are prefixed with AWS, your namespace is Namespace='AWS/MWAA', not Namespace='MWAA'.
Can you try this?
import boto3
client = boto3.client("cloudwatch", region_name='us-east-1')
list_resp = client.list_metrics(
Namespace='AWS/MWAA')
print(len(list_resp["Metrics"]))
answered 7 months ago
0
Hi, is it code you're trying to run in a lambda? Are you sure you have set all the dimensions and are querying the right region? Overall the syntax looks OK. Did you try calling the list_metrics API beforehand? This would help you check for any dimensions/names mismatches.
For example (note that region is optional, if you are calling from a lambda it inherits by default the lambda region) - note this example uses the lambda_handler as I tested it from a lambda, you may not need it if you're calling your python script in a different way:
import boto3
from datetime import datetime
client = boto3.client("cloudwatch")
def lambda_handler(event, context):
list_resp = client.list_metrics(
Namespace='MWAA')
print(list_resp)
answered 7 months ago
0
import boto3
client = boto3.client("cloudwatch", region_name='us-east-1')
list_resp = client.list_metrics(
Namespace='MWAA')
print(len(list_resp["Metrics"]))
-- 0
and
import boto3
client = boto3.client("cloudwatch", region_name='us-east-1')
list_resp = client.list_metrics(
Namespace='AmazonMWAA')
print(len(list_resp["Metrics"]))
-- 499
answered 7 months ago
Relevant content
- Accepted Answerasked 2 months ago
- asked a month ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 2 years ago