Skip to content
This repository was archived by the owner on Feb 20, 2026. It is now read-only.

Commit 76868ff

Browse files
committed
fix(prometheus): add link support
1 parent 523a5a7 commit 76868ff

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

webserver/prometheus.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ var (
8282
promDescNodeAirtimeRxUtil = prometheus.NewDesc("yanic_node_airtime_rx_util", "", allLabelsWithFrequency, prometheus.Labels{})
8383
promDescNodeAirtimeNoise = prometheus.NewDesc("yanic_node_airtime_noise", "", allLabelsWithFrequency, prometheus.Labels{})
8484
promDescNodeWirelessTxPower = prometheus.NewDesc("yanic_node_wireless_txpower", "", allLabelsWithFrequency, prometheus.Labels{})
85+
86+
// Links - just necessary
87+
labelLinks = []string{"source_id", "target_id", "source_address", "target_address", "source_hostname", "target_hostname"}
88+
promDescLinkTQ = prometheus.NewDesc("yanic_link_tq", "", labelLinks, prometheus.Labels{})
8589
)
8690

8791
type Prometheus struct {
@@ -164,6 +168,8 @@ func (prom *Prometheus) Describe(d chan<- *prometheus.Desc) {
164168
d <- promDescNodeAirtimeTxUtil
165169
d <- promDescNodeAirtimeNoise
166170
d <- promDescNodeWirelessTxPower
171+
172+
d <- promDescLinkTQ
167173
}
168174

169175
func (prom *Prometheus) getNodeLabels(ni *data.Nodeinfo) []string {
@@ -618,5 +624,21 @@ func (prom *Prometheus) Collect(metrics chan<- prometheus.Metric) {
618624
}
619625
}
620626
}
627+
for _, link := range prom.nodes.NodeLinks(node) {
628+
if m, err := prometheus.NewConstMetric(
629+
promDescLinkTQ,
630+
prometheus.GaugeValue,
631+
float64(link.TQ),
632+
// labels:
633+
link.SourceID,
634+
link.TargetID,
635+
link.SourceAddress,
636+
link.TargetAddress,
637+
link.SourceHostname,
638+
link.TargetHostname,
639+
); err == nil {
640+
metrics <- m
641+
}
642+
}
621643
}
622644
}

0 commit comments

Comments
 (0)