Coder Social home page Coder Social logo

egg-prometheus's Introduction

egg-prometheus

Prometheus plugin for egg framework

NPM version build status Test coverage David deps Known Vulnerabilities npm download

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 = {
  timeout: 3000
  scrapePort: 3000,
  scrapePath: '/metrics',
  defaultHttpMetricsFilter: ({ method, status, routerName, path }) => true,
  defaultLabels: { ... },
};
  • timeout: metrics pull timeout
  • scrapePort: the port to scrape metrics from
  • scrapePath: the path to scrape metrics from
  • defaultLabels: static labels may be applied to every metric emitted by a registry
  • defaultHttpMetricsFilter: can custom filter default http metrics, return false can prevent metrics

Default Metrics

  • http_response_time_ms summary: ms to handle a request
  • http_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 consuming
  • rpc_consumer_request_rate counter: number of rpc calls
  • rpc_consumer_fail_response_time_ms summary: ms of fail rpc time consuming
  • rpc_consumer_request_fail_rate counter: number of fail rpc calls
  • rpc_consumer_request_size_bytes summary: rpc request size in bytes
  • rpc_consumer_response_size_bytes summary: rpc response size in bytes
  • rpc_provider_response_time_ms summary: ms of request processed time
  • rpc_provider_request_rate counter: number of rpc calls
  • rpc_provider_fail_response_time_ms summary: ms of fail request processed time
  • rpc_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.

License

MIT

egg-prometheus's People

Contributors

gxcsoccer avatar jgchenu avatar popomore avatar sjfkai avatar xujihui1985 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

egg-prometheus's Issues

pid 无法删除

服务开启多进程 出现多个 pid, 对数据整合有干扰,指标中有默认的pid ,无法删除,官方有提供删除的办法嘛

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.