Created
July 6, 2017 13:51
-
-
Save haitaoyao/80737861081a4dacb7c51201e49c7984 to your computer and use it in GitHub Desktop.
Get rds replica lag metric value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_cloudwatch_replica_lag(rds_id, start_time, end_time) | |
local_timezone = pytz.timezone('Asia/Shanghai') | |
cloudwatch = boto3.client('cloudwatch') | |
start_time_with_tz = local_timezone.localize(start_time) | |
end_time_with_tz = local_timezone.localize(end_time) | |
values = cloudwatch.get_metric_statistics(Namespace='AWS/RDS', | |
MetricName='ReplicaLag', | |
Dimensions=[dict(Name='DBInstanceIdentifier', Value=rds_id)], | |
StartTime=start_time_with_tz, | |
EndTime=end_time_with_tz, | |
Period=60, | |
Statistics=['Maximum'], | |
Unit='Seconds').get('Datapoints') | |
return values |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment