def query_sls_risk_item()

in solution/finance/storage_risk_item.py [0:0]


    def query_sls_risk_item(account_id,
                            access_key_id,
                            access_key_secret,
                            role_name):

        permanent_storage_days = 3650
        for region_id in region_id_list:
            output_str = f'AccountId: {account_id} Region:{region_id}\n'
            client = StorageResourceSample.create_sls_client(account_id, access_key_id, access_key_secret, role_name,
                                                             region_id)

            projects = StorageResourceSample.query_sls_project(client)
            for project in projects:
                project_name = project['projectName']

                if project['status'] != 'Normal':
                    continue

                log_store_list = StorageResourceSample.query_sls_store(client, project_name)
                for log_store in log_store_list:
                    log_store_name = log_store["logstoreName"]
                    if log_store['ttl'] >= permanent_storage_days:
                        output_str += f'<Project:{project_name} LogStore:{log_store_name} Risk:开启永久存储>\n'
                        continue

                    if log_store['ttl'] >= sls_ttl_threshold_days:
                        output_str += f'<Project:{project_name} LogStore:{log_store_name} ' \
                                      f'Warn:存储天数大于设定的{sls_ttl_threshold_days}天阀值>\n'

                    if log_store['ttl'] > sls_hot_ttl_threshold_days and 'hot_ttl' not in log_store:
                        output_str += f'<Project:{project_name} LogStore:{log_store_name} ' \
                                      f'Warn:热存储超过{sls_hot_ttl_threshold_days}天,未开启冷存储>\n'

                    index = StorageResourceSample.query_sls_index(client, project_name, log_store_name)
                    if 'line' in index:
                        output_str += f'<Project:{project_name} LogStore:{log_store_name} Warn:开启全文索引\n'
                    if 'log_reduce' in index and index['log_reduce']:
                        output_str += f'<Project:{project_name} LogStore:{log_store_name} Info:开启日志聚类\n'

            print(output_str)