pangu-rca 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pangu_rca-0.1.0/PKG-INFO +125 -0
- pangu_rca-0.1.0/README.md +95 -0
- pangu_rca-0.1.0/pangu_rca/__init__.py +5 -0
- pangu_rca-0.1.0/pangu_rca/cli.py +262 -0
- pangu_rca-0.1.0/pangu_rca.egg-info/PKG-INFO +125 -0
- pangu_rca-0.1.0/pangu_rca.egg-info/SOURCES.txt +11 -0
- pangu_rca-0.1.0/pangu_rca.egg-info/dependency_links.txt +1 -0
- pangu_rca-0.1.0/pangu_rca.egg-info/entry_points.txt +2 -0
- pangu_rca-0.1.0/pangu_rca.egg-info/requires.txt +1 -0
- pangu_rca-0.1.0/pangu_rca.egg-info/top_level.txt +1 -0
- pangu_rca-0.1.0/pyproject.toml +39 -0
- pangu_rca-0.1.0/setup.cfg +4 -0
- pangu_rca-0.1.0/setup.py +37 -0
pangu_rca-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pangu-rca
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pangu RCA CLI - AI-powered log analysis tool
|
|
5
|
+
Home-page: https://www.pangulab.com
|
|
6
|
+
Author: Pangulab Team
|
|
7
|
+
Author-email: Pangulab Team <r00txxyyzz@gmail.com>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://www.pangulab.com
|
|
10
|
+
Project-URL: Source, https://github.com/halokid/TronRabbit
|
|
11
|
+
Keywords: log analysis,AI,root cause analysis,debugging,devtools
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Topic :: Software Development :: Debuggers
|
|
15
|
+
Classifier: Topic :: System :: Logging
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Requires-Python: >=3.7
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
Requires-Dist: requests>=2.25.0
|
|
27
|
+
Dynamic: author
|
|
28
|
+
Dynamic: home-page
|
|
29
|
+
Dynamic: requires-python
|
|
30
|
+
|
|
31
|
+
# Pangu RCA CLI
|
|
32
|
+
|
|
33
|
+
[](https://pypi.org/project/pangu-rca/)
|
|
34
|
+
[](https://pypi.org/project/pangu-rca/)
|
|
35
|
+
[](https://github.com/halokid/TronRabbit/blob/main/LICENSE)
|
|
36
|
+
|
|
37
|
+
**AI-powered log analysis tool for developers.** Analyze error logs directly from your terminal.
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install pangu-rca
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Analyze a log file
|
|
49
|
+
pangu-rca analyze error.log
|
|
50
|
+
|
|
51
|
+
# Analyze with English output
|
|
52
|
+
pangu-rca analyze error.log --lang en
|
|
53
|
+
|
|
54
|
+
# Pipe log content directly
|
|
55
|
+
cat error.log | pangu-rca analyze --stdin
|
|
56
|
+
|
|
57
|
+
# Get JSON output (for scripting)
|
|
58
|
+
pangu-rca analyze error.log --output json
|
|
59
|
+
|
|
60
|
+
# Check service health
|
|
61
|
+
pangu-rca health
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Examples
|
|
65
|
+
|
|
66
|
+
### Analyze a Java error log
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
$ pangu-rca analyze java_error.log
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
============================================================
|
|
74
|
+
🔍 Pangu RCA Agent - 分析结果
|
|
75
|
+
============================================================
|
|
76
|
+
|
|
77
|
+
📋 问题类型: 数据库连接超时
|
|
78
|
+
🎯 置信度: 95.0%
|
|
79
|
+
|
|
80
|
+
📝 详细原因:
|
|
81
|
+
数据库连接池配置过小,导致在高并发场景下连接被耗尽...
|
|
82
|
+
|
|
83
|
+
🔑 关键证据:
|
|
84
|
+
1. java.sql.SQLException: Connection timeout
|
|
85
|
+
2. Caused by: java.sql.SQLTimeoutException: Timeout waiting for connection
|
|
86
|
+
|
|
87
|
+
💡 修复建议:
|
|
88
|
+
增加数据库连接池的最大连接数,建议从 10 调整为 50...
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Pipe from another command
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Analyze Docker container logs
|
|
95
|
+
docker logs my-container 2>&1 | pangu-rca analyze --stdin
|
|
96
|
+
|
|
97
|
+
# Analyze system logs
|
|
98
|
+
journalctl -u my-service --no-pager | pangu-rca analyze --stdin --lang en
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Options
|
|
102
|
+
|
|
103
|
+
| Option | Description | Default |
|
|
104
|
+
|--------|-------------|---------|
|
|
105
|
+
| `--lang` | Output language: `zh` or `en` | `zh` |
|
|
106
|
+
| `--output` | Output format: `text` or `json` | `text` |
|
|
107
|
+
| `--api-url` | Custom API endpoint | `https://www.pangulab.com/api/analyze` |
|
|
108
|
+
|
|
109
|
+
## Commands
|
|
110
|
+
|
|
111
|
+
- `pangu-rca analyze <file>` — Analyze a log file
|
|
112
|
+
- `pangu-rca analyze --stdin` — Read logs from stdin
|
|
113
|
+
- `pangu-rca health` — Check API service status
|
|
114
|
+
- `pangu-rca --version` — Show version
|
|
115
|
+
- `pangu-rca --help` — Show help
|
|
116
|
+
|
|
117
|
+
## About
|
|
118
|
+
|
|
119
|
+
Pangu RCA Agent is an AI-powered log analysis tool that helps developers quickly identify root causes of errors from application logs. It supports Java, Python, Go, Rust, JavaScript, and many other programming languages.
|
|
120
|
+
|
|
121
|
+
**Web version**: https://www.pangulab.com
|
|
122
|
+
|
|
123
|
+
## License
|
|
124
|
+
|
|
125
|
+
MIT
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Pangu RCA CLI
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/pangu-rca/)
|
|
4
|
+
[](https://pypi.org/project/pangu-rca/)
|
|
5
|
+
[](https://github.com/halokid/TronRabbit/blob/main/LICENSE)
|
|
6
|
+
|
|
7
|
+
**AI-powered log analysis tool for developers.** Analyze error logs directly from your terminal.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install pangu-rca
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Analyze a log file
|
|
19
|
+
pangu-rca analyze error.log
|
|
20
|
+
|
|
21
|
+
# Analyze with English output
|
|
22
|
+
pangu-rca analyze error.log --lang en
|
|
23
|
+
|
|
24
|
+
# Pipe log content directly
|
|
25
|
+
cat error.log | pangu-rca analyze --stdin
|
|
26
|
+
|
|
27
|
+
# Get JSON output (for scripting)
|
|
28
|
+
pangu-rca analyze error.log --output json
|
|
29
|
+
|
|
30
|
+
# Check service health
|
|
31
|
+
pangu-rca health
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Examples
|
|
35
|
+
|
|
36
|
+
### Analyze a Java error log
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
$ pangu-rca analyze java_error.log
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
============================================================
|
|
44
|
+
🔍 Pangu RCA Agent - 分析结果
|
|
45
|
+
============================================================
|
|
46
|
+
|
|
47
|
+
📋 问题类型: 数据库连接超时
|
|
48
|
+
🎯 置信度: 95.0%
|
|
49
|
+
|
|
50
|
+
📝 详细原因:
|
|
51
|
+
数据库连接池配置过小,导致在高并发场景下连接被耗尽...
|
|
52
|
+
|
|
53
|
+
🔑 关键证据:
|
|
54
|
+
1. java.sql.SQLException: Connection timeout
|
|
55
|
+
2. Caused by: java.sql.SQLTimeoutException: Timeout waiting for connection
|
|
56
|
+
|
|
57
|
+
💡 修复建议:
|
|
58
|
+
增加数据库连接池的最大连接数,建议从 10 调整为 50...
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Pipe from another command
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Analyze Docker container logs
|
|
65
|
+
docker logs my-container 2>&1 | pangu-rca analyze --stdin
|
|
66
|
+
|
|
67
|
+
# Analyze system logs
|
|
68
|
+
journalctl -u my-service --no-pager | pangu-rca analyze --stdin --lang en
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Options
|
|
72
|
+
|
|
73
|
+
| Option | Description | Default |
|
|
74
|
+
|--------|-------------|---------|
|
|
75
|
+
| `--lang` | Output language: `zh` or `en` | `zh` |
|
|
76
|
+
| `--output` | Output format: `text` or `json` | `text` |
|
|
77
|
+
| `--api-url` | Custom API endpoint | `https://www.pangulab.com/api/analyze` |
|
|
78
|
+
|
|
79
|
+
## Commands
|
|
80
|
+
|
|
81
|
+
- `pangu-rca analyze <file>` — Analyze a log file
|
|
82
|
+
- `pangu-rca analyze --stdin` — Read logs from stdin
|
|
83
|
+
- `pangu-rca health` — Check API service status
|
|
84
|
+
- `pangu-rca --version` — Show version
|
|
85
|
+
- `pangu-rca --help` — Show help
|
|
86
|
+
|
|
87
|
+
## About
|
|
88
|
+
|
|
89
|
+
Pangu RCA Agent is an AI-powered log analysis tool that helps developers quickly identify root causes of errors from application logs. It supports Java, Python, Go, Rust, JavaScript, and many other programming languages.
|
|
90
|
+
|
|
91
|
+
**Web version**: https://www.pangulab.com
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
MIT
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
Pangu RCA CLI - AI-powered log analysis tool
|
|
5
|
+
|
|
6
|
+
Usage:
|
|
7
|
+
pangu-rca analyze <log-file> [--api-url=<url>] [--lang=<lang>] [--output=<format>]
|
|
8
|
+
pangu-rca analyze --stdin [--api-url=<url>] [--lang=<lang>] [--output=<format>]
|
|
9
|
+
pangu-rca --version
|
|
10
|
+
pangu-rca --help
|
|
11
|
+
|
|
12
|
+
Examples:
|
|
13
|
+
pangu-rca analyze error.log
|
|
14
|
+
pangu-rca analyze error.log --lang en
|
|
15
|
+
pangu-rca analyze error.log --output json
|
|
16
|
+
cat error.log | pangu-rca analyze --stdin
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
import argparse
|
|
20
|
+
import json
|
|
21
|
+
import sys
|
|
22
|
+
import os
|
|
23
|
+
import requests
|
|
24
|
+
from . import __version__
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
DEFAULT_API_URL = "https://www.pangulab.com/api/analyze"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def read_file(file_path):
|
|
31
|
+
"""Read log content from a file."""
|
|
32
|
+
try:
|
|
33
|
+
with open(file_path, 'r', encoding='utf-8', errors='ignore') as f:
|
|
34
|
+
return f.read()
|
|
35
|
+
except FileNotFoundError:
|
|
36
|
+
print(f"❌ Error: File not found: {file_path}", file=sys.stderr)
|
|
37
|
+
sys.exit(1)
|
|
38
|
+
except Exception as e:
|
|
39
|
+
print(f"❌ Error reading file: {e}", file=sys.stderr)
|
|
40
|
+
sys.exit(1)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def read_stdin():
|
|
44
|
+
"""Read log content from stdin."""
|
|
45
|
+
try:
|
|
46
|
+
return sys.stdin.read()
|
|
47
|
+
except Exception as e:
|
|
48
|
+
print(f"❌ Error reading stdin: {e}", file=sys.stderr)
|
|
49
|
+
sys.exit(1)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def call_api(log_content, api_url, language):
|
|
53
|
+
"""Call the Pangu RCA API for log analysis."""
|
|
54
|
+
try:
|
|
55
|
+
response = requests.post(
|
|
56
|
+
api_url,
|
|
57
|
+
headers={"Content-Type": "application/json"},
|
|
58
|
+
json={
|
|
59
|
+
"log_content": log_content,
|
|
60
|
+
"language": language
|
|
61
|
+
},
|
|
62
|
+
timeout=60
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
if response.status_code == 200:
|
|
66
|
+
return response.json()
|
|
67
|
+
else:
|
|
68
|
+
error_detail = "Unknown error"
|
|
69
|
+
try:
|
|
70
|
+
error_detail = response.json().get("detail", response.text)
|
|
71
|
+
except Exception:
|
|
72
|
+
error_detail = response.text
|
|
73
|
+
print(f"❌ API Error ({response.status_code}): {error_detail}", file=sys.stderr)
|
|
74
|
+
sys.exit(1)
|
|
75
|
+
|
|
76
|
+
except requests.exceptions.ConnectionError:
|
|
77
|
+
print(f"❌ Error: Cannot connect to {api_url}", file=sys.stderr)
|
|
78
|
+
print(" Make sure the service is running and the URL is correct.", file=sys.stderr)
|
|
79
|
+
sys.exit(1)
|
|
80
|
+
except requests.exceptions.Timeout:
|
|
81
|
+
print("❌ Error: API request timed out (60s)", file=sys.stderr)
|
|
82
|
+
sys.exit(1)
|
|
83
|
+
except Exception as e:
|
|
84
|
+
print(f"❌ Error: {e}", file=sys.stderr)
|
|
85
|
+
sys.exit(1)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def format_text_output(result, language):
|
|
89
|
+
"""Format analysis result as human-readable text."""
|
|
90
|
+
confidence_pct = result.get("confidence", 0) * 100
|
|
91
|
+
|
|
92
|
+
if language == "zh":
|
|
93
|
+
output = []
|
|
94
|
+
output.append("=" * 60)
|
|
95
|
+
output.append("🔍 Pangu RCA Agent - 分析结果")
|
|
96
|
+
output.append("=" * 60)
|
|
97
|
+
output.append(f"\n📋 问题类型: {result.get('root_cause_type', 'N/A')}")
|
|
98
|
+
output.append(f"🎯 置信度: {confidence_pct:.1f}%")
|
|
99
|
+
output.append(f"\n📝 详细原因:")
|
|
100
|
+
output.append(f" {result.get('root_cause_detail', 'N/A')}")
|
|
101
|
+
output.append(f"\n🔑 关键证据:")
|
|
102
|
+
for i, evidence in enumerate(result.get("key_evidence", []), 1):
|
|
103
|
+
output.append(f" {i}. {evidence}")
|
|
104
|
+
output.append(f"\n💡 修复建议:")
|
|
105
|
+
output.append(f" {result.get('suggestion', 'N/A')}")
|
|
106
|
+
output.append("\n" + "=" * 60)
|
|
107
|
+
return "\n".join(output)
|
|
108
|
+
else:
|
|
109
|
+
output = []
|
|
110
|
+
output.append("=" * 60)
|
|
111
|
+
output.append("🔍 Pangu RCA Agent - Analysis Result")
|
|
112
|
+
output.append("=" * 60)
|
|
113
|
+
output.append(f"\n📋 Problem Type: {result.get('root_cause_type', 'N/A')}")
|
|
114
|
+
output.append(f"🎯 Confidence: {confidence_pct:.1f}%")
|
|
115
|
+
output.append(f"\n📝 Detailed Reason:")
|
|
116
|
+
output.append(f" {result.get('root_cause_detail', 'N/A')}")
|
|
117
|
+
output.append(f"\n🔑 Key Evidence:")
|
|
118
|
+
for i, evidence in enumerate(result.get("key_evidence", []), 1):
|
|
119
|
+
output.append(f" {i}. {evidence}")
|
|
120
|
+
output.append(f"\n💡 Fix Suggestions:")
|
|
121
|
+
output.append(f" {result.get('suggestion', 'N/A')}")
|
|
122
|
+
output.append("\n" + "=" * 60)
|
|
123
|
+
return "\n".join(output)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def format_output(result, output_format, language):
|
|
127
|
+
"""Format the analysis result in the specified format."""
|
|
128
|
+
if output_format == "json":
|
|
129
|
+
return json.dumps(result, indent=2, ensure_ascii=False)
|
|
130
|
+
elif output_format == "text":
|
|
131
|
+
return format_text_output(result, language)
|
|
132
|
+
else:
|
|
133
|
+
return format_text_output(result, language)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def analyze_command(args):
|
|
137
|
+
"""Handle the 'analyze' subcommand."""
|
|
138
|
+
# Read log content
|
|
139
|
+
if args.stdin:
|
|
140
|
+
log_content = read_stdin()
|
|
141
|
+
source = "stdin"
|
|
142
|
+
else:
|
|
143
|
+
log_content = read_file(args.log_file)
|
|
144
|
+
source = args.log_file
|
|
145
|
+
|
|
146
|
+
if not log_content.strip():
|
|
147
|
+
print("❌ Error: Log content is empty", file=sys.stderr)
|
|
148
|
+
sys.exit(1)
|
|
149
|
+
|
|
150
|
+
# Show progress
|
|
151
|
+
line_count = len(log_content.split('\n'))
|
|
152
|
+
lang_name = "中文" if args.lang == "zh" else "English"
|
|
153
|
+
print(f"📄 Reading logs from: {source}", file=sys.stderr)
|
|
154
|
+
print(f"📊 Log lines: {line_count}", file=sys.stderr)
|
|
155
|
+
print(f"🌐 Language: {lang_name}", file=sys.stderr)
|
|
156
|
+
print(f"⏳ Analyzing...", file=sys.stderr)
|
|
157
|
+
|
|
158
|
+
# Call API
|
|
159
|
+
result = call_api(log_content, args.api_url, args.lang)
|
|
160
|
+
|
|
161
|
+
# Output result
|
|
162
|
+
output = format_output(result, args.output, args.lang)
|
|
163
|
+
print(output)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def health_command(args):
|
|
167
|
+
"""Check if the API is healthy."""
|
|
168
|
+
health_url = args.api_url.replace("/api/analyze", "/api/health")
|
|
169
|
+
try:
|
|
170
|
+
response = requests.get(health_url, timeout=10)
|
|
171
|
+
if response.status_code == 200:
|
|
172
|
+
data = response.json()
|
|
173
|
+
print(f"✅ Service is healthy")
|
|
174
|
+
print(f" Status: {data.get('status', 'unknown')}")
|
|
175
|
+
print(f" Service: {data.get('service', 'unknown')}")
|
|
176
|
+
else:
|
|
177
|
+
print(f"❌ Service returned status {response.status_code}")
|
|
178
|
+
except Exception as e:
|
|
179
|
+
print(f"❌ Cannot connect to service: {e}")
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def main():
|
|
183
|
+
parser = argparse.ArgumentParser(
|
|
184
|
+
description="Pangu RCA CLI - AI-powered log analysis tool",
|
|
185
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
186
|
+
epilog="""
|
|
187
|
+
Examples:
|
|
188
|
+
pangu-rca analyze error.log
|
|
189
|
+
pangu-rca analyze error.log --lang en
|
|
190
|
+
pangu-rca analyze error.log --output json
|
|
191
|
+
cat error.log | pangu-rca analyze --stdin
|
|
192
|
+
pangu-rca health
|
|
193
|
+
|
|
194
|
+
Visit https://www.pangulab.com for more information.
|
|
195
|
+
"""
|
|
196
|
+
)
|
|
197
|
+
parser.add_argument(
|
|
198
|
+
"--version",
|
|
199
|
+
action="version",
|
|
200
|
+
version=f"Pangu RCA CLI v{__version__}"
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
subparsers = parser.add_subparsers(dest="command", help="Available commands")
|
|
204
|
+
|
|
205
|
+
# Analyze command
|
|
206
|
+
analyze_parser = subparsers.add_parser("analyze", help="Analyze log file")
|
|
207
|
+
analyze_parser.add_argument(
|
|
208
|
+
"log_file",
|
|
209
|
+
nargs="?",
|
|
210
|
+
help="Path to the log file to analyze"
|
|
211
|
+
)
|
|
212
|
+
analyze_parser.add_argument(
|
|
213
|
+
"--stdin",
|
|
214
|
+
action="store_true",
|
|
215
|
+
help="Read log content from stdin (pipe)"
|
|
216
|
+
)
|
|
217
|
+
analyze_parser.add_argument(
|
|
218
|
+
"--api-url",
|
|
219
|
+
default=DEFAULT_API_URL,
|
|
220
|
+
help=f"API endpoint URL (default: {DEFAULT_API_URL})"
|
|
221
|
+
)
|
|
222
|
+
analyze_parser.add_argument(
|
|
223
|
+
"--lang",
|
|
224
|
+
choices=["zh", "en"],
|
|
225
|
+
default="zh",
|
|
226
|
+
help="Output language: zh (Chinese) or en (English) (default: zh)"
|
|
227
|
+
)
|
|
228
|
+
analyze_parser.add_argument(
|
|
229
|
+
"--output",
|
|
230
|
+
choices=["text", "json"],
|
|
231
|
+
default="text",
|
|
232
|
+
help="Output format: text or json (default: text)"
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
# Health command
|
|
236
|
+
health_parser = subparsers.add_parser("health", help="Check API health status")
|
|
237
|
+
health_parser.add_argument(
|
|
238
|
+
"--api-url",
|
|
239
|
+
default=DEFAULT_API_URL,
|
|
240
|
+
help=f"API endpoint URL (default: {DEFAULT_API_URL})"
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
args = parser.parse_args()
|
|
244
|
+
|
|
245
|
+
if args.command == "analyze":
|
|
246
|
+
if not args.stdin and not args.log_file:
|
|
247
|
+
print("❌ Error: Please provide a log file or use --stdin", file=sys.stderr)
|
|
248
|
+
print(" Usage: pangu-rca analyze <log-file>", file=sys.stderr)
|
|
249
|
+
print(" Or: cat <log-file> | pangu-rca analyze --stdin", file=sys.stderr)
|
|
250
|
+
sys.exit(1)
|
|
251
|
+
if args.stdin and args.log_file:
|
|
252
|
+
print("❌ Error: Cannot use both --stdin and a log file", file=sys.stderr)
|
|
253
|
+
sys.exit(1)
|
|
254
|
+
analyze_command(args)
|
|
255
|
+
elif args.command == "health":
|
|
256
|
+
health_command(args)
|
|
257
|
+
else:
|
|
258
|
+
parser.print_help()
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
if __name__ == "__main__":
|
|
262
|
+
main()
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pangu-rca
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pangu RCA CLI - AI-powered log analysis tool
|
|
5
|
+
Home-page: https://www.pangulab.com
|
|
6
|
+
Author: Pangulab Team
|
|
7
|
+
Author-email: Pangulab Team <r00txxyyzz@gmail.com>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://www.pangulab.com
|
|
10
|
+
Project-URL: Source, https://github.com/halokid/TronRabbit
|
|
11
|
+
Keywords: log analysis,AI,root cause analysis,debugging,devtools
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Topic :: Software Development :: Debuggers
|
|
15
|
+
Classifier: Topic :: System :: Logging
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Requires-Python: >=3.7
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
Requires-Dist: requests>=2.25.0
|
|
27
|
+
Dynamic: author
|
|
28
|
+
Dynamic: home-page
|
|
29
|
+
Dynamic: requires-python
|
|
30
|
+
|
|
31
|
+
# Pangu RCA CLI
|
|
32
|
+
|
|
33
|
+
[](https://pypi.org/project/pangu-rca/)
|
|
34
|
+
[](https://pypi.org/project/pangu-rca/)
|
|
35
|
+
[](https://github.com/halokid/TronRabbit/blob/main/LICENSE)
|
|
36
|
+
|
|
37
|
+
**AI-powered log analysis tool for developers.** Analyze error logs directly from your terminal.
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install pangu-rca
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Analyze a log file
|
|
49
|
+
pangu-rca analyze error.log
|
|
50
|
+
|
|
51
|
+
# Analyze with English output
|
|
52
|
+
pangu-rca analyze error.log --lang en
|
|
53
|
+
|
|
54
|
+
# Pipe log content directly
|
|
55
|
+
cat error.log | pangu-rca analyze --stdin
|
|
56
|
+
|
|
57
|
+
# Get JSON output (for scripting)
|
|
58
|
+
pangu-rca analyze error.log --output json
|
|
59
|
+
|
|
60
|
+
# Check service health
|
|
61
|
+
pangu-rca health
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Examples
|
|
65
|
+
|
|
66
|
+
### Analyze a Java error log
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
$ pangu-rca analyze java_error.log
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
============================================================
|
|
74
|
+
🔍 Pangu RCA Agent - 分析结果
|
|
75
|
+
============================================================
|
|
76
|
+
|
|
77
|
+
📋 问题类型: 数据库连接超时
|
|
78
|
+
🎯 置信度: 95.0%
|
|
79
|
+
|
|
80
|
+
📝 详细原因:
|
|
81
|
+
数据库连接池配置过小,导致在高并发场景下连接被耗尽...
|
|
82
|
+
|
|
83
|
+
🔑 关键证据:
|
|
84
|
+
1. java.sql.SQLException: Connection timeout
|
|
85
|
+
2. Caused by: java.sql.SQLTimeoutException: Timeout waiting for connection
|
|
86
|
+
|
|
87
|
+
💡 修复建议:
|
|
88
|
+
增加数据库连接池的最大连接数,建议从 10 调整为 50...
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Pipe from another command
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Analyze Docker container logs
|
|
95
|
+
docker logs my-container 2>&1 | pangu-rca analyze --stdin
|
|
96
|
+
|
|
97
|
+
# Analyze system logs
|
|
98
|
+
journalctl -u my-service --no-pager | pangu-rca analyze --stdin --lang en
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Options
|
|
102
|
+
|
|
103
|
+
| Option | Description | Default |
|
|
104
|
+
|--------|-------------|---------|
|
|
105
|
+
| `--lang` | Output language: `zh` or `en` | `zh` |
|
|
106
|
+
| `--output` | Output format: `text` or `json` | `text` |
|
|
107
|
+
| `--api-url` | Custom API endpoint | `https://www.pangulab.com/api/analyze` |
|
|
108
|
+
|
|
109
|
+
## Commands
|
|
110
|
+
|
|
111
|
+
- `pangu-rca analyze <file>` — Analyze a log file
|
|
112
|
+
- `pangu-rca analyze --stdin` — Read logs from stdin
|
|
113
|
+
- `pangu-rca health` — Check API service status
|
|
114
|
+
- `pangu-rca --version` — Show version
|
|
115
|
+
- `pangu-rca --help` — Show help
|
|
116
|
+
|
|
117
|
+
## About
|
|
118
|
+
|
|
119
|
+
Pangu RCA Agent is an AI-powered log analysis tool that helps developers quickly identify root causes of errors from application logs. It supports Java, Python, Go, Rust, JavaScript, and many other programming languages.
|
|
120
|
+
|
|
121
|
+
**Web version**: https://www.pangulab.com
|
|
122
|
+
|
|
123
|
+
## License
|
|
124
|
+
|
|
125
|
+
MIT
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
setup.py
|
|
4
|
+
pangu_rca/__init__.py
|
|
5
|
+
pangu_rca/cli.py
|
|
6
|
+
pangu_rca.egg-info/PKG-INFO
|
|
7
|
+
pangu_rca.egg-info/SOURCES.txt
|
|
8
|
+
pangu_rca.egg-info/dependency_links.txt
|
|
9
|
+
pangu_rca.egg-info/entry_points.txt
|
|
10
|
+
pangu_rca.egg-info/requires.txt
|
|
11
|
+
pangu_rca.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests>=2.25.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pangu_rca
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pangu-rca"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Pangu RCA CLI - AI-powered log analysis tool"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.7"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
keywords = ["log analysis", "AI", "root cause analysis", "debugging", "devtools"]
|
|
13
|
+
authors = [
|
|
14
|
+
{name = "Pangulab Team", email = "r00txxyyzz@gmail.com"},
|
|
15
|
+
]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Topic :: Software Development :: Debuggers",
|
|
20
|
+
"Topic :: System :: Logging",
|
|
21
|
+
"License :: OSI Approved :: MIT License",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3.7",
|
|
24
|
+
"Programming Language :: Python :: 3.8",
|
|
25
|
+
"Programming Language :: Python :: 3.9",
|
|
26
|
+
"Programming Language :: Python :: 3.10",
|
|
27
|
+
"Programming Language :: Python :: 3.11",
|
|
28
|
+
"Programming Language :: Python :: 3.12",
|
|
29
|
+
]
|
|
30
|
+
dependencies = [
|
|
31
|
+
"requests>=2.25.0",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[project.urls]
|
|
35
|
+
Homepage = "https://www.pangulab.com"
|
|
36
|
+
Source = "https://github.com/halokid/TronRabbit"
|
|
37
|
+
|
|
38
|
+
[project.scripts]
|
|
39
|
+
pangu-rca = "pangu_rca.cli:main"
|
pangu_rca-0.1.0/setup.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name="pangu-rca",
|
|
5
|
+
version="0.1.0",
|
|
6
|
+
description="Pangu RCA CLI - AI-powered log analysis tool",
|
|
7
|
+
long_description=open("README.md", encoding="utf-8").read(),
|
|
8
|
+
long_description_content_type="text/markdown",
|
|
9
|
+
author="Pangulab Team",
|
|
10
|
+
author_email="r00txxyyzz@gmail.com",
|
|
11
|
+
url="https://www.pangulab.com",
|
|
12
|
+
packages=find_packages(),
|
|
13
|
+
install_requires=[
|
|
14
|
+
"requests>=2.25.0",
|
|
15
|
+
],
|
|
16
|
+
entry_points={
|
|
17
|
+
"console_scripts": [
|
|
18
|
+
"pangu-rca=pangu_rca.cli:main",
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
classifiers=[
|
|
22
|
+
"Development Status :: 4 - Beta",
|
|
23
|
+
"Intended Audience :: Developers",
|
|
24
|
+
"Topic :: Software Development :: Debuggers",
|
|
25
|
+
"Topic :: System :: Logging",
|
|
26
|
+
"License :: OSI Approved :: MIT License",
|
|
27
|
+
"Programming Language :: Python :: 3",
|
|
28
|
+
"Programming Language :: Python :: 3.7",
|
|
29
|
+
"Programming Language :: Python :: 3.8",
|
|
30
|
+
"Programming Language :: Python :: 3.9",
|
|
31
|
+
"Programming Language :: Python :: 3.10",
|
|
32
|
+
"Programming Language :: Python :: 3.11",
|
|
33
|
+
"Programming Language :: Python :: 3.12",
|
|
34
|
+
],
|
|
35
|
+
python_requires=">=3.7",
|
|
36
|
+
keywords="log analysis, AI, root cause analysis, debugging, devtools",
|
|
37
|
+
)
|