Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
node-client
Advanced tools
npm install node-client --registry=https://npm.finogeeks.club
变量 | 说明 | 默认值 |
---|---|---|
ENABLE_MONITOR | 是否打开监控 | false |
MONITOR_DEFAULT_INTERVAL | 采集nodejs的cpu/mem等指标的时间间隔 | undefined, 即关闭该功能 |
MONITOR_PORT | exporter端口 | 9092 |
MONITOR_PATH | exporter路径 | /metrics |
访问:http://<SERVER_URL>:<MONITOR_PORT>/<MONITOR_PATH>
.
比如,本地调试时可以直接在浏览器访问http://127.0.0.1:9092/metrics
查看已添加的监控指标。
mesons_synapse_requests
const monitor = require('node-client');
const counter = monitor.Counter('mesons_synapse_request', ['code', 'method']);
// 实际上得到了一个Counter类型的指标
const gauge = monitor.Gauge('mesons_synapse_request', ['code', 'status']);
// error: Couter类型的指标不存在dec方法
gauge.dec();
<namespace>_<subsystem>_<metric>
的格式mesons_synapse_counter 1
mesons_synapse_counter{code="200",method="GET"} 10
mesons_synapse_counter{code="404",method="POST"} 20 1497341287055
mesons_synapse_gauge 1
mesons_synapse_gauge{code="400"} 1497341287056
mesons_synapse_gauge{code="200",method="GET"} -2
mesons_synapse_gauge{code="404",method="POST"} 3 1497341287056
mesons_synapse_summary{quantile="0.5",method="GET",code="200"} 20
mesons_synapse_summary{quantile="0.9",method="GET",code="200"} 30
mesons_synapse_summary_sum{code="200",method="GET"} 60
mesons_synapse_summary_count{code="200",method="GET"} 3
mesons_synapse_histogram_bucket{le="10",method="GET",code="200"} 1
mesons_synapse_histogram_bucket{le="15",method="GET",code="200"} 2
mesons_synapse_histogram_bucket{le="+Inf",method="GET",code="200"} 3
mesons_synapse_histogram_sum{code="200",method="GET"} 37
mesons_synapse_histogram_count{code="200",method="GET"} 3
mesons_synapse_gauge_timer 0.000040917
mesons_synapse_summary_timer{quantile="0.5",method="GET",code="200"} 0.000035099
mesons_synapse_summary_timer{quantile="0.9",method="GET",code="200"} 0.000035099
mesons_synapse_summary_timer_sum{code="200",method="GET"} 0.000035099
mesons_synapse_summary_timer_count{code="200",method="GET"} 1
mesons_synapse_histogram_timer_bucket{le="10",code="400",method="POST"} 1
mesons_synapse_histogram_timer_bucket{le="15",code="400",method="POST"} 1
mesons_synapse_histogram_timer_bucket{le="+Inf",code="400",method="POST"} 1
mesons_synapse_histogram_timer_sum{method="POST",code="400"} 0.000043813
mesons_synapse_histogram_timer_count{method="POST",code="400"} 1
mesons_synapse_histogram_timer_bucket{le="10",method="POST",code="500"} 1
mesons_synapse_histogram_timer_bucket{le="15",method="POST",code="500"} 1
mesons_synapse_histogram_timer_bucket{le="+Inf",method="POST",code="500"} 1
mesons_synapse_histogram_timer_sum{code="500",method="POST"} 0.000002668
mesons_synapse_histogram_timer_count{code="500",method="POST"} 1
# 默认指标
process_cpu_user_seconds_total 0.001006 1498200452791
process_cpu_system_seconds_total 0.000042 1498200452791
process_cpu_seconds_total 0.001048 1498200452791
process_start_time_seconds 1498200453 1498200452626
process_resident_memory_bytes 36163584 1498200452792
nodejs_eventloop_lag_seconds 0.015018044 1498200452807
nodejs_active_handles_total 2 1498200452793
nodejs_active_requests_total 0 1498200452793
nodejs_heap_size_total_bytes 19853312 1498200452793
nodejs_heap_size_used_bytes 11901432 1498200452793
nodejs_external_memory_bytes 78171 1498200452793
nodejs_heap_space_size_total_bytes{space="new"} 8388608 1498200452793
nodejs_heap_space_size_total_bytes{space="old"} 7704576 1498200452793
nodejs_heap_space_size_total_bytes{space="code"} 2154496 1498200452793
nodejs_heap_space_size_total_bytes{space="map"} 1069056 1498200452793
nodejs_heap_space_size_total_bytes{space="large_object"} 536576 1498200452793
nodejs_heap_space_size_used_bytes{space="new"} 1648120 1498200452793
nodejs_heap_space_size_used_bytes{space="old"} 7061616 1498200452793
nodejs_heap_space_size_used_bytes{space="code"} 2032832 1498200452793
nodejs_heap_space_size_used_bytes{space="map"} 643192 1498200452793
nodejs_heap_space_size_used_bytes{space="large_object"} 524328 1498200452793
nodejs_heap_space_size_available_bytes{space="new"} 2476552 1498200452793
nodejs_heap_space_size_available_bytes{space="old"} 136 1498200452793
nodejs_heap_space_size_available_bytes{space="code"} 2144 1498200452793
nodejs_heap_space_size_available_bytes{space="map"} 80 1498200452793
nodejs_heap_space_size_available_bytes{space="large_object"} 1478471168 1498200452793
nodejs_version_info{version="v7.7.4",major="7",minor="7",patch="4"} 1 1498200452630
自动监控http中间件,支持express和restify。
const express = require('express');
const monitor = require('node-client');
const app = express();
monitor.Instrument(app);
app.get('/', (req, res) => {
res.send();
});
app.listen(3000, () => {
console.log('express server listening on port 3000');
});
const restify = require('restify');
const mointor = require('node-client');
const server = restify.createServer();
monitor.Instrument(server);
server.get('/', (req, res, done) => {
res.send();
done();
});
server.listen(3000, () => {
console.log('restify server listening on port 3000');
});
FAQs
Nodejs Client for Monitor
The npm package node-client receives a total of 2 weekly downloads. As such, node-client popularity was classified as not popular.
We found that node-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.