Skip to content

Commit

Permalink
fix(output/prometheus-sd): int labels not allowed ...
Browse files Browse the repository at this point in the history
  • Loading branch information
genofire committed Jul 10, 2022
1 parent 124215f commit aa0cf52
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions output/prometheus-sd/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type Output struct {
output.Output
path string
targetType TargetAddressType
labels map[string]interface{}
labels map[string]string
}

type Config map[string]interface{}
Expand Down Expand Up @@ -55,9 +55,9 @@ func (c Config) TargetAddress() TargetAddressType {
return TargetAddressIP
}

func (c Config) Labels() map[string]interface{} {
func (c Config) Labels() map[string]string {
if v, ok := c["labels"]; ok {
return v.(map[string]interface{})
return v.(map[string]string)
}
return nil
}
Expand All @@ -82,16 +82,16 @@ func Register(configuration map[string]interface{}) (output.Output, error) {

type Targets struct {
Targets []string `json:"targets"`
Labels map[string]interface{} `json:"labels,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
}

func toTargets(n *runtime.Node, defaultLabels map[string]interface{}, targetFunc TargetAddressFunc) *Targets {
func toTargets(n *runtime.Node, defaultLabels map[string]string, targetFunc TargetAddressFunc) *Targets {
target := targetFunc(n)
if target == "" {
return nil
}

labels := map[string]interface{}{}
labels := map[string]string{}
for k, v := range defaultLabels {
labels[k] = v
}
Expand Down Expand Up @@ -120,10 +120,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"] = string(wifi.TxPower24)
labels["wifi_channel24"] = string(wifi.Channel24)
labels["wifi_txpower5"] = string(wifi.TxPower5)
labels["wifi_channel5"] = string(wifi.Channel5)
}
}
return &Targets{
Expand Down

0 comments on commit aa0cf52

Please sign in to comment.