From d0847a8bf677d7bc1668a185dc7dea72e2710038 Mon Sep 17 00:00:00 2001 From: Frank Nagel Date: Wed, 9 Jun 2021 09:44:27 +0200 Subject: [PATCH] docs: Add documentation for prometheus-middleware --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 3b15cbbb..c5a2c120 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,25 @@ getting elasticsearch to work, have a look in the [README](https://gitlab.com/openstapps/database) of the image first. +## Metrics collection +The backend contains an express middleware which can be optionally enabled by setting the environment variable +`PROMETHEUS_MIDDLEWARE` to `true`. The middleware collects metrics and provides a [Prometheus](https://prometheus.io/) +compatible endpoint from which the metrics may be scraped by Prometheus. + +The middleware may be configured with JSON provided in `config/prometheus.json`, i.e. + +```JSON +{ + "metricsPath": "/metrics", + "collectDefaultMetrics": true, + "requestDurationBuckets": [0.1, 0.5, 1, 2], + "requestLengthBuckets": [512, 1024, 5120, 10240, 51200, 102400], + "responseLengthBuckets": [512, 1024, 5120, 10240, 51200, 102400] +} +``` + +You can get a compatible grafana dashboard at [grafana.com](https://grafana.com/grafana/dashboards/14565). + ## Start backend Run `npm install` and `npm run build`, then start with `npm start`. The server should now be accepting connections at `http://localhost:3000`. @@ -79,6 +98,7 @@ The list of environment variables includes: * `ES_FORCE_MAPPING_UPDATE` when this variable is set to `true`, the backend will always generate a new Elasticsearch mapping from the core regardless of whether there is already a version present. This should only really be used when you are working on the core. * `ALLOW_NO_TRANSPORT` if set to true, the backend will allow starting without an Email configured that receives critical errors. * `ES_DEBUG` setting this to `true` will result in Elasticsearch logging to be **VERY** extensive, in almost all situation this should no be enabled. +* `PROMETHEUS_MIDDLEWARE` if set to `true` will enable metrics collection with [Express Prometheus Middleware](https://www.npmjs.com/package/express-prometheus-middleware) ## Config files Each university can have it's specific config for the general backend and app and for all databases.