Languages: [English] [简体中文]
This project is based on egg-prometheus, with more performance metrics. It provides more Prometheus functionalities for egg. For more information, please refer to Node.js monitering solutions.
$ npm i egg-exporter --save
Start the plugin with configurations in ${app_root}/config/plugin.js
:
exports.exporter = {
enable: true,
package: 'egg-exporter',
};
exports.exporter = {
scrapePort: 3000,
scrapePath: '/metrics',
prefix: 'egg_',
defaultLabels: { stage: 'dev' },
};
scrapePort
: the port used to scrape metricsscrapePath
: the path used for monitoring metricsprefix
: the prefix for the metrics namesdefaultLabels
: default metrics labels, globally effectiveaggregatorPort
: the TCP port for RPC
http_request_duration_milliseconds histogram
: http request durationhttp_request_size_bytes summary
: http request body sizehttp_response_size_bytes summary
: http reponse body sizehttp_request_total counter
: number of http requestshttp_all_errors_total counter
: number of http erorrshttp_all_request_in_processing_total gauge
: number of http requests being processedprocess_resident_memory_bytes gauge
: resident memory sizenodejs_heap_size_total_bytes gauge
: allocated heap memory sizenodejs_heap_size_used_bytes gauge
: allocated stack memory sizenodejs_external_memory_bytes gauge
: C++ bind objects memory usagenodejs_version_info
: version information
When the egg-rpc-base plugin is enabled, the following metrics are also provided
rpc_consumer_response_time_ms summary
: rpc client response time in millisecondsrpc_consumer_request_rate counter
: rpc client number of requestsrpc_consumer_fail_response_time_ms summary
: rpc client failed response timerpc_consumer_request_fail_rate counter
: rpc failed requestsrpc_consumer_request_size_bytes summary
: rpc request sizerpc_consumer_response_size_bytes summary
: rpc response sizerpc_provider_response_time_ms summary
: rpc server response timerpc_provider_request_rate counter
: rpc server number of requests receivedrpc_provider_fail_response_time_ms summary
: rpc server failed response time in millisecondsrpc_provider_request_fail_rate counter
: rpc server failed responses
You may use the following API to customize metrics in your business logics.
const counter = new app.prometheus.Counter({
name: 'xxx_total',
help: 'custom counter',
labelNames: [ 'xxx' ],
});
const gauge = new app.prometheus.Gauge({
name: 'xxx_gauge',
help: 'custom gauge',
labelNames: [ 'xxx' ],
});
const histogram = new app.prometheus.Histogram({
name: 'xxx_histogram',
help: 'custom histogram',
labelNames: [ 'xxx' ],
});
const summary = new app.prometheus.Summary({
name: 'xxx_summary',
help: 'custom summary',
labelNames: [ 'xxx' ],
});
Please tell us what we can do for you, but before that, check if there are existing bugs or issues.