All Projects → jianglin-wu → egg-exporter

jianglin-wu / egg-exporter

Licence: MIT license
Egg.js 的 Prometheus 指标收集插件,附带 Grafana 看板。

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to egg-exporter

Egg Passport
passport plugin for egg
Stars: ✭ 98 (+308.33%)
Mutual labels:  egg, egg-plugin
Egg Oauth2 Server
🌟 OAuth2 server plugin for egg.js based on node-oauth2-server
Stars: ✭ 174 (+625%)
Mutual labels:  egg, egg-plugin
Egg Router Plus
The missing router feature for eggjs
Stars: ✭ 117 (+387.5%)
Mutual labels:  egg, egg-plugin
Egg View Ejs
egg view plugin for ejs.
Stars: ✭ 54 (+125%)
Mutual labels:  egg, egg-plugin
Egg Validate
validate plugin for egg
Stars: ✭ 224 (+833.33%)
Mutual labels:  egg, egg-plugin
Egg View React Ssr
Egg React Server Side Render (SSR) Plugin
Stars: ✭ 55 (+129.17%)
Mutual labels:  egg, egg-plugin
Egg Multipart
multipart plugin for egg
Stars: ✭ 145 (+504.17%)
Mutual labels:  egg, egg-plugin
Egg Valid
👮Validation plugin for eggjs
Stars: ✭ 10 (-58.33%)
Mutual labels:  egg, egg-plugin
Egg Socket.io
socket.io plugin for eggjs.
Stars: ✭ 209 (+770.83%)
Mutual labels:  egg, egg-plugin
Egg Security
Security plugin for egg, force performance too.
Stars: ✭ 204 (+750%)
Mutual labels:  egg, egg-plugin
Egg Authz
egg-authz is an authorization middleware for Egg.js based on Casbin
Stars: ✭ 50 (+108.33%)
Mutual labels:  egg, egg-plugin
metrics
atomic measures + Prometheus exposition library
Stars: ✭ 22 (-8.33%)
Mutual labels:  prometheus-exporter, metrics-exporter
Egg Cancan
cancancan like authorization plugin for Egg.js
Stars: ✭ 47 (+95.83%)
Mutual labels:  egg, egg-plugin
Egg Schedule
Schedule plugin for egg
Stars: ✭ 76 (+216.67%)
Mutual labels:  egg, egg-plugin
Egg View
Stars: ✭ 35 (+45.83%)
Mutual labels:  egg, egg-plugin
Egg View Vue
vue view plugin for egg
Stars: ✭ 136 (+466.67%)
Mutual labels:  egg, egg-plugin
Egg Restfulapi
🏅 基于Egg.js 2.0 & {mongoose,jwt}RESTful API 模板,用于快速集成开发RESTful前后端分离的服务端。
Stars: ✭ 524 (+2083.33%)
Mutual labels:  egg, egg-plugin
Egg Sequelize
Sequelize for Egg.js
Stars: ✭ 540 (+2150%)
Mutual labels:  egg, egg-plugin
Cool Admin Api
cool-admin-api 是基于egg.js、typeorm、jwt等封装的api开发脚手架、快速开发api接口
Stars: ✭ 188 (+683.33%)
Mutual labels:  egg, egg-plugin
Egg Redis
redis plugin for egg
Stars: ✭ 234 (+875%)
Mutual labels:  egg, egg-plugin

egg-exporter

NPM version npm download

基于 egg-prometheus 开发,增加更多性能指标,为 egg 提供 Prometheus 功能支持。了解更多请看 Node.js 监控方案

展示

./screenshots/egg-metrics-v1.png

安装

$ npm i egg-exporter --save

用法

开启插件

通过 ${app_root}/config/plugin.js 配置启动 Prometheus 插件:

exports.exporter = {
  enable: true,
  package: 'egg-exporter',
};

配置

exports.exporter = {
  scrapePort: 3000,
  scrapePath: '/metrics',
  prefix: 'egg_',
  defaultLabels: { stage: 'dev' },
};
  • scrapePort: 监听的用于采集 metrics 的端口
  • scrapePath: 监听的采集 metrics 的服务路径
  • prefix: 指定 metrics 名称的前缀
  • defaultLabels: 默认的 metrics 标签,全局生效
  • aggregatorPort: 配置 TCP 进程通信所使用的端口

内置的 Metrics

  • http_request_duration_milliseconds histogram: http 请求耗时
  • http_request_size_bytes summary: http 请求 body 大小
  • http_response_size_bytes summary: http 响应 body 大小
  • http_request_total counter: http 请求数
  • http_all_errors_total counter: http 错误数
  • http_all_request_in_processing_total gauge: http 处理中请求数
  • process_resident_memory_bytes gauge: 驻留内存大小
  • nodejs_heap_size_total_bytes gauge: 已申请堆内存大小
  • nodejs_heap_size_used_bytes gauge: 已使用堆内存大小
  • nodejs_external_memory_bytes gauge: V8 管理的,绑定到 Javascript 的 C++ 对象的内存使用情况
  • nodejs_version_info: 版本信息

当 egg-rpc-base 插件开启时,还会提供下面 metrics

  • rpc_consumer_response_time_ms summary: rpc 客户端请求耗时
  • rpc_consumer_request_rate counter: rpc 客户端请求数
  • rpc_consumer_fail_response_time_ms summary: rpc 客户端失败的请求耗时
  • rpc_consumer_request_fail_rate counter: rpc 客户端失败的请求数
  • rpc_consumer_request_size_bytes summary: rpc 请求大小统计
  • rpc_consumer_response_size_bytes summary: rpc 响应大小统计
  • rpc_provider_response_time_ms summary: rpc 服务端处理时间
  • rpc_provider_request_rate counter: rpc 服务端收到请求数
  • rpc_provider_fail_response_time_ms summary: rpc 服务端失败的请求处理时间
  • rpc_provider_request_fail_rate counter: rpc 服务端失败的请求数

自定义 Metrics

可以通过下面 API 自定义业务 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' ],
});

如何贡献

请告知我们可以为你做些什么,不过在此之前,请检查一下是否有已经存在的Bug或者意见

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].