A Haraka plugin for collecting metrics into Prometheus.
Install with npm
npm install @mailprotector/haraka-plugin-prometheus --save
Enable Haraka's HTTP server (see listen
in http.ini) to listen on port 9904
http.ini:
listen=[::]:9904
Add to plugin
file in the haraka config folder
@mailprotector/haraka-plugin-prometheus
Config options are set in prometheus.json
:
Parameter | Description | Type | Default Value |
---|---|---|---|
enabled | whether to enable the plugin | boolean | true |
prefix | prefix that gets appended to all metrics | string | none |
default_labels | labels to add to all metrics | map | none |
You can push metrics into the connection.notes.prometheus_metrics
array from any other Haraka plugin. They will be collected into Prometheus on the disconnect
hook.
The format of the array is:
connection.notes.prometheus_metrics = [
{ type: 'counter', name 'test_counter', help: '', value: 1, label_names: ['foo', 'bar'] },
{ type: 'gauge', name 'test_gauge', help: '', value: 1, label_names: ['foo', 'bar'] },
{ type: 'histogram', name 'test_histogram', help: '', value: 1, label_names: ['foo', 'bar'] },
{ type: 'summary', name 'test_summary', help: '', value: 1, label_names: ['foo', 'bar'] }
]