Unverified Commit da6e5f3a by Joseph Mulloy Committed by GitHub

Merge pull request #4282 from edx/jdmulloy/ops2545/redis_script_alarm_thresholds

Prevent reconfiguring alarms OPS-2545
parents 81feb823 5893c690
...@@ -100,7 +100,8 @@ def check_queues(host, port, environment, deploy, max_metrics, threshold, ...@@ -100,7 +100,8 @@ def check_queues(host, port, environment, deploy, max_metrics, threshold,
if len(all_queues) > max_metrics: if len(all_queues) > max_metrics:
# TODO: Use proper logging framework # TODO: Use proper logging framework
print("Warning! Too many metrics, refusing to publish more than {}".format(max_metrics)) print("Warning! Too many metrics, refusing to publish more than {}"
.format(max_metrics))
# Take first max_metrics number of queues from all_queues and remove # Take first max_metrics number of queues from all_queues and remove
# queues that aren't in redis # queues that aren't in redis
...@@ -128,21 +129,26 @@ def check_queues(host, port, environment, deploy, max_metrics, threshold, ...@@ -128,21 +129,26 @@ def check_queues(host, port, environment, deploy, max_metrics, threshold,
treat_missing_data = "missing" treat_missing_data = "missing"
statistic = "Maximum" statistic = "Maximum"
actions = [sns_arn] actions = [sns_arn]
alarm_name = "{} queue length over threshold".format(queue) alarm_name = "{}-{} {} queue length over threshold".format(environment,
deploy,
# Always create/configure alert to keep config up to date queue)
cloudwatch.put_metric_alarm(AlarmName=alarm_name, if len(cloudwatch.describe_alarms_for_metric(Namespace=namespace,
AlarmDescription=alarm_name, MetricName=metric_name,
Namespace=namespace, Dimensions=dimensions)
MetricName=metric_name, ['MetricAlarms']) < 1:
Dimensions=dimensions, print('Creating new alarm "{}"'.format(alarm_name))
Period=period, cloudwatch.put_metric_alarm(AlarmName=alarm_name,
EvaluationPeriods=evaluation_periods, AlarmDescription=alarm_name,
TreatMissingData=treat_missing_data, Namespace=namespace,
Threshold=threshold, MetricName=metric_name,
ComparisonOperator=comparison_operator, Dimensions=dimensions,
Statistic=statistic, Period=period,
AlarmActions=actions) EvaluationPeriods=evaluation_periods,
TreatMissingData=treat_missing_data,
Threshold=threshold,
ComparisonOperator=comparison_operator,
Statistic=statistic,
AlarmActions=actions)
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment