Collect socket.io
server metrics with Prometheus.
This module has a peer dependency on prom-client
, version 10
and up.
Pass the socket.io
instance to the socket.io-prometheus
module.
const app = require('express')();
const server = require('http').Server(app);
const io = require('socket.io')(server);
const ioMetrics = require('socket.io-prometheus')
const promRegister = require('prom-client').register
// start collecting socket.io metrics
ioMetrics(io);
// expose metrics endpoint
app.get('/metrics', (req, res) => {
res.set('Content-Type', promRegister.contentType)
res.end(promRegister.metrics())
})
all metrics have
socket_io_
prefix in their names.
Name | Help | Labels |
---|---|---|
socket_io_connected |
Number of currently connected sockets | |
socket_io_connect_total |
Total count of socket.io connection requests | |
socket_io_disconnect_total |
Total count of socket.io disconnections | |
socket_io_events_received_total |
Total count of socket.io recieved events | event |
socket_io_events_sent_total |
Total count of socket.io sent events | event |
socket_io_recieve_bytes |
Total socket.io bytes recieved | event |
socket_io_transmit_bytes |
Total socket.io bytes transmitted | event |
Licensed under the MIT License. See the LICENSE file for details.