grpc-prometheus
TypeScript icon, indicating that this package has built-in type declarations

2.1.1 • Public • Published

grpc-prometheus

npm version npm downloads

Interceptor for the server to collect statistics of calls through Prometheus

Install

npm i grpc-prometheus

Usage

const { serverInterceptorsFactory } = require("grpc-prometheus");

/*...*/

const server = await new GrpcHostBuilder()
  /*...*/
  .addInterceptor(
    serverInterceptorsFactory({
      timeBuckets: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 10],
    })
  )
  /*...*/
  .bind(grpcBind)
  .buildAsync();

Metrics example

# HELP grpc_server_handled_total Total number of RPCs completed on the server, regardless of success or failure.
# TYPE grpc_server_handled_total counter
grpc_server_handled_total{grpc_code="OK",grpc_method="SayHello",grpc_service="v1.Greeter",grpc_type="unary"} 1

# HELP grpc_server_handling_seconds Histogram of response latency (seconds) of gRPC that had been application-level handled by the server.
# TYPE grpc_server_handling_seconds histogram
grpc_server_handling_seconds_bucket{le="0.005",grpc_code="OK",grpc_method="SayHello",grpc_service="v1.Greeter",grpc_type="unary"} 1
grpc_server_handling_seconds_bucket{le="0.01",grpc_code="OK",grpc_method="SayHello",grpc_service="v1.Greeter",grpc_type="unary"} 1
grpc_server_handling_seconds_bucket{le="0.025",grpc_code="OK",grpc_method="SayHello",grpc_service="v1.Greeter",grpc_type="unary"} 1
grpc_server_handling_seconds_bucket{le="0.05",grpc_code="OK",grpc_method="SayHello",grpc_service="v1.Greeter",grpc_type="unary"} 1
grpc_server_handling_seconds_bucket{le="0.1",grpc_code="OK",grpc_method="SayHello",grpc_service="v1.Greeter",grpc_type="unary"} 1
grpc_server_handling_seconds_bucket{le="0.25",grpc_code="OK",grpc_method="SayHello",grpc_service="v1.Greeter",grpc_type="unary"} 1
grpc_server_handling_seconds_bucket{le="0.5",grpc_code="OK",grpc_method="SayHello",grpc_service="v1.Greeter",grpc_type="unary"} 1
grpc_server_handling_seconds_bucket{le="1",grpc_code="OK",grpc_method="SayHello",grpc_service="v1.Greeter",grpc_type="unary"} 1
grpc_server_handling_seconds_bucket{le="2.5",grpc_code="OK",grpc_method="SayHello",grpc_service="v1.Greeter",grpc_type="unary"} 1
grpc_server_handling_seconds_bucket{le="10",grpc_code="OK",grpc_method="SayHello",grpc_service="v1.Greeter",grpc_type="unary"} 1
grpc_server_handling_seconds_bucket{le="+Inf",grpc_code="OK",grpc_method="SayHello",grpc_service="v1.Greeter",grpc_type="unary"} 1
grpc_server_handling_seconds_sum{grpc_code="OK",grpc_method="SayHello",grpc_service="v1.Greeter",grpc_type="unary"} 0.001358001
grpc_server_handling_seconds_count{grpc_code="OK",grpc_method="SayHello",grpc_service="v1.Greeter",grpc_type="unary"} 1

Readme

Keywords

Package Sidebar

Install

npm i grpc-prometheus

Weekly Downloads

131

Version

2.1.1

License

MIT

Unpacked Size

10 kB

Total Files

7

Last publish

Collaborators

  • dmitriy.litichevskiy