diff --git a/ElasticSearch/legos/elasticsearch_get_index_health/elasticsearch_get_index_health.py b/ElasticSearch/legos/elasticsearch_get_index_health/elasticsearch_get_index_health.py index 44396686d..8c7fe4481 100644 --- a/ElasticSearch/legos/elasticsearch_get_index_health/elasticsearch_get_index_health.py +++ b/ElasticSearch/legos/elasticsearch_get_index_health/elasticsearch_get_index_health.py @@ -51,29 +51,25 @@ def elasticsearch_get_index_health(handle, index_name="") -> Tuple: :return: A list of dictionaries where each dictionary contains stats about each index """ try: - if index_name: - # Fetch specific index health - health_url = f"/_cat/indices/{index_name}?v&h=index,status&format=json" - health_response = handle.web_request(health_url, "GET", None) - index_stats = [health_response[0]] if health_response and 'error' not in health_response else [] - else: - # Fetches all indices health; skips empty lines and system indices - health_url = "/_cat/indices?v&h=index,status&format=json" - health_response = handle.web_request(health_url, "GET", None) - index_stats = [idx for idx in health_response if not idx['index'].startswith('.')] if health_response and 'error' not in health_response else [] - - if not index_stats: + health_url = f"/_cat/indices/{index_name}?v&h=index,health&format=json" if index_name else "/_cat/indices?v&h=index,health&format=json" + health_response = handle.web_request(health_url, "GET", None) + if not health_response: print(f"No indices found or error retrieving indices: {health_response.get('error', 'No response') if health_response else 'No data'}") return (True, None) - all_indices_stats = [ - {"index": idx['index'], "status": idx['status']} - for idx in index_stats + # Filter indices that are not 'green' + problematic_indices = [ + {"index": idx['index'], "health": idx['health']} + for idx in health_response if idx['health'] != 'green' ] + if not problematic_indices: + print("All indices are in good health.") + return (True, None) + except Exception as e: print(f"Error processing index health: {str(e)}") return (False, []) - return (False, all_indices_stats) if all_indices_stats else (True, None) + return (False, problematic_indices) diff --git a/unskript-ctl/unskript_ctl_main.py b/unskript-ctl/unskript_ctl_main.py index f8c3bea70..cf9fa3fcb 100644 --- a/unskript-ctl/unskript_ctl_main.py +++ b/unskript-ctl/unskript_ctl_main.py @@ -157,7 +157,7 @@ def run_main(self, **kwargs): else: output_dir = os.path.join(UNSKRIPT_EXECUTION_DIR, self.uglobals.get('exec_id')) - failed_objects_file = os.path.join(UNSKRIPT_EXECUTION_DIR, self.uglobals.get('exec_id')) + '_output.txt' + failed_objects_file = os.path.join(output_dir, self.uglobals.get('exec_id')) + '_output.txt' diag_args = [ '--yaml-file', YAML_CONFIG_FILE, diff --git a/unskript-ctl/unskript_upload_results_to_s3.py b/unskript-ctl/unskript_upload_results_to_s3.py index 5b27b7c1b..eabed0dc6 100644 --- a/unskript-ctl/unskript_upload_results_to_s3.py +++ b/unskript-ctl/unskript_upload_results_to_s3.py @@ -14,9 +14,9 @@ def __init__(self): aws_access_key_id = os.getenv('LIGHTBEAM_AWS_ACCESS_KEY_ID') aws_secret_access_key = os.getenv('LIGHTBEAM_AWS_SECRET_ACCESS_KEY') self.bucket_name = 'lightbeam-reports' - self.ts = "TS" now = datetime.now() rfc3339_timestamp = now.isoformat() + 'Z' + self.ts = rfc3339_timestamp year = now.strftime("%Y") month = now.strftime("%m") day = now.strftime("%d")