kokutele / mediasoup-exporter

mediasoup exporter for prometheus
6 stars 1 forks source link

mediasoup-exporter

caution: Do not use this library in production system, which means experimental use cases only. This exporter has a scalability problem. It stores each metrics with labels of consumerIds and producerIds, which is agaist this best practice.

how to use

npm install mediasoup-exporter

we are assuming that library mediasoup is installed already.

snipet

const exporter = require('mediasoup-exporter')

(async () => {
  // ...snip...
  // before starting Mediasoup server

  await exporter( { port: 4000 } )

  // ...snip...
})();

for more detail, see sample code

how to add custom data into label?

put any data into appData for consumer and producer

Then you can see custom data in metrics as a label.

const consumer = await transport.consume({
  producerId      : producer.id,
  rtpCapabilities : consumerPeer.data.rtpCapabilities,
  paused          : true,
  appData         : { roomId: this._roomId } // add custom data
});
# HELP mediasoup_consumers_byte_count mediasoup_consumers_byte_count
# TYPE mediasoup_consumers_byte_count gauge
mediasoup_consumers_byte_count{kind="video",mimeType="video/VP8",type="outbound-rtp",consumerId="39de65e6-6514-4cd3-b2e3-77894ee6e876",roomId="test-guitarsolo-w5f0Mc20gP-6jmtL8Km"} 272998
mediasoup_consumers_byte_count{kind="audio",mimeType="audio/opus",type="outbound-rtp",consumerId="a66cf2cf-251b-4d2d-9098-dec8ad88d4bf",roomId="test-guitarsolo-w5f0Mc20gP-6jmtL8Km"} 32917

REST

prometheus

casual api

run test server

$ cd test-server
$ node server.js