Skip to content

Commit

Permalink
prometheus: add hostname label to links
Browse files Browse the repository at this point in the history
  • Loading branch information
genofire committed Sep 9, 2021
1 parent 5ac58d1 commit 0c98c28
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions webserver/prometheus/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,23 @@ func MetricsFromNode(nodes *runtime.Nodes, node *runtime.Node) []Metric {

// before node metrics to get link statics undependent of node validation
for _, link := range nodes.NodeLinks(node) {
label := map[string]interface{}{
"source_id": link.SourceID,
"source_addr": link.SourceAddress,
"source_hostname": link.SourceHostname,
"target_id": link.TargetID,
"target_addr": link.TargetAddress,
}
if hostname := link.SourceHostname; hostname != "" {
label["source_hostname"] = hostname
}
if hostname := link.TargetHostname; hostname != "" {
label["target_hostname"] = hostname
}
m = append(m, Metric{
Labels: map[string]interface{}{
"source_id": link.SourceID,
"source_addr": link.SourceAddress,
"target_id": link.TargetID,
"target_addr": link.TargetAddress,
},
Name: "yanic_link",
Value: link.TQ * 100,
Labels: label,
Name: "yanic_link",
Value: link.TQ * 100,
})
}

Expand Down

0 comments on commit 0c98c28

Please sign in to comment.