From 7c01dcbe39063ca97710fc786551091cf29d0550 Mon Sep 17 00:00:00 2001 From: genofire Date: Sun, 10 Jul 2022 16:44:00 +0200 Subject: [PATCH] fix(output/prometheus-sd): int labels not allowed ... --- output/prometheus-sd/output.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/output/prometheus-sd/output.go b/output/prometheus-sd/output.go index ab74fd6..47e95d2 100644 --- a/output/prometheus-sd/output.go +++ b/output/prometheus-sd/output.go @@ -2,6 +2,7 @@ package prometheus_sd import ( "errors" + "strconv" "github.com/FreifunkBremen/yanic/output" "github.com/FreifunkBremen/yanic/runtime" @@ -81,8 +82,8 @@ func Register(configuration map[string]interface{}) (output.Output, error) { } type Targets struct { - Targets []string `json:"targets"` - Labels map[string]interface{} `json:"labels,omitempty"` + Targets []string `json:"targets"` + Labels map[string]string `json:"labels,omitempty"` } func toTargets(n *runtime.Node, defaultLabels map[string]interface{}, targetFunc TargetAddressFunc) *Targets { @@ -91,9 +92,10 @@ func toTargets(n *runtime.Node, defaultLabels map[string]interface{}, targetFunc return nil } - labels := map[string]interface{}{} + labels := map[string]string{} for k, v := range defaultLabels { - labels[k] = v + vS := v.(string) + labels[k] = vS } if ni := n.Nodeinfo; ni != nil { labels["node_id"] = ni.NodeID @@ -120,10 +122,10 @@ func toTargets(n *runtime.Node, defaultLabels map[string]interface{}, targetFunc // wireless - airtime if wifi := ni.Wireless; wifi != nil { - labels["wifi_txpower24"] = wifi.TxPower24 - labels["wifi_channel24"] = wifi.Channel24 - labels["wifi_txpower5"] = wifi.TxPower5 - labels["wifi_channel5"] = wifi.Channel5 + labels["wifi_txpower24"] = strconv.Itoa(int(wifi.TxPower24)) + labels["wifi_channel24"] = strconv.Itoa(int(wifi.Channel24)) + labels["wifi_txpower5"] = strconv.Itoa(int(wifi.TxPower5)) + labels["wifi_channel5"] = strconv.Itoa(int(wifi.Channel5)) } } return &Targets{