155 أسطر
5.0 KiB
HTML
155 أسطر
5.0 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="ar" dir="rtl">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>مراقبة تطبيق غيمة - SRE</title>
|
|
<style>
|
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
body {
|
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
background-color: #f0f2f5;
|
|
color: #333;
|
|
padding: 40px 20px;
|
|
}
|
|
.container {
|
|
max-width: 800px;
|
|
margin: 0 auto;
|
|
background: #fff;
|
|
padding: 30px;
|
|
border-radius: 12px;
|
|
box-shadow: 0 8px 16px rgba(0,0,0,0.05);
|
|
}
|
|
h1 {
|
|
text-align: center;
|
|
margin-bottom: 30px;
|
|
color: #1a1a1a;
|
|
border-bottom: 2px solid #e4e6eb;
|
|
padding-bottom: 10px;
|
|
}
|
|
|
|
.metrics-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
gap: 20px;
|
|
margin-bottom: 30px;
|
|
}
|
|
.metric-card {
|
|
background: #f8f9fa;
|
|
padding: 25px 20px;
|
|
border-radius: 8px;
|
|
text-align: center;
|
|
border-top: 4px solid #6c757d;
|
|
transition: all 0.3s ease;
|
|
}
|
|
.metric-card h3 {
|
|
font-size: 16px;
|
|
color: #6c757d;
|
|
margin-bottom: 10px;
|
|
}
|
|
.metric-value {
|
|
font-size: 32px;
|
|
font-weight: bold;
|
|
color: #212529;
|
|
}
|
|
|
|
.status-up { border-top-color: #10b981; }
|
|
.status-up .metric-value { color: #10b981; }
|
|
|
|
.status-down { border-top-color: #ef4444; }
|
|
.status-down .metric-value { color: #ef4444; }
|
|
|
|
.footer {
|
|
text-align: center;
|
|
font-size: 14px;
|
|
color: #6c757d;
|
|
margin-top: 20px;
|
|
}
|
|
#last-updated { font-weight: bold; }
|
|
|
|
#error-msg {
|
|
display: none;
|
|
background: #fee2e2;
|
|
color: #b91c1c;
|
|
padding: 10px;
|
|
text-align: center;
|
|
border-radius: 6px;
|
|
margin-bottom: 20px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="container">
|
|
<h1>لوحة المراقبة (SRE Dashboard)</h1>
|
|
|
|
<div id="error-msg">فشل في الاتصال بملف البيانات (metrics.json)</div>
|
|
|
|
<div class="metrics-grid">
|
|
<div class="metric-card" id="card-status">
|
|
<h3>حالة التطبيق</h3>
|
|
<div class="metric-value" id="val-status">جاري...</div>
|
|
</div>
|
|
|
|
<div class="metric-card">
|
|
<h3>زمن الاستجابة (Latency)</h3>
|
|
<div class="metric-value" id="val-latency">0 <span style="font-size:16px; color:#6c757d;">ms</span></div>
|
|
</div>
|
|
|
|
<div class="metric-card">
|
|
<h3>إجمالي الطلبات</h3>
|
|
<div class="metric-value" id="val-requests">0</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="footer">
|
|
آخر تحديث للبيانات: <span id="last-updated">--:--:--</span>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
async function fetchMetrics() {
|
|
try {
|
|
const response = await fetch('metrics.json?t=' + new Date().getTime());
|
|
|
|
if (!response.ok) {
|
|
throw new Error('Network response was not ok');
|
|
}
|
|
|
|
const data = await response.json();
|
|
|
|
|
|
document.getElementById('error-msg').style.display = 'none';
|
|
|
|
const statusEl = document.getElementById('val-status');
|
|
const statusCard = document.getElementById('card-status');
|
|
|
|
statusEl.innerText = data.status;
|
|
if (data.status === 'Healthy') {
|
|
statusCard.className = 'metric-card status-up';
|
|
} else {
|
|
statusCard.className = 'metric-card status-down';
|
|
}
|
|
|
|
|
|
document.getElementById('val-latency').innerHTML = `${data.latency_ms} <span style="font-size:16px; color:#6c757d;">ms</span>`;
|
|
document.getElementById('val-requests').innerText = data.total_requests;
|
|
|
|
|
|
const localTime = new Date(data.timestamp).toLocaleTimeString('ar-EG');
|
|
document.getElementById('last-updated').innerText = localTime;
|
|
|
|
} catch (error) {
|
|
console.error("Error fetching metrics:", error);
|
|
document.getElementById('error-msg').style.display = 'block';
|
|
document.getElementById('val-status').innerText = 'غير متصل';
|
|
document.getElementById('card-status').className = 'metric-card status-down';
|
|
}
|
|
}
|
|
|
|
fetchMetrics();
|
|
|
|
setInterval(fetchMetrics, 5000);
|
|
</script>
|
|
</body>
|
|
</html> |