From 1b33a3d3dc1020f56be093498592141a3a684c8b Mon Sep 17 00:00:00 2001 From: NathanTesseyre Date: Fri, 22 May 2026 11:01:33 +0200 Subject: [PATCH 1/6] feat: add critical errors to server.log --- python-api/server.log | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python-api/server.log b/python-api/server.log index 5eac220..d2d2378 100644 --- a/python-api/server.log +++ b/python-api/server.log @@ -15,5 +15,8 @@ 2024-01-15 08:14:03 INFO Alert sent to monitoring team via Azure Monitor 2024-01-15 08:15:00 INFO Scheduled maintenance check completed 2024-01-15 08:16:30 WARNING SSL certificate expires in 14 days for api.azuretech.fr +2024-01-15 08:18:00 CRITICAL Database connection pool exhausted — all 20 connections in use 2024-01-15 08:18:55 INFO Kubernetes pod restarted: api-deployment-7d9f8b-xkp2m +2024-01-15 08:19:30 CRITICAL Azure Key Vault unreachable — secrets cannot be retrieved 2024-01-15 08:20:00 INFO Health check passed: all 3 replicas running +2024-01-15 08:21:00 CRITICAL Disk full on /var/log — logging suspended From 0813a16c08ac7139f63640c0b524446718d2a7c6 Mon Sep 17 00:00:00 2001 From: NathanTesseyre Date: Fri, 22 May 2026 11:07:19 +0200 Subject: [PATCH 2/6] feat: update parse_logs function to add critical errors --- python-api/app.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python-api/app.py b/python-api/app.py index bc7c4b5..07a3b3a 100644 --- a/python-api/app.py +++ b/python-api/app.py @@ -15,6 +15,7 @@ # ------------------------------------------------------- def parse_logs(filepath): + criticals = [] errors = [] warnings = [] infos = [] @@ -24,7 +25,9 @@ def parse_logs(filepath): line = line.strip() if not line: continue - if "ERROR" in line: + if "CRITICAL" in line: + criticals.append(line) + elif "ERROR" in line: errors.append(line) elif "WARNING" in line: warnings.append(line) @@ -32,9 +35,11 @@ def parse_logs(filepath): infos.append(line) return { + "critical_count": len(criticals), "error_count": len(errors), "warning_count": len(warnings), "info_count": len(infos), + "criticals": criticals, "errors": errors, "warnings": warnings } From def74afb18bf7d946fa2f9d891a706225cf76390 Mon Sep 17 00:00:00 2001 From: NathanTesseyre Date: Fri, 22 May 2026 11:35:55 +0200 Subject: [PATCH 3/6] refactor: improve maintainability of get_stats function --- python-api/app.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/python-api/app.py b/python-api/app.py index 07a3b3a..be28a94 100644 --- a/python-api/app.py +++ b/python-api/app.py @@ -50,6 +50,25 @@ def get_logs(): result = parse_logs(config["api"]["log_file"]) return jsonify(result), 200 +@app.route("/api/stats", methods=["GET"]) +def get_stats(): + + result = parse_logs(config["api"]["log_file"]) + + critical_count = result["critical_count"] + errors_count = result["errors_count"] + warning_count = result["warning_count"] + infos_count = result["infos_count"] + + total = critical_count + error_count + warning_count + info_count + + return jsonify({ + "critical_count": critical_count, + "error_count": error_count, + "warning_count": warning_count, + "info_count": info_count, + "total": total + }), 200 if __name__ == "__main__": app.run(debug=True, port=config["api"]["port"]) From 408796584d8c1832bb691427da501886a5ecbaf7 Mon Sep 17 00:00:00 2001 From: NathanTesseyre Date: Fri, 22 May 2026 11:40:58 +0200 Subject: [PATCH 4/6] feat: update getLogs function to display critical errors --- node-client/app.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/node-client/app.js b/node-client/app.js index 47cf0a2..9dbdc41 100644 --- a/node-client/app.js +++ b/node-client/app.js @@ -18,13 +18,22 @@ async function getLogs() { console.log('\n========================================'); console.log(' RAPPORT D\'ANALYSE DES LOGS AZURE '); console.log('========================================'); + if (data.critical_count > 0) { + console.log(` !! CRITIQUE !! : ${data.critical_count}`); + } console.log(` Erreurs detectees : ${data.error_count}`); console.log(` Avertissements : ${data.warning_count}`); console.log(` Messages info : ${data.info_count}`); + + if (data.criticals && data.criticals.length > 0) { + console.log('\n--- Incidents critiques ---'); + data.criticals.forEach(c => console.log(` !! ${c}`)); + } console.log('\n--- Detail des erreurs ---'); data.errors.forEach(err => console.log(` > ${err}`)); console.log('\n--- Detail des avertissements ---'); data.warnings.forEach(warn => console.log(` > ${warn}`)); + console.log('========================================\n'); } catch (error) { From d3d8b9331b28ad45df407c0e63f9e088d562f9d4 Mon Sep 17 00:00:00 2001 From: NathanTesseyre Date: Fri, 22 May 2026 12:26:31 +0200 Subject: [PATCH 5/6] style: remove blank line --- node-client/app.js | 1 - 1 file changed, 1 deletion(-) diff --git a/node-client/app.js b/node-client/app.js index 9dbdc41..5c25fba 100644 --- a/node-client/app.js +++ b/node-client/app.js @@ -33,7 +33,6 @@ async function getLogs() { data.errors.forEach(err => console.log(` > ${err}`)); console.log('\n--- Detail des avertissements ---'); data.warnings.forEach(warn => console.log(` > ${warn}`)); - console.log('========================================\n'); } catch (error) { From 0141791422e31f6e7aea7c359d8b578cba616100 Mon Sep 17 00:00:00 2001 From: NathanTesseyre Date: Fri, 22 May 2026 16:17:26 +0200 Subject: [PATCH 6/6] fix: typos in js keys --- python-api/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python-api/app.py b/python-api/app.py index be28a94..4e93e99 100644 --- a/python-api/app.py +++ b/python-api/app.py @@ -56,9 +56,9 @@ def get_stats(): result = parse_logs(config["api"]["log_file"]) critical_count = result["critical_count"] - errors_count = result["errors_count"] + error_count = result["error_count"] warning_count = result["warning_count"] - infos_count = result["infos_count"] + info_count = result["info_count"] total = critical_count + error_count + warning_count + info_count