prometheus-metrics
Utility to generate prometheus metrics based on tasks from config
How to use
Install
npm install @akasybe/prometheus-metrics --save-dev
Create config file
Create file metrics.config.js
in root directory:
moduleexports = output: "build/metrics.txt" tasks: type: "size" path: "build/*.js" labels: compression: "gzip" type: "javascript" project: "app" // optional, 'bundle_size_bytes_total` is default value // metricName: "bundle_size_bytes_total" type: "custom" // client is default export from 'prom-client' library { // you can create any valid metric, please refer to 'prom-client' docs const metric = name: "metric_name" help: "metric_help" ; // calculate metric value metric; // and do not forget to return metric return metric; } ;
Supported 2 task types: size
and custom
.
- Task with type
size
should havepath
as glob pattern andlabels
(these are prometheus labels) - Task with type
custom
should haveresolve
method that returns singleprom-client
metric
Add script
Add script in package.json
:
"scripts":
Run
npm run metrics
Now go to output
directory and look at metrics.txt
file