Include node ID with Prometheus metrics (#251)
* include node id in prometheus metrics * static prom init and nodeID * update protocol dep
This commit is contained in:
@@ -5,37 +5,44 @@ import (
|
||||
"time"
|
||||
|
||||
livekit "github.com/livekit/protocol/livekit"
|
||||
"github.com/livekit/protocol/utils"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const livekitNamespace = "livekit"
|
||||
const livekitNamespace string = "livekit"
|
||||
|
||||
var (
|
||||
MessageCounter *prometheus.CounterVec
|
||||
ServiceOperationCounter *prometheus.CounterVec
|
||||
)
|
||||
|
||||
func init() {
|
||||
nodeID, _ := utils.LocalNodeID()
|
||||
MessageCounter = prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: livekitNamespace,
|
||||
Subsystem: "node",
|
||||
Name: "messages",
|
||||
Namespace: livekitNamespace,
|
||||
Subsystem: "node",
|
||||
Name: "messages",
|
||||
ConstLabels: prometheus.Labels{"node_id": nodeID},
|
||||
},
|
||||
[]string{"type", "status"},
|
||||
)
|
||||
|
||||
ServiceOperationCounter = prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: livekitNamespace,
|
||||
Subsystem: "node",
|
||||
Name: "service_operation",
|
||||
Namespace: livekitNamespace,
|
||||
Subsystem: "node",
|
||||
Name: "service_operation",
|
||||
ConstLabels: prometheus.Labels{"node_id": nodeID},
|
||||
},
|
||||
[]string{"type", "status", "error_type"},
|
||||
)
|
||||
)
|
||||
|
||||
func init() {
|
||||
prometheus.MustRegister(MessageCounter)
|
||||
prometheus.MustRegister(ServiceOperationCounter)
|
||||
|
||||
initPacketStats()
|
||||
initRoomStats()
|
||||
initPacketStats(nodeID)
|
||||
initRoomStats(nodeID)
|
||||
}
|
||||
|
||||
func UpdateCurrentNodeStats(nodeStats *livekit.NodeStats) error {
|
||||
|
||||
Reference in New Issue
Block a user