Jun 28, 2024
const promClient = require('prom-client');
const collectDefaultMetrics = promClient.collectDefaultMetrics;
collectDefaultMetrics({ register: promClient.register });
app.get('/metrics', (req, res) => {
res.set('Content-Type', promClient.register.contentType);
res.end(promClient.register.metrics());
});
npm install winston winston-loki
const winston = require('winston');
const LokiTransport = require('winston-loki');
const logger = winston.createLogger({
transports: [
new LokiTransport({
host: 'http://localhost:3100',
json: true,
}),
],
});