pms_md 1.0.0
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.
- package/README.md +93 -0
- package/node-monitor/ARCHITECTURE.md +341 -0
- package/node-monitor/CHANGELOG.md +105 -0
- package/node-monitor/CONTRIBUTING.md +96 -0
- package/node-monitor/DESIGN_IMPROVEMENTS.md +286 -0
- package/node-monitor/FILTER_BUTTONS_FIX.md +303 -0
- package/node-monitor/GETTING_STARTED.md +416 -0
- package/node-monitor/INSTALLATION.md +470 -0
- package/node-monitor/LICENSE +22 -0
- package/node-monitor/PUBLISHING_GUIDE.md +331 -0
- package/node-monitor/QUICK_REFERENCE.md +252 -0
- package/node-monitor/README.md +458 -0
- package/node-monitor/READY_TO_PUBLISH.md +272 -0
- package/node-monitor/SETUP_GUIDE.md +479 -0
- package/node-monitor/examples/EMAIL_SETUP_GUIDE.md +282 -0
- package/node-monitor/examples/ERROR_LOGGING_GUIDE.md +405 -0
- package/node-monitor/examples/GET_APP_PASSWORD.md +145 -0
- package/node-monitor/examples/LOG_FILES_REFERENCE.md +336 -0
- package/node-monitor/examples/QUICK_START_EMAIL.md +126 -0
- package/node-monitor/examples/express-app.js +499 -0
- package/node-monitor/examples/package-lock.json +1295 -0
- package/node-monitor/examples/package.json +18 -0
- package/node-monitor/examples/public/css/style.css +718 -0
- package/node-monitor/examples/public/js/dashboard.js +207 -0
- package/node-monitor/examples/public/js/health.js +114 -0
- package/node-monitor/examples/public/js/main.js +89 -0
- package/node-monitor/examples/public/js/metrics.js +225 -0
- package/node-monitor/examples/public/js/theme.js +138 -0
- package/node-monitor/examples/views/dashboard.ejs +20 -0
- package/node-monitor/examples/views/error-logs.ejs +1129 -0
- package/node-monitor/examples/views/health.ejs +21 -0
- package/node-monitor/examples/views/home.ejs +341 -0
- package/node-monitor/examples/views/layout.ejs +50 -0
- package/node-monitor/examples/views/metrics.ejs +16 -0
- package/node-monitor/examples/views/partials/footer.ejs +16 -0
- package/node-monitor/examples/views/partials/header.ejs +35 -0
- package/node-monitor/examples/views/partials/nav.ejs +23 -0
- package/node-monitor/examples/views/status.ejs +390 -0
- package/node-monitor/package-lock.json +4300 -0
- package/node-monitor/package.json +76 -0
- package/node-monitor/pre-publish-check.js +200 -0
- package/node-monitor/src/config/monitoringConfig.js +255 -0
- package/node-monitor/src/index.js +300 -0
- package/node-monitor/src/logger/errorLogger.js +297 -0
- package/node-monitor/src/monitors/apiErrorMonitor.js +156 -0
- package/node-monitor/src/monitors/dbConnectionMonitor.js +389 -0
- package/node-monitor/src/monitors/serverHealthMonitor.js +320 -0
- package/node-monitor/src/monitors/systemResourceMonitor.js +357 -0
- package/node-monitor/src/notifiers/emailNotifier.js +248 -0
- package/node-monitor/src/notifiers/notificationManager.js +96 -0
- package/node-monitor/src/notifiers/slackNotifier.js +209 -0
- package/node-monitor/src/views/dashboard.html +530 -0
- package/node-monitor/src/views/health.html +399 -0
- package/node-monitor/src/views/metrics.html +406 -0
- package/package.json +22 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# ๐ How to Get Gmail App Password
|
|
2
|
+
|
|
3
|
+
## โ ๏ธ Current Issue
|
|
4
|
+
|
|
5
|
+
You're seeing this error:
|
|
6
|
+
```
|
|
7
|
+
Invalid login: 535 5.7.8 Username and Password not accepted
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
This means you need to create a **Gmail App Password**.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## ๐ Step-by-Step Instructions
|
|
15
|
+
|
|
16
|
+
### **Step 1: Enable 2-Step Verification** (if not already enabled)
|
|
17
|
+
|
|
18
|
+
1. Open: https://myaccount.google.com/security
|
|
19
|
+
2. Scroll to "How you sign in to Google"
|
|
20
|
+
3. Click **"2-Step Verification"**
|
|
21
|
+
4. Follow the setup process (takes 2-3 minutes)
|
|
22
|
+
|
|
23
|
+
### **Step 2: Create App Password**
|
|
24
|
+
|
|
25
|
+
1. Open: **https://myaccount.google.com/apppasswords**
|
|
26
|
+
2. You may need to sign in again
|
|
27
|
+
3. Under "Select app", choose: **Mail**
|
|
28
|
+
4. Under "Select device", choose: **Other (Custom name)**
|
|
29
|
+
5. Type: **Node Monitor**
|
|
30
|
+
6. Click **"Generate"**
|
|
31
|
+
|
|
32
|
+
### **Step 3: Copy the Password**
|
|
33
|
+
|
|
34
|
+
You'll see a 16-character password like this:
|
|
35
|
+
```
|
|
36
|
+
abcd efgh ijkl mnop
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**IMPORTANT:** Remove all spaces! It should be:
|
|
40
|
+
```
|
|
41
|
+
abcdefghijklmnop
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### **Step 4: Update .env File**
|
|
45
|
+
|
|
46
|
+
1. Open the file: `node-monitor/examples/.env`
|
|
47
|
+
2. Find this line:
|
|
48
|
+
```env
|
|
49
|
+
EMAIL_APP_PASSWORD=your-gmail-app-password-here
|
|
50
|
+
```
|
|
51
|
+
3. Replace it with your password:
|
|
52
|
+
```env
|
|
53
|
+
EMAIL_APP_PASSWORD=abcdefghijklmnop
|
|
54
|
+
```
|
|
55
|
+
4. **Save the file!**
|
|
56
|
+
|
|
57
|
+
### **Step 5: Restart the Server**
|
|
58
|
+
|
|
59
|
+
Stop the current server (Ctrl+C) and restart:
|
|
60
|
+
```bash
|
|
61
|
+
cd node-monitor/examples
|
|
62
|
+
node express-app.js
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### **Step 6: Test Again**
|
|
66
|
+
|
|
67
|
+
Visit: http://localhost:3001/api/notify-test
|
|
68
|
+
|
|
69
|
+
You should now see:
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"successful": 1,
|
|
73
|
+
"failed": 0
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
And receive an email at: **manish.proses@gmail.com**
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## ๐จ Troubleshooting
|
|
82
|
+
|
|
83
|
+
### Problem: "2-Step Verification not enabled"
|
|
84
|
+
|
|
85
|
+
You MUST enable 2-Step Verification first:
|
|
86
|
+
1. Go to: https://myaccount.google.com/security
|
|
87
|
+
2. Enable 2-Step Verification
|
|
88
|
+
3. Then create App Password
|
|
89
|
+
|
|
90
|
+
### Problem: "Can't find App Passwords option"
|
|
91
|
+
|
|
92
|
+
Make sure:
|
|
93
|
+
- โ
You're signed in to: manish.proses@gmail.com
|
|
94
|
+
- โ
2-Step Verification is enabled
|
|
95
|
+
- โ
You're using this direct link: https://myaccount.google.com/apppasswords
|
|
96
|
+
|
|
97
|
+
### Problem: Still getting "Invalid login"
|
|
98
|
+
|
|
99
|
+
Check:
|
|
100
|
+
- โ
You copied the ENTIRE 16-character password
|
|
101
|
+
- โ
You removed ALL spaces
|
|
102
|
+
- โ
You saved the .env file
|
|
103
|
+
- โ
You restarted the server
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## ๐ง Alternative: Use a Different Email Service
|
|
108
|
+
|
|
109
|
+
If you don't want to use Gmail App Passwords, you can use:
|
|
110
|
+
|
|
111
|
+
### **Option 1: Gmail with Less Secure Apps** (Not Recommended)
|
|
112
|
+
- Not available for accounts with 2FA
|
|
113
|
+
|
|
114
|
+
### **Option 2: SendGrid** (Free tier available)
|
|
115
|
+
1. Sign up at: https://sendgrid.com
|
|
116
|
+
2. Get API key
|
|
117
|
+
3. Update configuration
|
|
118
|
+
|
|
119
|
+
### **Option 3: Mailgun** (Free tier available)
|
|
120
|
+
1. Sign up at: https://www.mailgun.com
|
|
121
|
+
2. Get SMTP credentials
|
|
122
|
+
3. Update configuration
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## โ
Quick Checklist
|
|
127
|
+
|
|
128
|
+
- [ ] 2-Step Verification enabled on Gmail
|
|
129
|
+
- [ ] App Password created
|
|
130
|
+
- [ ] Password copied (16 characters, no spaces)
|
|
131
|
+
- [ ] .env file updated
|
|
132
|
+
- [ ] .env file saved
|
|
133
|
+
- [ ] Server restarted
|
|
134
|
+
- [ ] Test endpoint visited
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## ๐ฏ Need Help?
|
|
139
|
+
|
|
140
|
+
If you're still having issues, share:
|
|
141
|
+
1. Screenshot of the error
|
|
142
|
+
2. Confirm 2-Step Verification is enabled
|
|
143
|
+
3. Confirm you created an App Password
|
|
144
|
+
4. Confirm you updated and saved .env file
|
|
145
|
+
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
# ๐ Log Files Reference
|
|
2
|
+
|
|
3
|
+
## ๐ Quick Access
|
|
4
|
+
|
|
5
|
+
### **Web Interface:**
|
|
6
|
+
```
|
|
7
|
+
http://localhost:3001/monitor/error-logs
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
### **File Location:**
|
|
11
|
+
```
|
|
12
|
+
node-monitor/examples/logs/
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## ๐ Log Files
|
|
18
|
+
|
|
19
|
+
### **Error Logs (Errors Only)**
|
|
20
|
+
```
|
|
21
|
+
logs/error-2025-11-12.log
|
|
22
|
+
logs/error-2025-11-11.log
|
|
23
|
+
logs/error-2025-11-10.log
|
|
24
|
+
...
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Contains:** API errors, system errors, critical failures
|
|
28
|
+
|
|
29
|
+
### **Application Logs (All Events)**
|
|
30
|
+
```
|
|
31
|
+
logs/application-2025-11-12.log
|
|
32
|
+
logs/application-2025-11-11.log
|
|
33
|
+
logs/application-2025-11-10.log
|
|
34
|
+
...
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Contains:** Info, warnings, errors, debug messages
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## ๐ Log Entry Format
|
|
42
|
+
|
|
43
|
+
### **Error Log Entry Example:**
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"level": "error",
|
|
48
|
+
"message": "API Error This is a test error",
|
|
49
|
+
"type": "API_ERROR",
|
|
50
|
+
"method": "GET",
|
|
51
|
+
"url": "/api/error",
|
|
52
|
+
"statusCode": 500,
|
|
53
|
+
"timestamp": "2025-11-12T06:00:03.618Z",
|
|
54
|
+
"ip": "::1",
|
|
55
|
+
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)...",
|
|
56
|
+
"headers": {
|
|
57
|
+
"accept": "text/html,application/xhtml+xml...",
|
|
58
|
+
"host": "localhost:3001",
|
|
59
|
+
"user-agent": "Mozilla/5.0..."
|
|
60
|
+
},
|
|
61
|
+
"query": {},
|
|
62
|
+
"body": {},
|
|
63
|
+
"stack": "Error: This is a test error\n at ApiErrorMonitor.createError...",
|
|
64
|
+
"app": {
|
|
65
|
+
"name": "Example Express App",
|
|
66
|
+
"version": "1.0.0",
|
|
67
|
+
"environment": "production",
|
|
68
|
+
"hostname": "MD"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## ๐ Key Fields
|
|
76
|
+
|
|
77
|
+
| Field | Type | Description | Example |
|
|
78
|
+
|-------|------|-------------|---------|
|
|
79
|
+
| `level` | string | Log severity | `"error"`, `"warn"`, `"info"` |
|
|
80
|
+
| `message` | string | Error message | `"API Error This is a test error"` |
|
|
81
|
+
| `type` | string | Error category | `"API_ERROR"`, `"SYSTEM_ERROR"` |
|
|
82
|
+
| `method` | string | HTTP method | `"GET"`, `"POST"`, `"PUT"` |
|
|
83
|
+
| `url` | string | Request path | `"/api/error"` |
|
|
84
|
+
| `statusCode` | number | HTTP status | `500`, `404`, `400` |
|
|
85
|
+
| `timestamp` | string | ISO 8601 date | `"2025-11-12T06:00:03.618Z"` |
|
|
86
|
+
| `ip` | string | Client IP | `"::1"`, `"192.168.1.1"` |
|
|
87
|
+
| `userAgent` | string | Browser/client | `"Mozilla/5.0..."` |
|
|
88
|
+
| `headers` | object | HTTP headers | `{ "accept": "...", ... }` |
|
|
89
|
+
| `query` | object | URL params | `{ "id": "123" }` |
|
|
90
|
+
| `body` | object | Request body | `{ "username": "..." }` |
|
|
91
|
+
| `stack` | string | Stack trace | `"Error: ...\n at ..."` |
|
|
92
|
+
| `app.name` | string | App name | `"Example Express App"` |
|
|
93
|
+
| `app.version` | string | App version | `"1.0.0"` |
|
|
94
|
+
| `app.environment` | string | Environment | `"production"`, `"development"` |
|
|
95
|
+
| `app.hostname` | string | Server name | `"MD"` |
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## ๐ Reading Logs
|
|
100
|
+
|
|
101
|
+
### **Method 1: Web Interface**
|
|
102
|
+
```
|
|
103
|
+
http://localhost:3001/monitor/error-logs
|
|
104
|
+
```
|
|
105
|
+
- โ
Beautiful UI
|
|
106
|
+
- โ
Filter by date
|
|
107
|
+
- โ
Expandable stack traces
|
|
108
|
+
- โ
Download as JSON
|
|
109
|
+
|
|
110
|
+
### **Method 2: Command Line**
|
|
111
|
+
|
|
112
|
+
**View latest errors:**
|
|
113
|
+
```bash
|
|
114
|
+
tail -n 10 logs/error-2025-11-12.log
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Count errors:**
|
|
118
|
+
```bash
|
|
119
|
+
wc -l logs/error-2025-11-12.log
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Search for specific error:**
|
|
123
|
+
```bash
|
|
124
|
+
grep "test error" logs/error-2025-11-12.log
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Pretty print JSON:**
|
|
128
|
+
```bash
|
|
129
|
+
cat logs/error-2025-11-12.log | jq '.'
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### **Method 3: Node.js Script**
|
|
133
|
+
|
|
134
|
+
```javascript
|
|
135
|
+
const fs = require('fs');
|
|
136
|
+
|
|
137
|
+
// Read and parse log file
|
|
138
|
+
const logFile = 'logs/error-2025-11-12.log';
|
|
139
|
+
const content = fs.readFileSync(logFile, 'utf8');
|
|
140
|
+
|
|
141
|
+
// Parse each line as JSON
|
|
142
|
+
const errors = content
|
|
143
|
+
.split('\n')
|
|
144
|
+
.filter(line => line.trim())
|
|
145
|
+
.map(line => JSON.parse(line));
|
|
146
|
+
|
|
147
|
+
// Analyze
|
|
148
|
+
console.log('Total errors:', errors.length);
|
|
149
|
+
console.log('Latest error:', errors[errors.length - 1]);
|
|
150
|
+
|
|
151
|
+
// Group by status code
|
|
152
|
+
const byStatus = errors.reduce((acc, err) => {
|
|
153
|
+
acc[err.statusCode] = (acc[err.statusCode] || 0) + 1;
|
|
154
|
+
return acc;
|
|
155
|
+
}, {});
|
|
156
|
+
console.log('Errors by status code:', byStatus);
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### **Method 4: API Endpoint**
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Get errors as JSON
|
|
163
|
+
curl "http://localhost:3001/monitor/error-logs/error-2025-11-12.log?format=json&limit=10"
|
|
164
|
+
|
|
165
|
+
# Download log file
|
|
166
|
+
curl "http://localhost:3001/monitor/error-logs/error-2025-11-12.log" -o error-log.json
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## ๐ Log Rotation
|
|
172
|
+
|
|
173
|
+
### **Automatic Rotation:**
|
|
174
|
+
- โ
New file created daily at midnight
|
|
175
|
+
- โ
Old files kept for 14 days
|
|
176
|
+
- โ
Files automatically deleted after 14 days
|
|
177
|
+
- โ
Maximum file size: 20MB
|
|
178
|
+
|
|
179
|
+
### **File Naming:**
|
|
180
|
+
```
|
|
181
|
+
error-YYYY-MM-DD.log
|
|
182
|
+
application-YYYY-MM-DD.log
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Example:**
|
|
186
|
+
```
|
|
187
|
+
error-2025-11-12.log โ Today
|
|
188
|
+
error-2025-11-11.log โ Yesterday
|
|
189
|
+
error-2025-11-10.log โ 2 days ago
|
|
190
|
+
...
|
|
191
|
+
error-2025-10-29.log โ 14 days ago (will be deleted tomorrow)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## ๐ก๏ธ Sensitive Data Protection
|
|
197
|
+
|
|
198
|
+
### **Automatically Redacted Fields:**
|
|
199
|
+
- `password`
|
|
200
|
+
- `token`
|
|
201
|
+
- `apiKey`
|
|
202
|
+
- `secret`
|
|
203
|
+
- `authorization`
|
|
204
|
+
- Any field containing these keywords
|
|
205
|
+
|
|
206
|
+
### **Example:**
|
|
207
|
+
|
|
208
|
+
**Original Request:**
|
|
209
|
+
```json
|
|
210
|
+
{
|
|
211
|
+
"username": "john@example.com",
|
|
212
|
+
"password": "MySecret123",
|
|
213
|
+
"apiKey": "sk_live_abc123"
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**Logged as:**
|
|
218
|
+
```json
|
|
219
|
+
{
|
|
220
|
+
"username": "john@example.com",
|
|
221
|
+
"password": "***REDACTED***",
|
|
222
|
+
"apiKey": "***REDACTED***"
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## ๐ฅ Exporting Logs
|
|
229
|
+
|
|
230
|
+
### **For Analysis:**
|
|
231
|
+
```bash
|
|
232
|
+
# Export last 100 errors
|
|
233
|
+
curl "http://localhost:3001/monitor/error-logs/error-2025-11-12.log?format=json&limit=100" > errors.json
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### **For Backup:**
|
|
237
|
+
```bash
|
|
238
|
+
# Copy all log files
|
|
239
|
+
cp -r logs/ backup/logs-2025-11-12/
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### **For Sharing:**
|
|
243
|
+
```bash
|
|
244
|
+
# Download specific log
|
|
245
|
+
curl "http://localhost:3001/monitor/error-logs/error-2025-11-12.log" -o error-report.json
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## ๐ Common Queries
|
|
251
|
+
|
|
252
|
+
### **Find all 500 errors:**
|
|
253
|
+
```bash
|
|
254
|
+
cat logs/error-2025-11-12.log | jq 'select(.statusCode == 500)'
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### **Find errors from specific URL:**
|
|
258
|
+
```bash
|
|
259
|
+
cat logs/error-2025-11-12.log | jq 'select(.url == "/api/error")'
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### **Count errors by type:**
|
|
263
|
+
```bash
|
|
264
|
+
cat logs/error-2025-11-12.log | jq -r '.type' | sort | uniq -c
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### **Get error messages only:**
|
|
268
|
+
```bash
|
|
269
|
+
cat logs/error-2025-11-12.log | jq -r '.message'
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### **Find errors in last hour:**
|
|
273
|
+
```bash
|
|
274
|
+
cat logs/error-2025-11-12.log | jq --arg time "$(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%S)" 'select(.timestamp > $time)'
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## ๐ง Email Notifications
|
|
280
|
+
|
|
281
|
+
When errors are logged, emails are sent to: **manish.proses@gmail.com**
|
|
282
|
+
|
|
283
|
+
**Triggers:**
|
|
284
|
+
- Single API error โ Warning email
|
|
285
|
+
- High error rate (>10/min) โ Critical email
|
|
286
|
+
- Consecutive failures (2+) โ Critical email
|
|
287
|
+
|
|
288
|
+
**Cooldown:** 3 minutes between emails
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## ๐ฏ Quick Reference
|
|
293
|
+
|
|
294
|
+
| Task | Command/URL |
|
|
295
|
+
|------|-------------|
|
|
296
|
+
| View errors in browser | http://localhost:3001/monitor/error-logs |
|
|
297
|
+
| Download today's errors | http://localhost:3001/monitor/error-logs/error-2025-11-12.log |
|
|
298
|
+
| Get errors as JSON | http://localhost:3001/monitor/error-logs/error-2025-11-12.log?format=json |
|
|
299
|
+
| View latest 10 errors | `tail -n 10 logs/error-2025-11-12.log` |
|
|
300
|
+
| Count total errors | `wc -l logs/error-2025-11-12.log` |
|
|
301
|
+
| Search for error | `grep "keyword" logs/error-2025-11-12.log` |
|
|
302
|
+
| Pretty print | `cat logs/error-2025-11-12.log \| jq '.'` |
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## ๐ Documentation
|
|
307
|
+
|
|
308
|
+
- **Full Guide:** `ERROR_LOGGING_GUIDE.md`
|
|
309
|
+
- **Email Setup:** `EMAIL_SETUP_GUIDE.md`
|
|
310
|
+
- **Quick Start:** `QUICK_START_EMAIL.md`
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## โ
Summary
|
|
315
|
+
|
|
316
|
+
**Log Files:**
|
|
317
|
+
- ๐ Location: `node-monitor/examples/logs/`
|
|
318
|
+
- ๐ Format: JSON (one object per line)
|
|
319
|
+
- ๐ Rotation: Daily, kept for 14 days
|
|
320
|
+
- ๐ก๏ธ Security: Sensitive data auto-redacted
|
|
321
|
+
|
|
322
|
+
**Access:**
|
|
323
|
+
- ๐ Web: http://localhost:3001/monitor/error-logs
|
|
324
|
+
- ๐ฅ API: `/monitor/error-logs/:filename?format=json`
|
|
325
|
+
- ๐ File: `logs/error-YYYY-MM-DD.log`
|
|
326
|
+
|
|
327
|
+
**Features:**
|
|
328
|
+
- โ
Automatic logging
|
|
329
|
+
- โ
Beautiful web viewer
|
|
330
|
+
- โ
Email notifications
|
|
331
|
+
- โ
Downloadable logs
|
|
332
|
+
- โ
Stack traces
|
|
333
|
+
- โ
Request details
|
|
334
|
+
|
|
335
|
+
**Perfect for debugging and monitoring your applications!** ๐
|
|
336
|
+
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# ๐ง Quick Start: Email Notifications
|
|
2
|
+
|
|
3
|
+
## โก 3-Step Setup
|
|
4
|
+
|
|
5
|
+
### Step 1: Get Gmail App Password (2 minutes)
|
|
6
|
+
|
|
7
|
+
1. Go to: https://myaccount.google.com/apppasswords
|
|
8
|
+
2. Create App Password for "Mail"
|
|
9
|
+
3. Copy the 16-character password (remove spaces)
|
|
10
|
+
|
|
11
|
+
### Step 2: Update .env File (30 seconds)
|
|
12
|
+
|
|
13
|
+
Open: `node-monitor/examples/.env`
|
|
14
|
+
|
|
15
|
+
Replace:
|
|
16
|
+
```env
|
|
17
|
+
EMAIL_APP_PASSWORD=your-gmail-app-password-here
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
With your password:
|
|
21
|
+
```env
|
|
22
|
+
EMAIL_APP_PASSWORD=abcdefghijklmnop
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Step 3: Restart Server (10 seconds)
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
cd node-monitor/examples
|
|
29
|
+
node express-app.js
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## โ
Test It!
|
|
35
|
+
|
|
36
|
+
Visit: http://localhost:3001/api/notify-test
|
|
37
|
+
|
|
38
|
+
Or click the **"๐ง Test Email"** button on the home page.
|
|
39
|
+
|
|
40
|
+
**Check your inbox:** manish.proses@gmail.com
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## ๐จ What Triggers Email Alerts?
|
|
45
|
+
|
|
46
|
+
| Trigger | Threshold | Email Type |
|
|
47
|
+
|---------|-----------|------------|
|
|
48
|
+
| API Error | Any error | Warning โ ๏ธ |
|
|
49
|
+
| High Error Rate | >10 errors/min | Critical ๐จ |
|
|
50
|
+
| High CPU | >75% | Warning โ ๏ธ |
|
|
51
|
+
| High Memory | >85% | Warning โ ๏ธ |
|
|
52
|
+
| Slow Response | >3 seconds | Warning โ ๏ธ |
|
|
53
|
+
| Server Crash | Any crash | Critical ๐จ |
|
|
54
|
+
| DB Connection Fail | Any failure | Critical ๐จ |
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## ๐งช Quick Tests
|
|
59
|
+
|
|
60
|
+
### Test 1: Send Test Email
|
|
61
|
+
```
|
|
62
|
+
http://localhost:3001/api/notify-test
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Test 2: Trigger Error Alert
|
|
66
|
+
```
|
|
67
|
+
http://localhost:3001/api/error
|
|
68
|
+
```
|
|
69
|
+
(Click twice to trigger consecutive failure alert)
|
|
70
|
+
|
|
71
|
+
### Test 3: Trigger High Error Rate
|
|
72
|
+
```bash
|
|
73
|
+
# Visit error endpoint 15 times
|
|
74
|
+
for i in {1..15}; do curl http://localhost:3001/api/error; done
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## ๐ง Email Format
|
|
80
|
+
|
|
81
|
+
**Subject:** `[Example Express App] ๐จ Critical: High Error Rate`
|
|
82
|
+
|
|
83
|
+
**Content:**
|
|
84
|
+
- Message: Detailed description
|
|
85
|
+
- Application: Example Express App (v1.0.0)
|
|
86
|
+
- Environment: development/production
|
|
87
|
+
- Hostname: Your computer name
|
|
88
|
+
- Time: When it happened
|
|
89
|
+
- Details: Specific metrics
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## ๐ง Troubleshooting
|
|
94
|
+
|
|
95
|
+
**Not receiving emails?**
|
|
96
|
+
|
|
97
|
+
1. โ
Check .env file has correct App Password
|
|
98
|
+
2. โ
Restart the server after updating .env
|
|
99
|
+
3. โ
Visit http://localhost:3001/api/notify-test
|
|
100
|
+
4. โ
Check spam folder
|
|
101
|
+
5. โ
Verify 2-Step Verification is enabled on Gmail
|
|
102
|
+
|
|
103
|
+
**Still not working?**
|
|
104
|
+
|
|
105
|
+
Check server console for:
|
|
106
|
+
- "Email notifier initialized successfully" โ
|
|
107
|
+
- OR "Email transporter verification failed" โ
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## ๐ Full Documentation
|
|
112
|
+
|
|
113
|
+
See: `EMAIL_SETUP_GUIDE.md` for complete details.
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## ๐ฏ You're Done!
|
|
118
|
+
|
|
119
|
+
Once setup is complete, you'll automatically receive emails for:
|
|
120
|
+
- โ
Server errors
|
|
121
|
+
- โ
API failures
|
|
122
|
+
- โ
Performance issues
|
|
123
|
+
- โ
System alerts
|
|
124
|
+
|
|
125
|
+
**No manual intervention needed!** ๐
|
|
126
|
+
|