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
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# PMS_MD
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Getting started
|
|
6
|
+
|
|
7
|
+
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
8
|
+
|
|
9
|
+
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
10
|
+
|
|
11
|
+
## Add your files
|
|
12
|
+
|
|
13
|
+
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
|
14
|
+
- [ ] [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
cd existing_repo
|
|
18
|
+
git remote add origin https://gitlab.com/manish-proses/pms_md.git
|
|
19
|
+
git branch -M main
|
|
20
|
+
git push -uf origin main
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Integrate with your tools
|
|
24
|
+
|
|
25
|
+
- [ ] [Set up project integrations](https://gitlab.com/manish-proses/pms_md/-/settings/integrations)
|
|
26
|
+
|
|
27
|
+
## Collaborate with your team
|
|
28
|
+
|
|
29
|
+
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
|
30
|
+
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
|
31
|
+
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
|
32
|
+
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
|
33
|
+
- [ ] [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
|
|
34
|
+
|
|
35
|
+
## Test and Deploy
|
|
36
|
+
|
|
37
|
+
Use the built-in continuous integration in GitLab.
|
|
38
|
+
|
|
39
|
+
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/)
|
|
40
|
+
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
|
41
|
+
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
|
42
|
+
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
|
43
|
+
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
|
44
|
+
|
|
45
|
+
***
|
|
46
|
+
|
|
47
|
+
# Editing this README
|
|
48
|
+
|
|
49
|
+
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
50
|
+
|
|
51
|
+
## Suggestions for a good README
|
|
52
|
+
|
|
53
|
+
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
54
|
+
|
|
55
|
+
## Name
|
|
56
|
+
Choose a self-explaining name for your project.
|
|
57
|
+
|
|
58
|
+
## Description
|
|
59
|
+
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
60
|
+
|
|
61
|
+
## Badges
|
|
62
|
+
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
63
|
+
|
|
64
|
+
## Visuals
|
|
65
|
+
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
69
|
+
|
|
70
|
+
## Usage
|
|
71
|
+
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
72
|
+
|
|
73
|
+
## Support
|
|
74
|
+
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
75
|
+
|
|
76
|
+
## Roadmap
|
|
77
|
+
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
78
|
+
|
|
79
|
+
## Contributing
|
|
80
|
+
State if you are open to contributions and what your requirements are for accepting them.
|
|
81
|
+
|
|
82
|
+
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
83
|
+
|
|
84
|
+
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
85
|
+
|
|
86
|
+
## Authors and acknowledgment
|
|
87
|
+
Show your appreciation to those who have contributed to the project.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
For open source projects, say how it is licensed.
|
|
91
|
+
|
|
92
|
+
## Project status
|
|
93
|
+
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
# Node Monitor - Architecture Overview
|
|
2
|
+
|
|
3
|
+
## System Architecture
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
7
|
+
│ Node Monitor │
|
|
8
|
+
│ │
|
|
9
|
+
│ ┌────────────────────────────────────────────────────────────┐ │
|
|
10
|
+
│ │ Main Monitor Class │ │
|
|
11
|
+
│ │ (Orchestrates all components) │ │
|
|
12
|
+
│ └────────────────────────────────────────────────────────────┘ │
|
|
13
|
+
│ │ │
|
|
14
|
+
│ ┌────────────────────┼────────────────────┐ │
|
|
15
|
+
│ │ │ │ │
|
|
16
|
+
│ ▼ ▼ ▼ │
|
|
17
|
+
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
|
18
|
+
│ │ Config │ │ Logger │ │ Notifier │ │
|
|
19
|
+
│ │ Manager │ │ Module │ │ Manager │ │
|
|
20
|
+
│ └─────────────┘ └─────────────┘ └─────────────┘ │
|
|
21
|
+
│ │ │
|
|
22
|
+
│ ┌────────┼────────┐ │
|
|
23
|
+
│ ▼ ▼ ▼ │
|
|
24
|
+
│ Email Slack SMS │
|
|
25
|
+
│ │
|
|
26
|
+
│ ┌──────────────────────────────────────────────────────────┐ │
|
|
27
|
+
│ │ Monitor Modules │ │
|
|
28
|
+
│ │ │ │
|
|
29
|
+
│ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │
|
|
30
|
+
│ │ │ API Error │ │ Server │ │ System │ │ │
|
|
31
|
+
│ │ │ Monitor │ │ Health │ │ Resource │ │ │
|
|
32
|
+
│ │ │ │ │ Monitor │ │ Monitor │ │ │
|
|
33
|
+
│ │ └──────────────┘ └──────────────┘ └──────────────┘ │ │
|
|
34
|
+
│ │ │ │
|
|
35
|
+
│ │ ┌──────────────┐ │ │
|
|
36
|
+
│ │ │ Database │ │ │
|
|
37
|
+
│ │ │ Connection │ │ │
|
|
38
|
+
│ │ │ Monitor │ │ │
|
|
39
|
+
│ │ └──────────────┘ │ │
|
|
40
|
+
│ └──────────────────────────────────────────────────────────┘ │
|
|
41
|
+
└───────────────────────────────────────────────────────────────┘
|
|
42
|
+
│
|
|
43
|
+
▼
|
|
44
|
+
┌──────────────────┐
|
|
45
|
+
│ Your Express │
|
|
46
|
+
│ Application │
|
|
47
|
+
└──────────────────┘
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Component Breakdown
|
|
51
|
+
|
|
52
|
+
### 1. Configuration Manager (`MonitoringConfig`)
|
|
53
|
+
|
|
54
|
+
**Responsibilities:**
|
|
55
|
+
- Load configuration from environment variables
|
|
56
|
+
- Merge with user-provided config
|
|
57
|
+
- Validate configuration
|
|
58
|
+
- Provide configuration access to all components
|
|
59
|
+
|
|
60
|
+
**Key Features:**
|
|
61
|
+
- Environment variable support
|
|
62
|
+
- Deep merge of configurations
|
|
63
|
+
- Validation with helpful error messages
|
|
64
|
+
- Sanitized config output (hides sensitive data)
|
|
65
|
+
|
|
66
|
+
### 2. Logger Module (`ErrorLogger`)
|
|
67
|
+
|
|
68
|
+
**Responsibilities:**
|
|
69
|
+
- Log all events (errors, warnings, info)
|
|
70
|
+
- Track error frequency
|
|
71
|
+
- Rotate log files
|
|
72
|
+
- Sanitize sensitive data
|
|
73
|
+
|
|
74
|
+
**Key Features:**
|
|
75
|
+
- Winston-based logging
|
|
76
|
+
- Daily log rotation
|
|
77
|
+
- Multiple output formats (JSON, text)
|
|
78
|
+
- Console and file outputs
|
|
79
|
+
- Error rate tracking
|
|
80
|
+
- Automatic sensitive data redaction
|
|
81
|
+
|
|
82
|
+
### 3. Notification Manager (`NotificationManager`)
|
|
83
|
+
|
|
84
|
+
**Responsibilities:**
|
|
85
|
+
- Coordinate all notification channels
|
|
86
|
+
- Manage cooldown periods
|
|
87
|
+
- Format messages for different channels
|
|
88
|
+
|
|
89
|
+
**Supported Channels:**
|
|
90
|
+
- Email (via Nodemailer)
|
|
91
|
+
- Slack (via Webhooks)
|
|
92
|
+
- SMS (planned - Twilio)
|
|
93
|
+
|
|
94
|
+
**Alert Levels:**
|
|
95
|
+
- Critical (🔴)
|
|
96
|
+
- Warning (⚠️)
|
|
97
|
+
- Info (ℹ️)
|
|
98
|
+
- Recovery (✅)
|
|
99
|
+
|
|
100
|
+
### 4. API Error Monitor (`ApiErrorMonitor`)
|
|
101
|
+
|
|
102
|
+
**Responsibilities:**
|
|
103
|
+
- Track API errors via middleware
|
|
104
|
+
- Log request/response details
|
|
105
|
+
- Monitor error rates
|
|
106
|
+
- Detect slow requests
|
|
107
|
+
- Handle 404s
|
|
108
|
+
|
|
109
|
+
**Integration Points:**
|
|
110
|
+
- Express error middleware
|
|
111
|
+
- Request logger middleware
|
|
112
|
+
- 404 handler
|
|
113
|
+
- Async handler wrapper
|
|
114
|
+
|
|
115
|
+
### 5. Server Health Monitor (`ServerHealthMonitor`)
|
|
116
|
+
|
|
117
|
+
**Responsibilities:**
|
|
118
|
+
- Periodic health checks
|
|
119
|
+
- Custom health check registration
|
|
120
|
+
- Uptime tracking
|
|
121
|
+
- Graceful shutdown handling
|
|
122
|
+
- Uncaught exception handling
|
|
123
|
+
|
|
124
|
+
**Features:**
|
|
125
|
+
- Customizable health checks
|
|
126
|
+
- Health check endpoints
|
|
127
|
+
- Consecutive failure tracking
|
|
128
|
+
- Recovery notifications
|
|
129
|
+
- Process signal handling
|
|
130
|
+
|
|
131
|
+
### 6. System Resource Monitor (`SystemResourceMonitor`)
|
|
132
|
+
|
|
133
|
+
**Responsibilities:**
|
|
134
|
+
- Monitor CPU usage (process and system)
|
|
135
|
+
- Monitor memory usage
|
|
136
|
+
- Track metrics history
|
|
137
|
+
- Alert on threshold breaches
|
|
138
|
+
|
|
139
|
+
**Metrics Tracked:**
|
|
140
|
+
- CPU percentage (process and system-wide)
|
|
141
|
+
- Memory usage (heap, RSS, total)
|
|
142
|
+
- System information
|
|
143
|
+
- Historical data (last 60 readings)
|
|
144
|
+
|
|
145
|
+
### 7. Database Connection Monitor (`DbConnectionMonitor`)
|
|
146
|
+
|
|
147
|
+
**Responsibilities:**
|
|
148
|
+
- Monitor database connections
|
|
149
|
+
- Perform health checks
|
|
150
|
+
- Track connection statistics
|
|
151
|
+
- Alert on connection failures
|
|
152
|
+
|
|
153
|
+
**Supported Databases:**
|
|
154
|
+
- MongoDB (via Mongoose)
|
|
155
|
+
- PostgreSQL
|
|
156
|
+
- MySQL
|
|
157
|
+
- Redis
|
|
158
|
+
|
|
159
|
+
## Data Flow
|
|
160
|
+
|
|
161
|
+
### 1. Error Tracking Flow
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
Request → Express App → Error Occurs
|
|
165
|
+
│
|
|
166
|
+
▼
|
|
167
|
+
Error Middleware
|
|
168
|
+
│
|
|
169
|
+
├─→ Log Error (ErrorLogger)
|
|
170
|
+
│
|
|
171
|
+
├─→ Check Error Rate
|
|
172
|
+
│
|
|
173
|
+
├─→ Send Alert (if threshold exceeded)
|
|
174
|
+
│
|
|
175
|
+
└─→ Send Response to Client
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### 2. Health Check Flow
|
|
179
|
+
|
|
180
|
+
```
|
|
181
|
+
Cron Schedule → Health Monitor
|
|
182
|
+
│
|
|
183
|
+
├─→ Run Custom Checks
|
|
184
|
+
│
|
|
185
|
+
├─→ Aggregate Results
|
|
186
|
+
│
|
|
187
|
+
├─→ Compare with Previous Status
|
|
188
|
+
│
|
|
189
|
+
└─→ Send Alert (if status changed)
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### 3. System Monitoring Flow
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
Cron Schedule → System Monitor
|
|
196
|
+
│
|
|
197
|
+
├─→ Collect CPU Metrics
|
|
198
|
+
│
|
|
199
|
+
├─→ Collect Memory Metrics
|
|
200
|
+
│
|
|
201
|
+
├─→ Store in History
|
|
202
|
+
│
|
|
203
|
+
├─→ Check Thresholds
|
|
204
|
+
│
|
|
205
|
+
└─→ Send Alert (if exceeded)
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### 4. Notification Flow
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
Alert Triggered → Notification Manager
|
|
212
|
+
│
|
|
213
|
+
├─→ Check Cooldown Period
|
|
214
|
+
│
|
|
215
|
+
├─→ Format Message
|
|
216
|
+
│
|
|
217
|
+
├─→ Send to Email
|
|
218
|
+
│
|
|
219
|
+
├─→ Send to Slack
|
|
220
|
+
│
|
|
221
|
+
├─→ Send to SMS
|
|
222
|
+
│
|
|
223
|
+
└─→ Log Result
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Design Patterns
|
|
227
|
+
|
|
228
|
+
### 1. Singleton Pattern
|
|
229
|
+
- `NodeMonitor` class is typically instantiated once per application
|
|
230
|
+
|
|
231
|
+
### 2. Observer Pattern
|
|
232
|
+
- Monitors observe application state and notify when thresholds are exceeded
|
|
233
|
+
|
|
234
|
+
### 3. Strategy Pattern
|
|
235
|
+
- Different notification strategies (Email, Slack, SMS)
|
|
236
|
+
- Different database monitoring strategies
|
|
237
|
+
|
|
238
|
+
### 4. Middleware Pattern
|
|
239
|
+
- Express middleware for error tracking and request logging
|
|
240
|
+
|
|
241
|
+
### 5. Factory Pattern
|
|
242
|
+
- Creating different types of monitors based on configuration
|
|
243
|
+
|
|
244
|
+
## Security Considerations
|
|
245
|
+
|
|
246
|
+
### 1. Data Sanitization
|
|
247
|
+
- Automatic redaction of sensitive fields
|
|
248
|
+
- Configurable sensitive field list
|
|
249
|
+
- Applied to all logs and notifications
|
|
250
|
+
|
|
251
|
+
### 2. Credential Management
|
|
252
|
+
- Environment variable support
|
|
253
|
+
- No hardcoded credentials
|
|
254
|
+
- Sanitized config output
|
|
255
|
+
|
|
256
|
+
### 3. Rate Limiting
|
|
257
|
+
- Cooldown periods prevent notification spam
|
|
258
|
+
- Configurable per alert type
|
|
259
|
+
|
|
260
|
+
### 4. Secure Communication
|
|
261
|
+
- HTTPS for webhooks
|
|
262
|
+
- TLS for email (STARTTLS)
|
|
263
|
+
- Encrypted credential storage recommended
|
|
264
|
+
|
|
265
|
+
## Scalability
|
|
266
|
+
|
|
267
|
+
### 1. Horizontal Scaling
|
|
268
|
+
- Each instance monitors independently
|
|
269
|
+
- Centralized logging recommended (ELK, CloudWatch)
|
|
270
|
+
- Shared notification channels
|
|
271
|
+
|
|
272
|
+
### 2. Performance
|
|
273
|
+
- Non-blocking operations
|
|
274
|
+
- Scheduled checks (not continuous)
|
|
275
|
+
- Configurable intervals
|
|
276
|
+
- Minimal overhead
|
|
277
|
+
|
|
278
|
+
### 3. Resource Usage
|
|
279
|
+
- Low memory footprint
|
|
280
|
+
- CPU usage < 1% typically
|
|
281
|
+
- Configurable metric history size
|
|
282
|
+
|
|
283
|
+
## Extension Points
|
|
284
|
+
|
|
285
|
+
### 1. Custom Monitors
|
|
286
|
+
```javascript
|
|
287
|
+
class CustomMonitor {
|
|
288
|
+
constructor(config, logger, notificationManager) {
|
|
289
|
+
// Your implementation
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
start() { /* ... */ }
|
|
293
|
+
stop() { /* ... */ }
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### 2. Custom Notifiers
|
|
298
|
+
```javascript
|
|
299
|
+
class CustomNotifier {
|
|
300
|
+
async send(alertType, subject, message, details) {
|
|
301
|
+
// Your implementation
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### 3. Custom Health Checks
|
|
307
|
+
```javascript
|
|
308
|
+
monitor.registerHealthCheck('custom', async () => {
|
|
309
|
+
// Your check logic
|
|
310
|
+
return true; // or false
|
|
311
|
+
});
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
## Future Enhancements
|
|
315
|
+
|
|
316
|
+
1. **Metrics Export**
|
|
317
|
+
- Prometheus format
|
|
318
|
+
- StatsD support
|
|
319
|
+
- Custom metrics API
|
|
320
|
+
|
|
321
|
+
2. **Advanced Analytics**
|
|
322
|
+
- Trend analysis
|
|
323
|
+
- Anomaly detection
|
|
324
|
+
- Predictive alerts
|
|
325
|
+
|
|
326
|
+
3. **Web Dashboard**
|
|
327
|
+
- Real-time metrics
|
|
328
|
+
- Historical charts
|
|
329
|
+
- Alert management
|
|
330
|
+
|
|
331
|
+
4. **Distributed Tracing**
|
|
332
|
+
- Request correlation
|
|
333
|
+
- Microservices support
|
|
334
|
+
- OpenTelemetry integration
|
|
335
|
+
|
|
336
|
+
5. **Advanced Notifications**
|
|
337
|
+
- PagerDuty integration
|
|
338
|
+
- Discord/Telegram support
|
|
339
|
+
- Custom webhooks
|
|
340
|
+
- Alert routing rules
|
|
341
|
+
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.0] - 2024-01-15
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial release of Node Monitor
|
|
12
|
+
- API error tracking with Express middleware
|
|
13
|
+
- Server health monitoring with customizable health checks
|
|
14
|
+
- System resource monitoring (CPU, memory)
|
|
15
|
+
- Database connection monitoring for MongoDB, PostgreSQL, MySQL, and Redis
|
|
16
|
+
- Email notifications via Nodemailer
|
|
17
|
+
- Slack notifications via webhooks
|
|
18
|
+
- Advanced logging with Winston and daily rotation
|
|
19
|
+
- Configurable thresholds and intervals
|
|
20
|
+
- Environment variable support
|
|
21
|
+
- Sensitive data sanitization
|
|
22
|
+
- Graceful shutdown handling
|
|
23
|
+
- Monitoring dashboard endpoints
|
|
24
|
+
- Comprehensive documentation and examples
|
|
25
|
+
- Example Express application
|
|
26
|
+
- Setup guide for production deployment
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
- **Error Tracking**
|
|
30
|
+
- Automatic API error logging
|
|
31
|
+
- Error rate monitoring with alerts
|
|
32
|
+
- Stack trace capture
|
|
33
|
+
- Request context logging
|
|
34
|
+
- Slow request detection
|
|
35
|
+
|
|
36
|
+
- **Health Monitoring**
|
|
37
|
+
- Customizable health checks
|
|
38
|
+
- Heartbeat mechanism
|
|
39
|
+
- Uptime tracking
|
|
40
|
+
- Graceful shutdown support
|
|
41
|
+
- Uncaught exception handling
|
|
42
|
+
|
|
43
|
+
- **System Monitoring**
|
|
44
|
+
- CPU usage tracking (process and system)
|
|
45
|
+
- Memory usage monitoring
|
|
46
|
+
- Configurable alert thresholds
|
|
47
|
+
- Historical metrics tracking
|
|
48
|
+
- System information reporting
|
|
49
|
+
|
|
50
|
+
- **Database Monitoring**
|
|
51
|
+
- Connection health checks
|
|
52
|
+
- Support for multiple database types
|
|
53
|
+
- Connection statistics
|
|
54
|
+
- Automatic reconnection detection
|
|
55
|
+
- Query timeout handling
|
|
56
|
+
|
|
57
|
+
- **Notifications**
|
|
58
|
+
- Multi-channel support (Email, Slack)
|
|
59
|
+
- Alert level classification (Critical, Warning, Info, Recovery)
|
|
60
|
+
- Cooldown periods to prevent spam
|
|
61
|
+
- Rich formatting for emails and Slack
|
|
62
|
+
- Configurable recipients
|
|
63
|
+
|
|
64
|
+
- **Logging**
|
|
65
|
+
- Winston-based logging
|
|
66
|
+
- Daily log rotation
|
|
67
|
+
- Multiple log levels
|
|
68
|
+
- JSON and text formats
|
|
69
|
+
- Console and file outputs
|
|
70
|
+
- Sensitive data sanitization
|
|
71
|
+
|
|
72
|
+
### Security
|
|
73
|
+
- Automatic sanitization of sensitive fields (passwords, tokens, API keys)
|
|
74
|
+
- Environment variable support for credentials
|
|
75
|
+
- Configurable sensitive field list
|
|
76
|
+
- Secure SMTP and webhook communication
|
|
77
|
+
|
|
78
|
+
### Documentation
|
|
79
|
+
- Comprehensive README with examples
|
|
80
|
+
- Complete setup guide
|
|
81
|
+
- API reference
|
|
82
|
+
- Configuration guide
|
|
83
|
+
- Troubleshooting section
|
|
84
|
+
- Example application
|
|
85
|
+
|
|
86
|
+
## [Unreleased]
|
|
87
|
+
|
|
88
|
+
### Planned Features
|
|
89
|
+
- SMS notifications via Twilio
|
|
90
|
+
- Discord/Telegram webhook support
|
|
91
|
+
- PagerDuty integration
|
|
92
|
+
- Prometheus metrics export
|
|
93
|
+
- Grafana dashboard templates
|
|
94
|
+
- Custom metric tracking
|
|
95
|
+
- Performance profiling
|
|
96
|
+
- Memory leak detection
|
|
97
|
+
- Event loop lag monitoring
|
|
98
|
+
- Request rate limiting monitoring
|
|
99
|
+
- WebSocket connection monitoring
|
|
100
|
+
- Microservices distributed tracing
|
|
101
|
+
- Custom alert rules engine
|
|
102
|
+
- Web-based dashboard UI
|
|
103
|
+
- Historical data persistence
|
|
104
|
+
- Metrics aggregation and analytics
|
|
105
|
+
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Contributing to Node Monitor
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to Node Monitor! This document provides guidelines and instructions for contributing.
|
|
4
|
+
|
|
5
|
+
## Code of Conduct
|
|
6
|
+
|
|
7
|
+
Please be respectful and constructive in all interactions. We aim to maintain a welcoming and inclusive community.
|
|
8
|
+
|
|
9
|
+
## How to Contribute
|
|
10
|
+
|
|
11
|
+
### Reporting Bugs
|
|
12
|
+
|
|
13
|
+
1. Check if the bug has already been reported in [Issues](https://github.com/yourorg/node-monitor/issues)
|
|
14
|
+
2. If not, create a new issue with:
|
|
15
|
+
- Clear title and description
|
|
16
|
+
- Steps to reproduce
|
|
17
|
+
- Expected vs actual behavior
|
|
18
|
+
- Environment details (Node version, OS, etc.)
|
|
19
|
+
- Relevant logs or error messages
|
|
20
|
+
|
|
21
|
+
### Suggesting Features
|
|
22
|
+
|
|
23
|
+
1. Check existing issues and discussions
|
|
24
|
+
2. Create a new issue with:
|
|
25
|
+
- Clear description of the feature
|
|
26
|
+
- Use cases and benefits
|
|
27
|
+
- Possible implementation approach
|
|
28
|
+
- Any potential drawbacks
|
|
29
|
+
|
|
30
|
+
### Pull Requests
|
|
31
|
+
|
|
32
|
+
1. Fork the repository
|
|
33
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
34
|
+
3. Make your changes
|
|
35
|
+
4. Write or update tests
|
|
36
|
+
5. Update documentation
|
|
37
|
+
6. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
38
|
+
7. Push to the branch (`git push origin feature/amazing-feature`)
|
|
39
|
+
8. Open a Pull Request
|
|
40
|
+
|
|
41
|
+
## Development Setup
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Clone the repository
|
|
45
|
+
git clone https://github.com/yourorg/node-monitor.git
|
|
46
|
+
cd node-monitor
|
|
47
|
+
|
|
48
|
+
# Install dependencies
|
|
49
|
+
npm install
|
|
50
|
+
|
|
51
|
+
# Run example application
|
|
52
|
+
npm run example
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Coding Standards
|
|
56
|
+
|
|
57
|
+
- Use ES6+ features
|
|
58
|
+
- Follow existing code style
|
|
59
|
+
- Add JSDoc comments for public APIs
|
|
60
|
+
- Keep functions focused and small
|
|
61
|
+
- Use meaningful variable names
|
|
62
|
+
- Handle errors appropriately
|
|
63
|
+
|
|
64
|
+
## Testing
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Run tests
|
|
68
|
+
npm test
|
|
69
|
+
|
|
70
|
+
# Run tests with coverage
|
|
71
|
+
npm run test:coverage
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Documentation
|
|
75
|
+
|
|
76
|
+
- Update README.md for user-facing changes
|
|
77
|
+
- Update SETUP_GUIDE.md for configuration changes
|
|
78
|
+
- Add JSDoc comments for new functions
|
|
79
|
+
- Update CHANGELOG.md
|
|
80
|
+
|
|
81
|
+
## Commit Messages
|
|
82
|
+
|
|
83
|
+
Use clear and descriptive commit messages:
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
feat: Add SMS notification support
|
|
87
|
+
fix: Resolve memory leak in metrics tracking
|
|
88
|
+
docs: Update configuration examples
|
|
89
|
+
refactor: Simplify error handling logic
|
|
90
|
+
test: Add tests for database monitoring
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
By contributing, you agree that your contributions will be licensed under the MIT License.
|
|
96
|
+
|