mongo-prometheus
Connector from mongodb to prometheus client that is ready to be scraped.
Pre-requisite and requirement
node
> 8- Make sure
mongodb
is installed - Enable oplog to your mongo
Installation and Usage
Quickstart
- Install the module in your project directory
npm install mongo-prometheus
- Initialize the class with proper config and ETL function
const MongoPrometheus = ; const config = database: "test" collection: "requests" job: "mongo-prometheus" defaultMetrics: true; const etl = { const record = metric: "test_metric" value: datatotal type: "counter" label: "test" ;} config etl;
- Navigate to
http://localhost:1337/metrics
Here are some more details explanation about the config.
database
: database of mongo to check oplogcollection
: collection of mongo to check oplogjob
: job as a label for prometheus scrapeendpoint
: Endpoint of the metrics for scraping. Default is/metrics
port
: Port of the metrics for scraping. Default is3031
defaultMetrics
: Generate the default performance metrics. Default isfalse