egg-prom
v1.0.3
Published
Prometheus plugin for Egg.js
Downloads
4
Readme
forked from eggjs/egg-prometheus 1.4.0
为支持随机端口,修改生命周期和获取配置相关逻辑
egg-prom
Prometheus plugin for egg framework
Install
$ npm i egg-prometheus --save
Usage
Enable the plugin
Change ${app_root}/config/plugin.js
to enable Prometheus plugin:
exports.prometheus = {
enable: true,
package: 'egg-prometheus',
};
Configuration
exports.prometheus = {
scrapePort: 3000,
scrapePath: '/metrics',
defaultLabels: { ... },
};
scrapePort
: the port to scrape metrics fromscrapePath
: the path to scrape metrics fromdefaultLabels
: static labels may be applied to every metric emitted by a registry
Default Metrics
http_response_time_ms summary
: ms to handle a requesthttp_request_rate counter
: number of requests to a route
while egg-rpc-base is enabled
rpc_consumer_response_time_ms summary
: ms of rpc time consumingrpc_consumer_request_rate counter
: number of rpc callsrpc_consumer_fail_response_time_ms summary
: ms of fail rpc time consumingrpc_consumer_request_fail_rate counter
: number of fail rpc callsrpc_consumer_request_size_bytes summary
: rpc request size in bytesrpc_consumer_response_size_bytes summary
: rpc response size in bytesrpc_provider_response_time_ms summary
: ms of request processed timerpc_provider_request_rate counter
: number of rpc callsrpc_provider_fail_response_time_ms summary
: ms of fail request processed timerpc_provider_request_fail_rate counter
: number of fail rpc calls
Custom Metrics
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' ],
});
How to Contribute
Please let us know how can we help. Do check out issues for bug reports or suggestions first.
To become a contributor, please follow our contributing guide.