node type prometheus metric labels (#1197)

This commit is contained in:
Mathew Kamkar
2022-11-29 20:36:35 -08:00
committed by GitHub
parent 711799ecf8
commit caae389717
7 changed files with 29 additions and 25 deletions
+1 -1
View File
@@ -239,7 +239,7 @@ func startServer(c *cli.Context) error {
return err
}
prometheus.Init(currentNode.Id)
prometheus.Init(currentNode.Id, currentNode.Type)
server, err := service.InitializeServer(conf, currentNode)
if err != nil {
+1 -1
View File
@@ -10,7 +10,7 @@ import (
)
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 {
+7 -7
View File
@@ -28,7 +28,7 @@ var (
promSysDroppedPacketPctGauge prometheus.Gauge
)
func Init(nodeID string) {
func Init(nodeID string, nodeType livekit.NodeType) {
if initialized.Swap(true) {
return
}
@@ -38,7 +38,7 @@ func Init(nodeID string) {
Namespace: livekitNamespace,
Subsystem: "node",
Name: "messages",
ConstLabels: prometheus.Labels{"node_id": nodeID},
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
},
[]string{"type", "status"},
)
@@ -48,7 +48,7 @@ func Init(nodeID string) {
Namespace: livekitNamespace,
Subsystem: "node",
Name: "service_operation",
ConstLabels: prometheus.Labels{"node_id": nodeID},
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
},
[]string{"type", "status", "error_type"},
)
@@ -58,7 +58,7 @@ func Init(nodeID string) {
Namespace: livekitNamespace,
Subsystem: "node",
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.",
},
[]string{"type"},
@@ -69,7 +69,7 @@ func Init(nodeID string) {
Namespace: livekitNamespace,
Subsystem: "node",
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.",
},
)
@@ -81,8 +81,8 @@ func Init(nodeID string) {
sysPacketsStart, sysDroppedPacketsStart, _ = getTCStats()
initPacketStats(nodeID)
initRoomStats(nodeID)
initPacketStats(nodeID, nodeType)
initRoomStats(nodeID, nodeType)
}
func getMemoryStats() (memoryLoad float32, err error) {
+10 -8
View File
@@ -3,6 +3,8 @@ package prometheus
import (
"github.com/prometheus/client_golang/prometheus"
"go.uber.org/atomic"
"github.com/livekit/protocol/livekit"
)
type Direction string
@@ -35,48 +37,48 @@ var (
promConnections *prometheus.GaugeVec
)
func initPacketStats(nodeID string) {
func initPacketStats(nodeID string, nodeType livekit.NodeType) {
promPacketTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: livekitNamespace,
Subsystem: "packet",
Name: "total",
ConstLabels: prometheus.Labels{"node_id": nodeID},
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
}, promPacketLabels)
promPacketBytes = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: livekitNamespace,
Subsystem: "packet",
Name: "bytes",
ConstLabels: prometheus.Labels{"node_id": nodeID},
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
}, promPacketLabels)
promNackTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: livekitNamespace,
Subsystem: "nack",
Name: "total",
ConstLabels: prometheus.Labels{"node_id": nodeID},
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
}, promRTCPLabels)
promPliTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: livekitNamespace,
Subsystem: "pli",
Name: "total",
ConstLabels: prometheus.Labels{"node_id": nodeID},
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
}, promRTCPLabels)
promFirTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: livekitNamespace,
Subsystem: "fir",
Name: "total",
ConstLabels: prometheus.Labels{"node_id": nodeID},
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
}, promRTCPLabels)
promParticipantJoin = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: livekitNamespace,
Subsystem: "participant_join",
Name: "total",
ConstLabels: prometheus.Labels{"node_id": nodeID},
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
}, nil)
promConnections = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: livekitNamespace,
Subsystem: "connection",
Name: "total",
ConstLabels: prometheus.Labels{"node_id": nodeID},
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
}, []string{"kind"})
prometheus.MustRegister(promPacketTotal)
+8 -6
View File
@@ -5,6 +5,8 @@ import (
"github.com/prometheus/client_golang/prometheus"
"go.uber.org/atomic"
"github.com/livekit/protocol/livekit"
)
var (
@@ -20,18 +22,18 @@ var (
promTrackSubscribedTotal *prometheus.GaugeVec
)
func initRoomStats(nodeID string) {
func initRoomStats(nodeID string, nodeType livekit.NodeType) {
promRoomTotal = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: livekitNamespace,
Subsystem: "room",
Name: "total",
ConstLabels: prometheus.Labels{"node_id": nodeID},
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
})
promRoomDuration = prometheus.NewHistogram(prometheus.HistogramOpts{
Namespace: livekitNamespace,
Subsystem: "room",
Name: "duration_seconds",
ConstLabels: prometheus.Labels{"node_id": nodeID},
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
Buckets: []float64{
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,
Subsystem: "participant",
Name: "total",
ConstLabels: prometheus.Labels{"node_id": nodeID},
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
})
promTrackPublishedTotal = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: livekitNamespace,
Subsystem: "track",
Name: "published_total",
ConstLabels: prometheus.Labels{"node_id": nodeID},
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
}, []string{"kind"})
promTrackSubscribedTotal = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: livekitNamespace,
Subsystem: "track",
Name: "subscribed_total",
ConstLabels: prometheus.Labels{"node_id": nodeID},
ConstLabels: prometheus.Labels{"node_id": nodeID, "node_type": nodeType.String()},
}, []string{"kind"})
prometheus.MustRegister(promRoomTotal)
+1 -1
View File
@@ -15,7 +15,7 @@ import (
)
func init() {
prometheus.Init("test")
prometheus.Init("test", livekit.NodeType_SERVER)
}
type telemetryServiceFixture struct {
+1 -1
View File
@@ -47,7 +47,7 @@ func init() {
Config: logger.Config{Level: "debug"},
})
prometheus.Init("test")
prometheus.Init("test", livekit.NodeType_SERVER)
}
func setupSingleNodeTest(name string) (*service.LivekitServer, func()) {