How to get the Utilized storage of the AWS RDS instance using python

0

I am trying to get the utilized storage of the AWS RDS instance using python scripts.

gefragt vor 10 Monaten353 Aufrufe
3 Antworten
0

You can find this via the RDS/CloudWatch metric, FreeStorageSpace. See also, CloudWatch examples using SDK for Python (Boto3).

profile pictureAWS
EXPERTE
kentrad
beantwortet vor 10 Monaten
0

Please check this re:Post answer, which gives you free space available. I'm pasting the code snippet form this thread for your quick reference.

     import boto3
     from datetime import datetime,timedelta
     import json

     # Create CloudWatch client
     cloudwatch = boto3.client('cloudwatch')

     response = cloudwatch.get_metric_data(
         MetricDataQueries=[
             {
                 'Id': 'fetching_FreeStorageSpace',
                 'MetricStat': {
                     'Metric': {
                         'Namespace': 'AWS/RDS',
                         'MetricName': 'FreeStorageSpace',
                         'Dimensions': [
                             {
                                 "Name": "DBInstanceIdentifier",
                                 "Value": "database-1"
                             }
                         ]
                     },
                     'Period': 300,
                     'Stat': 'Minimum'
                 }
             }
         ],
         StartTime=(datetime.now() - timedelta(seconds=300 * 3)).timestamp(),
         EndTime=datetime.now().timestamp(),
         ScanBy='TimestampDescending'
     ) 
     print(response['MetricDataResults'][0]['Values'])

Hope you find this useful.

Abhishek

profile pictureAWS
EXPERTE
beantwortet vor 10 Monaten
0

I have already tried. Thank you

beantwortet vor 10 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen