Is there a cloudwatch metric to determine no. of graviton instances running in a AWS region?

0

I want to create a grafana dashboard showing no. of graviton instances running in each region. This doesn't need to real time, need it refreshed once a week. Probably looking for some instance level metric which is unique to graviton or a metric which has a instance type dimension, or some other way to get the information.

질문됨 9달 전161회 조회
1개 답변
0

I don't think there is going to be any pre-built metrics that can do this for you. Two ways that I can think of that might help here:

  1. This is probably simplest: Use Config - you can create a query to list all of the instances, then filter from there: https://docs.aws.amazon.com/config/latest/developerguide/example-query.html
  2. Create a Lambda function that scans all regions and collects the data that you need. Run the function periodically using EventBridge then store the results in an appropriate place. This is more complex but depending on what you're looking for may have greater flexibility. Example Python code below:
import boto3

ec2 = boto3.client('ec2')

regionList = ec2.describe_regions()['Regions']
for region in regionList:
    regionName = region['RegionName']
    ec2Region = boto3.client('ec2', region_name=regionName)

    ec2Iterator = ec2Region.get_paginator('describe_instances').paginate()
    for object in ec2Iterator:
        for instanceList in object['Reservations']:
            for instance in instanceList['Instances']:
                print(regionName, instance['InstanceType'])
profile pictureAWS
전문가
답변함 9달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠