Code Monkey home page Code Monkey logo

egg-exporter's Introduction

egg-exporter

Languages: [English] [简体中文]

NPM version npm download

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.

Demonstration

./screenshots/egg-metrics-v1.png

Installation

$ npm i egg-exporter --save

Usages

Start the plugin

Start the plugin with configurations in ${app_root}/config/plugin.js:

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

Configuration

exports.exporter = {
  scrapePort: 3000,
  scrapePath: '/metrics',
  prefix: 'egg_',
  defaultLabels: { stage: 'dev' },
};
  • scrapePort: the port used to scrape metrics
  • scrapePath: the path used for monitoring metrics
  • prefix: the prefix for the metrics names
  • defaultLabels: default metrics labels, globally effective
  • aggregatorPort: the TCP port for RPC

Builtin Metrics

  • http_request_duration_milliseconds histogram: http request duration
  • http_request_size_bytes summary: http request body size
  • http_response_size_bytes summary: http reponse body size
  • http_request_total counter: number of http requests
  • http_all_errors_total counter: number of http erorrs
  • http_all_request_in_processing_total gauge: number of http requests being processed
  • process_resident_memory_bytes gauge: resident memory size
  • nodejs_heap_size_total_bytes gauge: allocated heap memory size
  • nodejs_heap_size_used_bytes gauge: allocated stack memory size
  • nodejs_external_memory_bytes gauge: C++ bind objects memory usage
  • nodejs_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 milliseconds
  • rpc_consumer_request_rate counter: rpc client number of requests
  • rpc_consumer_fail_response_time_ms summary: rpc client failed response time
  • rpc_consumer_request_fail_rate counter: rpc failed requests
  • rpc_consumer_request_size_bytes summary: rpc request size
  • rpc_consumer_response_size_bytes summary: rpc response size
  • rpc_provider_response_time_ms summary: rpc server response time
  • rpc_provider_request_rate counter: rpc server number of requests received
  • rpc_provider_fail_response_time_ms summary: rpc server failed response time in milliseconds
  • rpc_provider_request_fail_rate counter: rpc server failed responses

Customized Metrics

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' ],
});

How to contribute

Please tell us what we can do for you, but before that, check if there are existing bugs or issues.

License

MIT

egg-exporter's People

Contributors

bill0412 avatar gxcsoccer avatar jianglin-wu avatar jinbangyi avatar popomore avatar semantic-release-bot avatar xujihui1985 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.