How to use describe_alarm_history method in localstack

Best Python code snippet using localstack_python

CouldWatch-01.py

Source:CouldWatch-01.py Github

copy

Full Screen

...79}80"""81# ################################### describe_alarm_history #################################82# 检索指定警报的历史记录83# response = client.describe_alarm_history(84# AlarmName='Default_Test_Alarm3',85# HistoryItemType='ConfigurationUpdate',86# StartDate=datetime(2015, 1, 1),87# EndDate=datetime(2019, 7, 2),88# MaxRecords=50, # 小于等于10089# # NextToken=None90# )91# # 'ConfigurationUpdate' | 'StateUpdate' | 'Action',92# print(response)93"""94{95 'AlarmHistoryItems': [],96 'ResponseMetadata': {97 'RequestId': '9a2d94f2-9cb6-11e9-b5ef-09bc043668d6',...

Full Screen

Full Screen

cwops.py

Source:cwops.py Github

copy

Full Screen

...214 p2=namespace, p3=period,215 p4=statistic,216 p5=dimensions, p6=unit))217 return self.connection.describe_alarms_for_metric(metric_name, namespace, period, statistic, dimensions, unit)218 def describe_alarm_history(self, alarm_name=None, start_date=None, end_date=None, max_records=None,219 history_item_type=None, next_token=None):220 self.log.debug(221 'Calling describe_alarm_history( {p1}, {p2}, {p3}, {p4}, {p5}, {p6} )'.format(p1=alarm_name, p2=start_date,222 p3=end_date, p4=max_records,223 p5=history_item_type,224 p6=next_token))225 return self.connection.describe_alarm_history(alarm_name, start_date, end_date, max_records, history_item_type,226 next_token)227 def get_dimension_array(self):228 return DimensionArray229 def get_stats_array(self):230 return StatsArray231 def get_instance_metrics_array(self):232 return InstanceMetricArray233 def get_status_metric_array(self):234 return StatusMetricArray235 def get_ebs_metrics_array(self):236 return EbsMetricsArray237 def enable_alarm_actions(self, alarm_names):238 self.log.debug('Calling enable_alarm_actions( ' + str(alarm_names) + ' )')239 self.connection.enable_alarm_actions(alarm_names)...

Full Screen

Full Screen

cloudwatch.py

Source:cloudwatch.py Github

copy

Full Screen

1import logging2from nab3.base import PaginatedBaseService3from nab3.utils import paginated_search, snake_to_camelcap4LOGGER = logging.getLogger('nab3')5LOGGER.setLevel(logging.WARNING)6class Alarm(PaginatedBaseService):7 """8 boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudwatch.html#CloudWatch.Client.describe_alarm_history9 """10 boto3_client_name = 'cloudwatch'11 key_prefix = 'Alarm'12 @classmethod13 def get_history(cls, start_date, end_date, name=None, item_type=None, alarm_types=None, sort_descending=True):14 """ Retrieves the history for the specified alarm.15 :param start_date: StartDate=datetime(2015, 1, 1)16 :param end_date: EndDate=datetime(2015, 1, 1)17 :param name: AlarmName='string'18 :param item_type: HistoryItemType='ConfigurationUpdate StateUpdate Action'19 :param alarm_types: AlarmTypes=['CompositeAlarm MetricAlarm']20 :param sort_descending: bool -> ScanBy='TimestampDescending TimestampAscending'21 :return:22 """23 search_kwargs = dict(StartDate=start_date, EndDate=end_date,24 AlarmTypes=alarm_types,25 ScanBy='TimestampDescending' if sort_descending else 'TimestampAscending')26 if name:27 search_kwargs['AlarmName'] = name28 if item_type:29 search_kwargs['HistoryItemType'] = item_type30 search_fnc = cls._client.get(cls.boto3_client_name).describe_alarm_history31 results = paginated_search(search_fnc, search_kwargs, 'AlarmHistoryItems')32 return [cls(_loaded=True, **result) for result in results]33class Metric(PaginatedBaseService):34 """35 boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudwatch.html#CloudWatch.Client.list_metrics36 boto3.amazonaws.com/v1/documentation/api/latest/reference/services/cloudwatch.html#CloudWatch.Client.get_metric_statistics37 docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#dimension-combinations38 """39 boto3_client_name = 'cloudwatch'40 key_prefix = 'Metric'41 _boto3_describe_def = dict(42 client_call="list_metrics",43 call_params=dict(44 dimensions=dict(name='Dimensions', type=list), # list<dict(Name=str, Value=str)>45 name=dict(name='MetricName', type=str),46 namespace=dict(name='Namespace', type=str),47 )48 )49 @classmethod50 def get_statistics(cls, namespace, metric_name, start_time, end_time, interval_as_seconds, **kwargs):51 """52 Optional params:53 Dimensions=[54 {55 'Name': 'string',56 'Value': 'string'57 },58 ],59 StartTime=datetime(2015, 1, 1),60 EndTime=datetime(2015, 1, 1),61 Period=123,62 (Statistics=[63 'SampleCount Average Sum Minimum Maximum',64 ],65 ExtendedStatistics=[66 'string',67 ]) - Statistics or ExtendedStatistics must be set ,68 Unit='Seconds Microseconds Milliseconds Bytes Kilobytes Megabytes69 :param namespace:70 :param metric_name:71 :param start_time:72 :param end_time:73 :param interval_as_seconds: This is the Period paremeter. Renamed here to make the purpose more intuitive74 :param kwargs:75 :return:76 """77 search_kwargs = dict(EndTime=end_time,78 Namespace=namespace,79 MetricName=metric_name,80 Period=interval_as_seconds,81 StartTime=start_time)82 for k, v in kwargs.items():83 search_kwargs[snake_to_camelcap(k)] = v84 client = cls._client.get(cls.boto3_client_name)85 response = client.get_metric_statistics(**search_kwargs)86 return [cls(name=metric_name, _loaded=True, **obj) for obj in response.get('Datapoints', [])]87 @classmethod88 def get(cls, **kwargs):89 raise NotImplementedError("get is not a supported operation for Metric")90 @classmethod91 def load(cls, **kwargs):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful