Skip to content

Commit

Permalink
cli: Enhance diagnostics endpoints json output
Browse files Browse the repository at this point in the history
The 'endpoints' diagnostic command omits some interesting endpoint
metadata. This change adds weights and metric labels to JSON output.
  • Loading branch information
olix0r committed Jan 5, 2024
1 parent 55d1049 commit 80c68d9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cli/cmd/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type (
name string
address string
ip string
weight uint32
labels map[string]string
}
)

Expand Down Expand Up @@ -200,6 +202,8 @@ func requestEndpointsFromAPI(client destinationPb.DestinationClient, authorities
name: labels["pod"],
address: tcpAddr.String(),
ip: getIP(tcpAddr),
weight: addr.GetWeight(),
labels: addr.GetMetricLabels(),
})
}
}
Expand Down Expand Up @@ -230,6 +234,9 @@ type rowEndpoint struct {
Port uint32 `json:"port"`
Pod string `json:"pod"`
Service string `json:"service"`
Weight uint32 `json:"weight"`

Labels map[string]string `json:"labels"`
}

func writeEndpointsToBuffer(endpoints endpointsInfo, w *tabwriter.Writer, options *endpointsOptions) {
Expand All @@ -255,6 +262,8 @@ func writeEndpointsToBuffer(endpoints endpointsInfo, w *tabwriter.Writer, option
Port: port,
Pod: name,
Service: serviceID,
Weight: pod.weight,
Labels: pod.labels,
}

endpointsTables[namespace] = append(endpointsTables[namespace], row)
Expand Down

0 comments on commit 80c68d9

Please sign in to comment.