List cloudwatch metrics



    AWS and boto3 recipes for Python

    To list metrics in CloudWatch, first create a CloudWatch client. Next, use the get_paginator() function to get the paginator object. This object allows you to query CloudWatch using the pagination interface. Finally, use the paginate() function to iterate through the results of the query. Note that the query uses the Dimensions and MetricName parameters to specify the query parameters. The Namespace parameter specifies the namespace under which the results should be retrieved.

    Library: boto3

    import boto3
    # Create CloudWatch client
    cloudwatch = boto3.client('cloudwatch')
    # List metrics through the pagination interface
    paginator = cloudwatch.get_paginator('list_metrics')
    for response in paginator.paginate(Dimensions=[{'Name': 'loggroupname'}],
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.