feat(prometheus-sd): label for location

This commit is contained in:
genofire 2022-07-11 17:57:07 +02:00
parent 7c01dcbe39
commit 7da4dc7d7f
1 changed files with 7 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package prometheus_sd
import (
"errors"
"fmt"
"strconv"
"github.com/FreifunkBremen/yanic/output"
@ -120,6 +121,12 @@ func toTargets(n *runtime.Node, defaultLabels map[string]interface{}, targetFunc
labels["owner"] = owner.Contact
}
// location
if location := ni.Location; location != nil {
labels["latitude"] = fmt.Sprintf("%v", location.Latitude)
labels["longitude"] = fmt.Sprintf("%v", location.Longitude)
}
// wireless - airtime
if wifi := ni.Wireless; wifi != nil {
labels["wifi_txpower24"] = strconv.Itoa(int(wifi.TxPower24))