mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2026-03-14 14:35:44 +01:00
Also expose bandwidth usage of backend servers through metrics.
This commit is contained in:
parent
6d0d317252
commit
889ec056f2
5 changed files with 25 additions and 2 deletions
|
|
@ -321,6 +321,11 @@ type EventProxyServerBandwidth struct {
|
|||
Incoming *float64 `json:"incoming,omitempty"`
|
||||
// Outgoing is the bandwidth utilization for subscribers in percent.
|
||||
Outgoing *float64 `json:"outgoing,omitempty"`
|
||||
|
||||
// Received is the incoming bandwidth in bytes per second.
|
||||
Received uint64 `json:"received,omitempty"`
|
||||
// Sent is the outgoing bandwidth in bytes per second.
|
||||
Sent uint64 `json:"sent,omitempty"`
|
||||
}
|
||||
|
||||
func (b *EventProxyServerBandwidth) String() string {
|
||||
|
|
|
|||
|
|
@ -57,4 +57,5 @@ The following metrics are available:
|
|||
| `signaling_backend_client_requests_errors_total` | Counter | 2.0.3 | The total number of backend client requests that had an error | `backend`, `error` |
|
||||
| `signaling_mcu_bandwidth` | Gauge | 2.0.5 | The current bandwidth in bytes per second | `direction` |
|
||||
| `signaling_mcu_backend_usage` | Gauge | 2.0.5 | The current usage of signaling proxy backends in percent | `url`, `direction` |
|
||||
| `signaling_mcu_backend_bandwidth` | Gauge | 2.0.5 | The current bandwidth of signaling proxy backends in bytes per second | `url`, `direction` |
|
||||
| `signaling_proxy_load` | Gauge | 2.0.5 | The current load of the signaling proxy | |
|
||||
|
|
|
|||
|
|
@ -416,6 +416,8 @@ func newMcuProxyConnection(proxy *mcuProxy, baseUrl string, ip net.IP, token str
|
|||
statsProxyBackendLoadCurrent.WithLabelValues(conn.url.String()).Set(0)
|
||||
statsProxyUsageCurrent.WithLabelValues(conn.url.String(), "incoming").Set(0)
|
||||
statsProxyUsageCurrent.WithLabelValues(conn.url.String(), "outgoing").Set(0)
|
||||
statsProxyBandwidthCurrent.WithLabelValues(conn.url.String(), "incoming").Set(0)
|
||||
statsProxyBandwidthCurrent.WithLabelValues(conn.url.String(), "outgoing").Set(0)
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
|
|
@ -754,6 +756,8 @@ func (c *mcuProxyConnection) closeIfEmpty() bool {
|
|||
statsProxyBackendLoadCurrent.DeleteLabelValues(c.url.String())
|
||||
statsProxyUsageCurrent.DeleteLabelValues(c.url.String(), "incoming")
|
||||
statsProxyUsageCurrent.DeleteLabelValues(c.url.String(), "outgoing")
|
||||
statsProxyBandwidthCurrent.DeleteLabelValues(c.url.String(), "incoming")
|
||||
statsProxyBandwidthCurrent.DeleteLabelValues(c.url.String(), "outgoing")
|
||||
|
||||
c.proxy.removeConnection(c)
|
||||
}()
|
||||
|
|
@ -1090,6 +1094,8 @@ func (c *mcuProxyConnection) processEvent(msg *ProxyServerMessage) {
|
|||
c.bandwidth.Store(event.Bandwidth)
|
||||
statsProxyBackendLoadCurrent.WithLabelValues(c.url.String()).Set(float64(event.Load))
|
||||
if bw := event.Bandwidth; bw != nil {
|
||||
statsProxyBandwidthCurrent.WithLabelValues(c.url.String(), "incoming").Set(float64(bw.Received))
|
||||
statsProxyBandwidthCurrent.WithLabelValues(c.url.String(), "outgoing").Set(float64(bw.Sent))
|
||||
if bw.Incoming != nil {
|
||||
statsProxyUsageCurrent.WithLabelValues(c.url.String(), "incoming").Set(*bw.Incoming)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -115,6 +115,12 @@ var (
|
|||
Name: "backend_usage",
|
||||
Help: "The current usage of signaling proxy backends in percent",
|
||||
}, []string{"url", "direction"})
|
||||
statsProxyBandwidthCurrent = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Namespace: "signaling",
|
||||
Subsystem: "mcu",
|
||||
Name: "backend_bandwidth",
|
||||
Help: "The current bandwidth of signaling proxy backends in bytes per second",
|
||||
}, []string{"url", "direction"})
|
||||
statsProxyNobackendAvailableTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
Namespace: "signaling",
|
||||
Subsystem: "mcu",
|
||||
|
|
@ -126,6 +132,7 @@ var (
|
|||
statsConnectedProxyBackendsCurrent,
|
||||
statsProxyBackendLoadCurrent,
|
||||
statsProxyUsageCurrent,
|
||||
statsProxyBandwidthCurrent,
|
||||
statsProxyNobackendAvailableTotal,
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -503,8 +503,12 @@ func (s *ProxyServer) newLoadEvent(load uint64, incoming uint64, outgoing uint64
|
|||
}
|
||||
maxIncoming := s.maxIncoming.Load()
|
||||
maxOutgoing := s.maxOutgoing.Load()
|
||||
if maxIncoming > 0 || maxOutgoing > 0 {
|
||||
msg.Event.Bandwidth = &signaling.EventProxyServerBandwidth{}
|
||||
if maxIncoming > 0 || maxOutgoing > 0 || incoming != 0 || outgoing != 0 {
|
||||
// Values should be sent in bytes per second.
|
||||
msg.Event.Bandwidth = &signaling.EventProxyServerBandwidth{
|
||||
Received: incoming / 8,
|
||||
Sent: outgoing / 8,
|
||||
}
|
||||
if maxIncoming > 0 {
|
||||
value := float64(incoming) / float64(maxIncoming) * 100
|
||||
msg.Event.Bandwidth.Incoming = &value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue