Skip to content

Commit c83ee25

Browse files
committed
Expose ACK rate for Semtech UDP backend per Gateway ID.
If the ChirpStack Gateway Bridge is installed on the server and especially using Docker, there can be cases where the uplink path (GW > CGB) works, but the downlink path (CGB > GW) fails (UDP packets never reach the GW). By exposing the ACK rate per Gateway ID, it is possible to add per gateway monitoring. As the exposed ack-rate represents the last reported ack-rate by the GW, it is also important to monitor the ack-rate count. If this value does not increment, it could mean that the GW is no longer reporting the ack-rate and thus the exposed ack-rate is stale.
1 parent b9d3d7b commit c83ee25

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

internal/backend/semtechudp/backend.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,8 @@ func (b *Backend) handlePushData(up udpPacket) error {
462462
return errors.Wrap(err, "get stats error")
463463
}
464464
if stats != nil {
465+
ackRateCounter(p.GatewayMAC).Inc()
466+
ackRate(p.GatewayMAC).Set(p.Payload.Stat.ACKR)
465467
b.handleStats(p.GatewayMAC, stats)
466468
}
467469

internal/backend/semtechudp/metrics.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package semtechudp
22

33
import (
4+
"github.com/brocaar/lorawan"
45
"github.com/prometheus/client_golang/prometheus"
56
"github.com/prometheus/client_golang/prometheus/promauto"
67
)
@@ -25,6 +26,16 @@ var (
2526
Name: "backend_semtechudp_gateway_diconnect_count",
2627
Help: "The number of gateways that disconnected from the backend.",
2728
})
29+
30+
ackr = promauto.NewGaugeVec(prometheus.GaugeOpts{
31+
Name: "backend_semtechdup_gateway_ack_rate",
32+
Help: "The percentage of upstream datagrams that were acknowledged.",
33+
}, []string{"gateway_id"})
34+
35+
ackrc = promauto.NewCounterVec(prometheus.CounterOpts{
36+
Name: "backend_semtechudp_gateway_ack_rate_count",
37+
Help: "The number of ack-rates reported.",
38+
}, []string{"gateway_id"})
2839
)
2940

3041
func udpWriteCounter(pt string) prometheus.Counter {
@@ -42,3 +53,11 @@ func connectCounter() prometheus.Counter {
4253
func disconnectCounter() prometheus.Counter {
4354
return gwd
4455
}
56+
57+
func ackRate(gatewayID lorawan.EUI64) prometheus.Gauge {
58+
return ackr.With(prometheus.Labels{"gateway_id": gatewayID.String()})
59+
}
60+
61+
func ackRateCounter(gatewayID lorawan.EUI64) prometheus.Counter {
62+
return ackrc.With(prometheus.Labels{"gateway_id": gatewayID.String()})
63+
}

0 commit comments

Comments
 (0)