Fix jwt-token
This commit is contained in:
@@ -40,17 +40,25 @@ const Alerts = () => {
|
||||
|
||||
const fetchAlertData = async () => {
|
||||
try {
|
||||
console.log('🔄 Fetching alerts data...');
|
||||
|
||||
const [rulesRes, logsRes, statsRes] = await Promise.all([
|
||||
api.get('/alerts/rules'),
|
||||
api.get('/alerts/logs?limit=50'),
|
||||
api.get('/alerts/stats?hours=24')
|
||||
]);
|
||||
|
||||
console.log('📊 API Responses:', {
|
||||
rules: rulesRes.data,
|
||||
logs: logsRes.data,
|
||||
stats: statsRes.data
|
||||
});
|
||||
|
||||
setAlertRules(rulesRes.data?.data || []);
|
||||
setAlertLogs(logsRes.data?.data || []);
|
||||
setAlertStats(statsRes.data?.data || null);
|
||||
} catch (error) {
|
||||
console.error('Error fetching alert data:', error);
|
||||
console.error('❌ Error fetching alert data:', error);
|
||||
// Set default values on error
|
||||
setAlertRules([]);
|
||||
setAlertLogs([]);
|
||||
@@ -71,6 +79,17 @@ const Alerts = () => {
|
||||
alertStats: alertStats ? 'present' : 'null',
|
||||
invalidRules: alertRules?.filter(rule => typeof rule.alert_channels === 'object' && !Array.isArray(rule.alert_channels))
|
||||
});
|
||||
|
||||
// Check for any objects containing the problematic keys
|
||||
alertRules?.forEach((rule, index) => {
|
||||
if (rule.alert_channels && typeof rule.alert_channels === 'object') {
|
||||
const keys = Object.keys(rule.alert_channels);
|
||||
const hasProblematicKeys = ['sms', 'webhook', 'email'].some(key => keys.includes(key));
|
||||
if (hasProblematicKeys) {
|
||||
console.warn(`🚨 Rule ${index} has object alert_channels:`, rule.alert_channels);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, [alertRules, alertLogs, alertStats]);
|
||||
|
||||
// Group alerts by alert_event_id to show related alerts together
|
||||
|
||||
Reference in New Issue
Block a user