def __init__(self, dict_src, from_cache=False):
            self.statements = []

            super(CloudWatchLogGroup.LogStream,
                  self).__init__(dict_src, from_cache=from_cache)

            if from_cache:
                self.init_log_stream_from_cache(dict_src)
                return

            init_options = {
                "logStreamName":
                self.init_default_attr,
                "creationTime":
                lambda name, value:
                (name, CommonUtils.timestamp_to_datetime(value / 1000.0)),
                "firstEventTimestamp":
                self.init_default_attr,
                "lastEventTimestamp":
                self.init_default_attr,
                "lastIngestionTime":
                self.init_default_attr,
                "uploadSequenceToken":
                self.init_default_attr,
                "arn":
                self.init_default_attr,
                "storedBytes":
                self.init_default_attr
            }

            self.init_attrs(dict_src, init_options)
Ejemplo n.º 2
0
    def clear_indices(self, time_limit=None):
        if time_limit is None:
            time_limit = datetime.datetime.now() - datetime.timedelta(days=30 *
                                                                      2)

        self.init_indices()
        to_del_indices = []
        for es_index_name, es_index in self.indices.items():
            if es_index_name.startswith("."):
                continue

            created_date = CommonUtils.timestamp_to_datetime(
                es_index["settings"]["index"]["creation_date"],
                microseconds_value=True)
            if created_date < time_limit:
                logger.info(
                    f"Deleting index '{es_index_name}' created at {created_date}"
                )
                to_del_indices.append(es_index_name)
        pdb.set_trace()
        self.client.indices.delete(to_del_indices)
        logger.info(
            f"Deleted {len(to_del_indices)} out of {len(self.indices)}")