@@ -7,22 +7,22 @@ sidebar_position: 5
77## Recommended packages
88
99- [ prom-client] ( https://www.npmjs.com/package/prom-client ) . With >300k weekly downloads
10- prom-client is both the most used and most flexible prometheus client. It also has
10+ prom-client is both the most used and most flexible Prometheus client. It also has
1111 a shallow dependency tree.
1212
1313- [ express-prom-bundle] ( https://www.npmjs.com/package/express-prom-bundle ) , version 5
1414 or later. It is based on prom-client and if you are using the Express web
15- framework this is a good way to export prometheus metrics. It's more succinct
15+ framework this is a good way to export Prometheus metrics. It's more succinct
1616 to use to get started, but also more opinionated. Its a reasonable option
1717 until/unless more control or custom metrics are needed.
1818
1919## Guidance
2020
21- - Export prometheus endpoints for containers running Node.js applications. Without
21+ - Export Prometheus endpoints for containers running Node.js applications. Without
2222 these end points it can be difficult monitor your applications. Prometheus is
2323 the defacto standard for exposing metrics in Cloud Native applications. Further
2424 Cloud Native infrastructure (Kubernetes distributions) make it easily to collect
25- prometheus metrics and it is also easy to collect and graph even if you need
25+ Prometheus metrics and it is also easy to collect and graph even if you need
2626 to install the infrastructure components.
2727
2828- Collect and monitor "RED" metrics. Details are available in
@@ -37,35 +37,35 @@ sidebar_position: 5
3737 - error rate - requests which are not handled ok ( status code!=2xx). Expose this metric
3838 as a percentage of the total rate.
3939 - request latency - duration of requests which are handled ok, grouped into ranges/buckets and
40- exposed through a prometheus histogram.
40+ exposed through a Prometheus histogram.
4141
4242- [ prometheus-nodejs-tutorial] ( https://github.com/csantanapr/prometheus-nodejs-tutorial ) provides
4343 examples of using prom-client and express-prom-bundle to collect metrics. Lab 3 and 6
4444 show how to generate the http_request_duration_seconds_bucket metric.
4545
46- Configure prometheus middleware as the first middleware to start the timer as soon as possible.
46+ Configure Prometheus middleware as the first middleware to start the timer as soon as possible.
4747 When setting up the middleware define your expose route for metrics ` /metrics ` before activating the middleware
4848 to avoid calls to ` /metrics ` to be counted as part of the metrics, you can do the same for
49- liveness and readiness checks to define them before prometheus middleware if you want to discard them from your
49+ liveness and readiness checks to define them before Prometheus middleware if you want to discard them from your
5050 http metrics calculations.
5151
52- For success rate the prometheus query would be
52+ For success rate the Prometheus query would be
5353 ` sum(rate(http_request_duration_seconds_count{code="2xx", app="myapp"}[5m])) ` .
5454 The sum over all instances, the rate of change of the request count for app
5555 my app with status_code 2xx over a 5m window
5656
5757 For error rate, but the status_code is usually 4xx or 5xx expressed as [ 45] xx. The
58- prometheus query would be ` sum(rate(http_request_duration_seconds_count{code="[45]xx", app="myapp"}[5m])) ` .
58+ Prometheus query would be ` sum(rate(http_request_duration_seconds_count{code="[45]xx", app="myapp"}[5m])) ` .
5959
6060 For duration, or latency the metric is a histogram so you will graph and
61- monitor percentiles instead of a summary. For example, the prometheus query would be
61+ monitor percentiles instead of a summary. For example, the Prometheus query would be
6262 to get the 95 percentile over all instances over 5m window would be
6363 ` histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket{code="2xx", app="myapp"}[5m])) `
6464
6565- Export additional custom metrics to provide key attributes about the operation of
6666 your application which are not part of the standard metrics.
6767
68- - Be aware that the prometheus client instance needs to be a singleton within your app. For example, if your
68+ - Be aware that the Prometheus client instance needs to be a singleton within your app. For example, if your
6969 application imports separate packages that utilize the "prom-client" package, like customized RabbitMQ &
7070 Redis drivers that write metrics to prom-client, you need to make sure they use the same prom-client instance.
7171 A common way to do that is to make the prom-client instance as an optional parameter in the constructor for
0 commit comments