node type prometheus metric labels (#1197)
This commit is contained in:
+1
-1
@@ -239,7 +239,7 @@ func startServer(c *cli.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
prometheus.Init(currentNode.Id)
|
prometheus.Init(currentNode.Id, currentNode.Type)
|
||||||
|
|
||||||
server, err := service.InitializeServer(conf, currentNode)
|
server, err := service.InitializeServer(conf, currentNode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
prometheus.Init("test")
|
prometheus.Init("test", livekit.NodeType_SERVER)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newMockParticipant(identity livekit.ParticipantIdentity, protocol types.ProtocolVersion, hidden bool, publisher bool) *typesfakes.FakeLocalParticipant {
|
func newMockParticipant(identity livekit.ParticipantIdentity, protocol types.ProtocolVersion, hidden bool, publisher bool) *typesfakes.FakeLocalParticipant {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ var (
|
|||||||
promSysDroppedPacketPctGauge prometheus.Gauge
|
promSysDroppedPacketPctGauge prometheus.Gauge
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init(nodeID string) {
|
func Init(nodeID string, nodeType livekit.NodeType) {
|
||||||
if initialized.Swap(true) {
|
if initialized.Swap(true) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,7 @@ func Init(nodeID string) {
|
|||||||
Namespace: livekitNamespace,
|
Namespace: livekitNamespace,
|
||||||
Subsystem: "node",
|
Subsystem: "node",
|
||||||
Name: "messages",
|
Name: "messages",
|
||||||
ConstLabels: prometheus.Labels{"node_id": nodeID},
|
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
|
||||||
},
|
},
|
||||||
[]string{"type", "status"},
|
[]string{"type", "status"},
|
||||||
)
|
)
|
||||||
@@ -48,7 +48,7 @@ func Init(nodeID string) {
|
|||||||
Namespace: livekitNamespace,
|
Namespace: livekitNamespace,
|
||||||
Subsystem: "node",
|
Subsystem: "node",
|
||||||
Name: "service_operation",
|
Name: "service_operation",
|
||||||
ConstLabels: prometheus.Labels{"node_id": nodeID},
|
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
|
||||||
},
|
},
|
||||||
[]string{"type", "status", "error_type"},
|
[]string{"type", "status", "error_type"},
|
||||||
)
|
)
|
||||||
@@ -58,7 +58,7 @@ func Init(nodeID string) {
|
|||||||
Namespace: livekitNamespace,
|
Namespace: livekitNamespace,
|
||||||
Subsystem: "node",
|
Subsystem: "node",
|
||||||
Name: "packet_total",
|
Name: "packet_total",
|
||||||
ConstLabels: prometheus.Labels{"node_id": nodeID},
|
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
|
||||||
Help: "System level packet count. Count starts at 0 when service is first started.",
|
Help: "System level packet count. Count starts at 0 when service is first started.",
|
||||||
},
|
},
|
||||||
[]string{"type"},
|
[]string{"type"},
|
||||||
@@ -69,7 +69,7 @@ func Init(nodeID string) {
|
|||||||
Namespace: livekitNamespace,
|
Namespace: livekitNamespace,
|
||||||
Subsystem: "node",
|
Subsystem: "node",
|
||||||
Name: "dropped_packets",
|
Name: "dropped_packets",
|
||||||
ConstLabels: prometheus.Labels{"node_id": nodeID},
|
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
|
||||||
Help: "System level dropped outgoing packet percentage.",
|
Help: "System level dropped outgoing packet percentage.",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -81,8 +81,8 @@ func Init(nodeID string) {
|
|||||||
|
|
||||||
sysPacketsStart, sysDroppedPacketsStart, _ = getTCStats()
|
sysPacketsStart, sysDroppedPacketsStart, _ = getTCStats()
|
||||||
|
|
||||||
initPacketStats(nodeID)
|
initPacketStats(nodeID, nodeType)
|
||||||
initRoomStats(nodeID)
|
initRoomStats(nodeID, nodeType)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMemoryStats() (memoryLoad float32, err error) {
|
func getMemoryStats() (memoryLoad float32, err error) {
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package prometheus
|
|||||||
import (
|
import (
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"go.uber.org/atomic"
|
"go.uber.org/atomic"
|
||||||
|
|
||||||
|
"github.com/livekit/protocol/livekit"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Direction string
|
type Direction string
|
||||||
@@ -35,48 +37,48 @@ var (
|
|||||||
promConnections *prometheus.GaugeVec
|
promConnections *prometheus.GaugeVec
|
||||||
)
|
)
|
||||||
|
|
||||||
func initPacketStats(nodeID string) {
|
func initPacketStats(nodeID string, nodeType livekit.NodeType) {
|
||||||
promPacketTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
|
promPacketTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||||
Namespace: livekitNamespace,
|
Namespace: livekitNamespace,
|
||||||
Subsystem: "packet",
|
Subsystem: "packet",
|
||||||
Name: "total",
|
Name: "total",
|
||||||
ConstLabels: prometheus.Labels{"node_id": nodeID},
|
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
|
||||||
}, promPacketLabels)
|
}, promPacketLabels)
|
||||||
promPacketBytes = prometheus.NewCounterVec(prometheus.CounterOpts{
|
promPacketBytes = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||||
Namespace: livekitNamespace,
|
Namespace: livekitNamespace,
|
||||||
Subsystem: "packet",
|
Subsystem: "packet",
|
||||||
Name: "bytes",
|
Name: "bytes",
|
||||||
ConstLabels: prometheus.Labels{"node_id": nodeID},
|
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
|
||||||
}, promPacketLabels)
|
}, promPacketLabels)
|
||||||
promNackTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
|
promNackTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||||
Namespace: livekitNamespace,
|
Namespace: livekitNamespace,
|
||||||
Subsystem: "nack",
|
Subsystem: "nack",
|
||||||
Name: "total",
|
Name: "total",
|
||||||
ConstLabels: prometheus.Labels{"node_id": nodeID},
|
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
|
||||||
}, promRTCPLabels)
|
}, promRTCPLabels)
|
||||||
promPliTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
|
promPliTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||||
Namespace: livekitNamespace,
|
Namespace: livekitNamespace,
|
||||||
Subsystem: "pli",
|
Subsystem: "pli",
|
||||||
Name: "total",
|
Name: "total",
|
||||||
ConstLabels: prometheus.Labels{"node_id": nodeID},
|
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
|
||||||
}, promRTCPLabels)
|
}, promRTCPLabels)
|
||||||
promFirTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
|
promFirTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||||
Namespace: livekitNamespace,
|
Namespace: livekitNamespace,
|
||||||
Subsystem: "fir",
|
Subsystem: "fir",
|
||||||
Name: "total",
|
Name: "total",
|
||||||
ConstLabels: prometheus.Labels{"node_id": nodeID},
|
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
|
||||||
}, promRTCPLabels)
|
}, promRTCPLabels)
|
||||||
promParticipantJoin = prometheus.NewCounterVec(prometheus.CounterOpts{
|
promParticipantJoin = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||||
Namespace: livekitNamespace,
|
Namespace: livekitNamespace,
|
||||||
Subsystem: "participant_join",
|
Subsystem: "participant_join",
|
||||||
Name: "total",
|
Name: "total",
|
||||||
ConstLabels: prometheus.Labels{"node_id": nodeID},
|
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
|
||||||
}, nil)
|
}, nil)
|
||||||
promConnections = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
promConnections = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||||
Namespace: livekitNamespace,
|
Namespace: livekitNamespace,
|
||||||
Subsystem: "connection",
|
Subsystem: "connection",
|
||||||
Name: "total",
|
Name: "total",
|
||||||
ConstLabels: prometheus.Labels{"node_id": nodeID},
|
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
|
||||||
}, []string{"kind"})
|
}, []string{"kind"})
|
||||||
|
|
||||||
prometheus.MustRegister(promPacketTotal)
|
prometheus.MustRegister(promPacketTotal)
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import (
|
|||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"go.uber.org/atomic"
|
"go.uber.org/atomic"
|
||||||
|
|
||||||
|
"github.com/livekit/protocol/livekit"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -20,18 +22,18 @@ var (
|
|||||||
promTrackSubscribedTotal *prometheus.GaugeVec
|
promTrackSubscribedTotal *prometheus.GaugeVec
|
||||||
)
|
)
|
||||||
|
|
||||||
func initRoomStats(nodeID string) {
|
func initRoomStats(nodeID string, nodeType livekit.NodeType) {
|
||||||
promRoomTotal = prometheus.NewGauge(prometheus.GaugeOpts{
|
promRoomTotal = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||||
Namespace: livekitNamespace,
|
Namespace: livekitNamespace,
|
||||||
Subsystem: "room",
|
Subsystem: "room",
|
||||||
Name: "total",
|
Name: "total",
|
||||||
ConstLabels: prometheus.Labels{"node_id": nodeID},
|
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
|
||||||
})
|
})
|
||||||
promRoomDuration = prometheus.NewHistogram(prometheus.HistogramOpts{
|
promRoomDuration = prometheus.NewHistogram(prometheus.HistogramOpts{
|
||||||
Namespace: livekitNamespace,
|
Namespace: livekitNamespace,
|
||||||
Subsystem: "room",
|
Subsystem: "room",
|
||||||
Name: "duration_seconds",
|
Name: "duration_seconds",
|
||||||
ConstLabels: prometheus.Labels{"node_id": nodeID},
|
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
|
||||||
Buckets: []float64{
|
Buckets: []float64{
|
||||||
5, 10, 60, 5 * 60, 10 * 60, 30 * 60, 60 * 60, 2 * 60 * 60, 5 * 60 * 60, 10 * 60 * 60,
|
5, 10, 60, 5 * 60, 10 * 60, 30 * 60, 60 * 60, 2 * 60 * 60, 5 * 60 * 60, 10 * 60 * 60,
|
||||||
},
|
},
|
||||||
@@ -40,19 +42,19 @@ func initRoomStats(nodeID string) {
|
|||||||
Namespace: livekitNamespace,
|
Namespace: livekitNamespace,
|
||||||
Subsystem: "participant",
|
Subsystem: "participant",
|
||||||
Name: "total",
|
Name: "total",
|
||||||
ConstLabels: prometheus.Labels{"node_id": nodeID},
|
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
|
||||||
})
|
})
|
||||||
promTrackPublishedTotal = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
promTrackPublishedTotal = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||||
Namespace: livekitNamespace,
|
Namespace: livekitNamespace,
|
||||||
Subsystem: "track",
|
Subsystem: "track",
|
||||||
Name: "published_total",
|
Name: "published_total",
|
||||||
ConstLabels: prometheus.Labels{"node_id": nodeID},
|
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
|
||||||
}, []string{"kind"})
|
}, []string{"kind"})
|
||||||
promTrackSubscribedTotal = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
promTrackSubscribedTotal = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||||
Namespace: livekitNamespace,
|
Namespace: livekitNamespace,
|
||||||
Subsystem: "track",
|
Subsystem: "track",
|
||||||
Name: "subscribed_total",
|
Name: "subscribed_total",
|
||||||
ConstLabels: prometheus.Labels{"node_id": nodeID},
|
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
|
||||||
}, []string{"kind"})
|
}, []string{"kind"})
|
||||||
|
|
||||||
prometheus.MustRegister(promRoomTotal)
|
prometheus.MustRegister(promRoomTotal)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
prometheus.Init("test")
|
prometheus.Init("test", livekit.NodeType_SERVER)
|
||||||
}
|
}
|
||||||
|
|
||||||
type telemetryServiceFixture struct {
|
type telemetryServiceFixture struct {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ func init() {
|
|||||||
Config: logger.Config{Level: "debug"},
|
Config: logger.Config{Level: "debug"},
|
||||||
})
|
})
|
||||||
|
|
||||||
prometheus.Init("test")
|
prometheus.Init("test", livekit.NodeType_SERVER)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupSingleNodeTest(name string) (*service.LivekitServer, func()) {
|
func setupSingleNodeTest(name string) (*service.LivekitServer, func()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user