Spaces:
Sleeping
Sleeping
Initial Commit
Browse files- README.md +67 -10
- app.py +352 -0
- requirements.txt +5 -0
README.md
CHANGED
|
@@ -1,12 +1,69 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
-
|
|
|
|
| 1 |
+
# ๐ฎ DevOps Fortune Teller
|
| 2 |
+
|
| 3 |
+
AI-Powered Predictive Log Analysis for DevOps Teams
|
| 4 |
+
|
| 5 |
+
## ๐ What Does It Do?
|
| 6 |
+
|
| 7 |
+
DevOps Fortune Teller analyzes your deployment and application logs to **predict potential issues before they escalate**. Instead of just reading logs, it uses AI to detect patterns and forecast problems.
|
| 8 |
+
|
| 9 |
+
## โจ Features
|
| 10 |
+
|
| 11 |
+
- ๐ค **AI-Powered Analysis**: Uses transformer-based sentiment analysis
|
| 12 |
+
- ๐ฏ **Pattern Detection**: Identifies memory issues, connection problems, performance degradation, and more
|
| 13 |
+
- ๐ **Health Scoring**: Get an instant health score for your deployment
|
| 14 |
+
- ๐ฎ **Predictive Insights**: Forecasts issues 2-4 hours before they become critical
|
| 15 |
+
- ๐ก **Actionable Recommendations**: Get specific advice on how to fix detected issues
|
| 16 |
+
|
| 17 |
+
## ๐จ What Makes It Unique?
|
| 18 |
+
|
| 19 |
+
Unlike traditional log viewers, this tool:
|
| 20 |
+
- Treats logs as **predictive data** rather than just historical records
|
| 21 |
+
- Uses **AI sentiment analysis** to gauge system health
|
| 22 |
+
- Provides **confidence scores** on predictions
|
| 23 |
+
- Suggests **proactive actions** to prevent failures
|
| 24 |
+
|
| 25 |
+
## ๐ Supported Log Patterns
|
| 26 |
+
|
| 27 |
+
The tool detects:
|
| 28 |
+
- Memory pressure and OOM risks
|
| 29 |
+
- Connection timeouts and network issues
|
| 30 |
+
- Performance degradation (slow queries, high CPU)
|
| 31 |
+
- Lock contention and deadlocks
|
| 32 |
+
- Disk space exhaustion
|
| 33 |
+
- Cascading timeout failures
|
| 34 |
+
|
| 35 |
+
## ๐ง How to Use
|
| 36 |
+
|
| 37 |
+
1. Paste your logs (supports standard ERROR/WARN/INFO formats)
|
| 38 |
+
2. Click "Predict Issues"
|
| 39 |
+
3. Review predictions, health score, and recommendations
|
| 40 |
+
4. Take action before problems escalate!
|
| 41 |
+
|
| 42 |
+
## ๐ Example Log Format
|
| 43 |
+
|
| 44 |
+
```
|
| 45 |
+
2026-01-10 14:23:45 INFO Deployment started
|
| 46 |
+
2026-01-10 14:23:47 WARN Memory usage at 78%
|
| 47 |
+
2026-01-10 14:24:01 ERROR Connection timeout
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
## ๐ ๏ธ Tech Stack
|
| 51 |
+
|
| 52 |
+
- **Gradio**: Beautiful web interface
|
| 53 |
+
- **Transformers**: AI-powered sentiment analysis
|
| 54 |
+
- **Pattern Recognition**: Custom algorithms for DevOps-specific issues
|
| 55 |
+
|
| 56 |
+
## ๐ฏ Perfect For
|
| 57 |
+
|
| 58 |
+
- Post-deployment health checks
|
| 59 |
+
- Production incident investigation
|
| 60 |
+
- Proactive monitoring
|
| 61 |
+
- Team standups and retrospectives
|
| 62 |
+
|
| 63 |
+
## ๐ License
|
| 64 |
+
|
| 65 |
+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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# app.py
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
import re
|
| 5 |
+
from datetime import datetime, timedelta
|
| 6 |
+
import torch
|
| 7 |
+
|
| 8 |
+
# Initialize sentiment analysis pipeline
|
| 9 |
+
try:
|
| 10 |
+
sentiment_analyzer = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")
|
| 11 |
+
except:
|
| 12 |
+
sentiment_analyzer = None
|
| 13 |
+
|
| 14 |
+
def extract_log_level(line):
|
| 15 |
+
"""Extract log level from line"""
|
| 16 |
+
if 'ERROR' in line.upper():
|
| 17 |
+
return 'ERROR'
|
| 18 |
+
elif 'WARN' in line.upper() or 'WARNING' in line.upper():
|
| 19 |
+
return 'WARN'
|
| 20 |
+
elif 'INFO' in line.upper():
|
| 21 |
+
return 'INFO'
|
| 22 |
+
elif 'DEBUG' in line.upper():
|
| 23 |
+
return 'DEBUG'
|
| 24 |
+
else:
|
| 25 |
+
return 'UNKNOWN'
|
| 26 |
+
|
| 27 |
+
def analyze_patterns(lines):
|
| 28 |
+
"""Detect patterns in logs"""
|
| 29 |
+
patterns = {
|
| 30 |
+
'memory_issues': False,
|
| 31 |
+
'connection_issues': False,
|
| 32 |
+
'performance_issues': False,
|
| 33 |
+
'lock_issues': False,
|
| 34 |
+
'disk_issues': False,
|
| 35 |
+
'timeout_issues': False
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
keywords = {
|
| 39 |
+
'memory_issues': ['memory', 'oom', 'heap', 'ram'],
|
| 40 |
+
'connection_issues': ['connection', 'timeout', 'refused', 'unreachable'],
|
| 41 |
+
'performance_issues': ['slow', 'cpu', 'performance', 'latency'],
|
| 42 |
+
'lock_issues': ['lock', 'deadlock', 'blocked'],
|
| 43 |
+
'disk_issues': ['disk', 'storage', 'space', 'inode'],
|
| 44 |
+
'timeout_issues': ['timeout', 'timed out', 'deadline exceeded']
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
for line in lines:
|
| 48 |
+
line_lower = line.lower()
|
| 49 |
+
for pattern_type, pattern_keywords in keywords.items():
|
| 50 |
+
if any(keyword in line_lower for keyword in pattern_keywords):
|
| 51 |
+
patterns[pattern_type] = True
|
| 52 |
+
|
| 53 |
+
return patterns
|
| 54 |
+
|
| 55 |
+
def generate_predictions(error_count, warn_count, patterns, sentiment_score):
|
| 56 |
+
"""Generate predictions based on analysis"""
|
| 57 |
+
predictions = []
|
| 58 |
+
|
| 59 |
+
# Memory issues prediction
|
| 60 |
+
if patterns['memory_issues'] and warn_count > 0:
|
| 61 |
+
confidence = min(95, 70 + (warn_count * 5))
|
| 62 |
+
predictions.append({
|
| 63 |
+
'icon': 'โ ๏ธ',
|
| 64 |
+
'type': 'warning',
|
| 65 |
+
'title': 'Memory Pressure Detected',
|
| 66 |
+
'message': f'Based on memory warnings, pod restart likely within 2-4 hours if load increases. Consider scaling horizontally or increasing memory limits.',
|
| 67 |
+
'confidence': confidence,
|
| 68 |
+
'action': 'Review memory usage metrics and consider pod autoscaling'
|
| 69 |
+
})
|
| 70 |
+
|
| 71 |
+
# Connection issues prediction
|
| 72 |
+
if patterns['connection_issues']:
|
| 73 |
+
confidence = min(95, 75 + (error_count * 3))
|
| 74 |
+
predictions.append({
|
| 75 |
+
'icon': '๐ด',
|
| 76 |
+
'type': 'critical',
|
| 77 |
+
'title': 'Connection Instability',
|
| 78 |
+
'message': 'Database/service connection issues may cascade to dependent services. Network or connection pool exhaustion detected.',
|
| 79 |
+
'confidence': confidence,
|
| 80 |
+
'action': 'Check connection pool settings and network stability'
|
| 81 |
+
})
|
| 82 |
+
|
| 83 |
+
# Performance degradation
|
| 84 |
+
if patterns['performance_issues']:
|
| 85 |
+
confidence = min(90, 65 + (warn_count * 4))
|
| 86 |
+
predictions.append({
|
| 87 |
+
'icon': 'โ ๏ธ',
|
| 88 |
+
'type': 'warning',
|
| 89 |
+
'title': 'Performance Degradation',
|
| 90 |
+
'message': 'Slow queries or high CPU detected. Performance will likely degrade further under increased load.',
|
| 91 |
+
'confidence': confidence,
|
| 92 |
+
'action': 'Optimize queries and review resource allocation'
|
| 93 |
+
})
|
| 94 |
+
|
| 95 |
+
# Lock/Deadlock issues
|
| 96 |
+
if patterns['lock_issues']:
|
| 97 |
+
confidence = min(85, 60 + (error_count * 5))
|
| 98 |
+
predictions.append({
|
| 99 |
+
'icon': '๐ด',
|
| 100 |
+
'type': 'critical',
|
| 101 |
+
'title': 'Resource Contention',
|
| 102 |
+
'message': 'Lock acquisition failures suggest possible deadlock scenario. Transaction conflicts detected.',
|
| 103 |
+
'confidence': confidence,
|
| 104 |
+
'action': 'Review transaction isolation levels and locking strategy'
|
| 105 |
+
})
|
| 106 |
+
|
| 107 |
+
# Disk issues
|
| 108 |
+
if patterns['disk_issues']:
|
| 109 |
+
confidence = min(90, 70 + (error_count * 4))
|
| 110 |
+
predictions.append({
|
| 111 |
+
'icon': '๐ด',
|
| 112 |
+
'type': 'critical',
|
| 113 |
+
'title': 'Disk Space Warning',
|
| 114 |
+
'message': 'Disk space or inode exhaustion detected. Service interruption imminent if not addressed.',
|
| 115 |
+
'confidence': confidence,
|
| 116 |
+
'action': 'Clean up logs and temporary files, expand storage'
|
| 117 |
+
})
|
| 118 |
+
|
| 119 |
+
# Timeout cascade prediction
|
| 120 |
+
if patterns['timeout_issues'] and error_count > 2:
|
| 121 |
+
confidence = min(88, 68 + (error_count * 3))
|
| 122 |
+
predictions.append({
|
| 123 |
+
'icon': 'โ ๏ธ',
|
| 124 |
+
'type': 'warning',
|
| 125 |
+
'title': 'Timeout Cascade Risk',
|
| 126 |
+
'message': 'Multiple timeout events detected. This pattern often leads to cascading failures across microservices.',
|
| 127 |
+
'confidence': confidence,
|
| 128 |
+
'action': 'Increase timeout thresholds or implement circuit breakers'
|
| 129 |
+
})
|
| 130 |
+
|
| 131 |
+
# All clear
|
| 132 |
+
if not predictions and error_count == 0:
|
| 133 |
+
predictions.append({
|
| 134 |
+
'icon': 'โ
',
|
| 135 |
+
'type': 'success',
|
| 136 |
+
'title': 'All Systems Nominal',
|
| 137 |
+
'message': 'No concerning patterns detected. Your deployment looks healthy! Keep monitoring.',
|
| 138 |
+
'confidence': 95,
|
| 139 |
+
'action': 'Continue normal operations'
|
| 140 |
+
})
|
| 141 |
+
|
| 142 |
+
return predictions
|
| 143 |
+
|
| 144 |
+
def calculate_health_score(error_count, warn_count, info_count, sentiment_score):
|
| 145 |
+
"""Calculate overall health score"""
|
| 146 |
+
base_score = 100
|
| 147 |
+
|
| 148 |
+
# Deduct points for errors and warnings
|
| 149 |
+
base_score -= error_count * 15
|
| 150 |
+
base_score -= warn_count * 5
|
| 151 |
+
|
| 152 |
+
# Factor in sentiment if available
|
| 153 |
+
if sentiment_score is not None:
|
| 154 |
+
base_score = base_score * 0.7 + sentiment_score * 0.3
|
| 155 |
+
|
| 156 |
+
return max(0, min(100, base_score))
|
| 157 |
+
|
| 158 |
+
def analyze_sentiment(lines):
|
| 159 |
+
"""Analyze sentiment of log messages"""
|
| 160 |
+
if not sentiment_analyzer:
|
| 161 |
+
return None
|
| 162 |
+
|
| 163 |
+
try:
|
| 164 |
+
# Extract message content (remove timestamps and log levels)
|
| 165 |
+
messages = []
|
| 166 |
+
for line in lines:
|
| 167 |
+
# Remove common log prefixes
|
| 168 |
+
cleaned = re.sub(r'^\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}', '', line)
|
| 169 |
+
cleaned = re.sub(r'^(ERROR|WARN|WARNING|INFO|DEBUG)', '', cleaned)
|
| 170 |
+
cleaned = cleaned.strip()
|
| 171 |
+
if cleaned and len(cleaned) > 10:
|
| 172 |
+
messages.append(cleaned[:512]) # Limit length
|
| 173 |
+
|
| 174 |
+
if not messages:
|
| 175 |
+
return None
|
| 176 |
+
|
| 177 |
+
# Analyze sentiment (take average)
|
| 178 |
+
results = sentiment_analyzer(messages[:20]) # Limit to avoid timeout
|
| 179 |
+
|
| 180 |
+
positive_count = sum(1 for r in results if r['label'] == 'POSITIVE')
|
| 181 |
+
sentiment_score = (positive_count / len(results)) * 100
|
| 182 |
+
|
| 183 |
+
return sentiment_score
|
| 184 |
+
except:
|
| 185 |
+
return None
|
| 186 |
+
|
| 187 |
+
def format_prediction_html(predictions):
|
| 188 |
+
"""Format predictions as HTML"""
|
| 189 |
+
html = ""
|
| 190 |
+
for pred in predictions:
|
| 191 |
+
color = {
|
| 192 |
+
'critical': '#ef4444',
|
| 193 |
+
'warning': '#f59e0b',
|
| 194 |
+
'success': '#10b981'
|
| 195 |
+
}.get(pred['type'], '#6b7280')
|
| 196 |
+
|
| 197 |
+
html += f"""
|
| 198 |
+
<div style="border-left: 4px solid {color}; padding: 12px; margin: 10px 0; background: #f9fafb; border-radius: 4px;">
|
| 199 |
+
<div style="font-size: 18px; margin-bottom: 4px;">{pred['icon']} <strong>{pred['title']}</strong></div>
|
| 200 |
+
<div style="color: #4b5563; margin-bottom: 8px;">{pred['message']}</div>
|
| 201 |
+
<div style="font-size: 12px; color: #6b7280;">
|
| 202 |
+
<strong>Confidence:</strong> {pred['confidence']}% |
|
| 203 |
+
<strong>Action:</strong> {pred['action']}
|
| 204 |
+
</div>
|
| 205 |
+
</div>
|
| 206 |
+
"""
|
| 207 |
+
return html
|
| 208 |
+
|
| 209 |
+
def analyze_logs(log_text):
|
| 210 |
+
"""Main analysis function"""
|
| 211 |
+
if not log_text.strip():
|
| 212 |
+
return "โ ๏ธ Please paste some logs to analyze", "", ""
|
| 213 |
+
|
| 214 |
+
lines = [line.strip() for line in log_text.split('\n') if line.strip()]
|
| 215 |
+
|
| 216 |
+
# Count log levels
|
| 217 |
+
error_count = sum(1 for line in lines if extract_log_level(line) == 'ERROR')
|
| 218 |
+
warn_count = sum(1 for line in lines if extract_log_level(line) == 'WARN')
|
| 219 |
+
info_count = sum(1 for line in lines if extract_log_level(line) == 'INFO')
|
| 220 |
+
|
| 221 |
+
# Analyze patterns
|
| 222 |
+
patterns = analyze_patterns(lines)
|
| 223 |
+
|
| 224 |
+
# Sentiment analysis
|
| 225 |
+
sentiment_score = analyze_sentiment(lines)
|
| 226 |
+
|
| 227 |
+
# Calculate health score
|
| 228 |
+
health_score = calculate_health_score(error_count, warn_count, info_count, sentiment_score)
|
| 229 |
+
|
| 230 |
+
# Generate predictions
|
| 231 |
+
predictions = generate_predictions(error_count, warn_count, patterns, sentiment_score)
|
| 232 |
+
|
| 233 |
+
# Format summary
|
| 234 |
+
health_color = '#10b981' if health_score > 75 else '#f59e0b' if health_score > 50 else '#ef4444'
|
| 235 |
+
|
| 236 |
+
summary = f"""
|
| 237 |
+
<div style="padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 8px; color: white;">
|
| 238 |
+
<h2 style="margin: 0 0 10px 0;">๐ฎ DevOps Fortune Teller Analysis</h2>
|
| 239 |
+
<div style="font-size: 14px; opacity: 0.9;">AI-Powered Predictive Log Analysis</div>
|
| 240 |
+
</div>
|
| 241 |
+
|
| 242 |
+
<div style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 20px 0;">
|
| 243 |
+
<div style="background: #fee2e2; padding: 15px; border-radius: 8px; text-align: center;">
|
| 244 |
+
<div style="font-size: 24px; font-weight: bold; color: #dc2626;">{error_count}</div>
|
| 245 |
+
<div style="color: #991b1b; font-size: 12px;">Errors</div>
|
| 246 |
+
</div>
|
| 247 |
+
<div style="background: #fef3c7; padding: 15px; border-radius: 8px; text-align: center;">
|
| 248 |
+
<div style="font-size: 24px; font-weight: bold; color: #d97706;">{warn_count}</div>
|
| 249 |
+
<div style="color: #92400e; font-size: 12px;">Warnings</div>
|
| 250 |
+
</div>
|
| 251 |
+
<div style="background: #dbeafe; padding: 15px; border-radius: 8px; text-align: center;">
|
| 252 |
+
<div style="font-size: 24px; font-weight: bold; color: #2563eb;">{info_count}</div>
|
| 253 |
+
<div style="color: #1e40af; font-size: 12px;">Info</div>
|
| 254 |
+
</div>
|
| 255 |
+
<div style="background: {health_color}20; padding: 15px; border-radius: 8px; text-align: center;">
|
| 256 |
+
<div style="font-size: 24px; font-weight: bold; color: {health_color};">{health_score}%</div>
|
| 257 |
+
<div style="color: #374151; font-size: 12px;">Health Score</div>
|
| 258 |
+
</div>
|
| 259 |
+
</div>
|
| 260 |
+
"""
|
| 261 |
+
|
| 262 |
+
# Format patterns detected
|
| 263 |
+
patterns_html = "<h3>๐ Patterns Detected:</h3><ul style='color: #4b5563;'>"
|
| 264 |
+
pattern_names = {
|
| 265 |
+
'memory_issues': 'Memory Pressure',
|
| 266 |
+
'connection_issues': 'Connection Problems',
|
| 267 |
+
'performance_issues': 'Performance Issues',
|
| 268 |
+
'lock_issues': 'Lock Contention',
|
| 269 |
+
'disk_issues': 'Disk Space Issues',
|
| 270 |
+
'timeout_issues': 'Timeout Events'
|
| 271 |
+
}
|
| 272 |
+
detected = [pattern_names[k] for k, v in patterns.items() if v]
|
| 273 |
+
if detected:
|
| 274 |
+
for pattern in detected:
|
| 275 |
+
patterns_html += f"<li>{pattern}</li>"
|
| 276 |
+
else:
|
| 277 |
+
patterns_html += "<li>No critical patterns detected</li>"
|
| 278 |
+
patterns_html += "</ul>"
|
| 279 |
+
|
| 280 |
+
# Format predictions
|
| 281 |
+
predictions_html = "<h3>๐ฏ Predictions & Recommendations:</h3>" + format_prediction_html(predictions)
|
| 282 |
+
|
| 283 |
+
return summary, patterns_html, predictions_html
|
| 284 |
+
|
| 285 |
+
# Sample logs for demo
|
| 286 |
+
sample_logs = """2026-01-10 14:23:45 INFO Deployment started for service-auth v2.1.0
|
| 287 |
+
2026-01-10 14:23:47 WARN Memory usage at 78% on pod-auth-3
|
| 288 |
+
2026-01-10 14:23:50 INFO Health check passed for 3/3 pods
|
| 289 |
+
2026-01-10 14:24:01 ERROR Connection timeout to database cluster db-primary
|
| 290 |
+
2026-01-10 14:24:02 INFO Retrying connection (attempt 1/3)
|
| 291 |
+
2026-01-10 14:24:05 WARN Slow query detected: SELECT * FROM users WHERE status='active' (2.3s)
|
| 292 |
+
2026-01-10 14:24:08 ERROR Connection timeout to database cluster db-primary
|
| 293 |
+
2026-01-10 14:24:10 INFO Connection restored to db-primary
|
| 294 |
+
2026-01-10 14:24:15 ERROR Failed to acquire lock on resource user_session_123
|
| 295 |
+
2026-01-10 14:24:18 WARN High CPU usage detected: 89% on pod-auth-2
|
| 296 |
+
2026-01-10 14:24:20 INFO Processing queue: 1247 items pending
|
| 297 |
+
2026-01-10 14:24:25 ERROR Disk space warning: /var/log at 92% capacity
|
| 298 |
+
2026-01-10 14:24:30 WARN Response time degradation: p95 latency 1.8s (threshold: 1.0s)"""
|
| 299 |
+
|
| 300 |
+
# Create Gradio interface
|
| 301 |
+
with gr.Blocks(theme=gr.themes.Soft(), title="DevOps Fortune Teller") as demo:
|
| 302 |
+
gr.Markdown("""
|
| 303 |
+
# ๐ฎ DevOps Fortune Teller
|
| 304 |
+
### AI-Powered Predictive Log Analysis for DevOps
|
| 305 |
+
Paste your deployment, application, or error logs below and get AI-powered predictions about potential issues before they escalate.
|
| 306 |
+
""")
|
| 307 |
+
|
| 308 |
+
with gr.Row():
|
| 309 |
+
with gr.Column(scale=1):
|
| 310 |
+
log_input = gr.Textbox(
|
| 311 |
+
label="๐ Paste Your Logs Here",
|
| 312 |
+
placeholder="Paste your logs here (supports standard formats with ERROR, WARN, INFO levels)...",
|
| 313 |
+
lines=15,
|
| 314 |
+
max_lines=20
|
| 315 |
+
)
|
| 316 |
+
|
| 317 |
+
with gr.Row():
|
| 318 |
+
analyze_btn = gr.Button("๐ฎ Predict Issues", variant="primary", size="lg")
|
| 319 |
+
sample_btn = gr.Button("๐ Load Sample Logs", size="lg")
|
| 320 |
+
|
| 321 |
+
with gr.Column(scale=1):
|
| 322 |
+
summary_output = gr.HTML(label="Summary")
|
| 323 |
+
patterns_output = gr.HTML(label="Patterns")
|
| 324 |
+
predictions_output = gr.HTML(label="Predictions")
|
| 325 |
+
|
| 326 |
+
gr.Markdown("""
|
| 327 |
+
---
|
| 328 |
+
### ๐ฏ How It Works
|
| 329 |
+
This tool uses transformer-based sentiment analysis combined with pattern recognition to:
|
| 330 |
+
- Detect concerning patterns in your logs
|
| 331 |
+
- Predict potential issues before they become critical
|
| 332 |
+
- Provide actionable recommendations
|
| 333 |
+
- Calculate a health score for your deployment
|
| 334 |
+
|
| 335 |
+
**Supported Log Levels:** ERROR, WARN/WARNING, INFO, DEBUG
|
| 336 |
+
""")
|
| 337 |
+
|
| 338 |
+
# Button actions
|
| 339 |
+
analyze_btn.click(
|
| 340 |
+
fn=analyze_logs,
|
| 341 |
+
inputs=[log_input],
|
| 342 |
+
outputs=[summary_output, patterns_output, predictions_output]
|
| 343 |
+
)
|
| 344 |
+
|
| 345 |
+
sample_btn.click(
|
| 346 |
+
fn=lambda: sample_logs,
|
| 347 |
+
outputs=[log_input]
|
| 348 |
+
)
|
| 349 |
+
|
| 350 |
+
# Launch the app
|
| 351 |
+
if __name__ == "__main__":
|
| 352 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio==4.44.0
|
| 2 |
+
transformers==4.36.2
|
| 3 |
+
torch==2.1.2
|
| 4 |
+
sentencepiece==0.1.99
|
| 5 |
+
protobuf==3.20.3
|