This changes linkerd-multicluster's `gateways` command to use the service mirror component's `/metrics` endpoint so that there is no longer a dependency on linkerd-viz. The dependency on linkerd-viz is leftover from when those components were part of the default installation meaning that we could always rely on the Prometheus component being present.
Now, the `gateways` command starts a port-forward to each service mirror component (for each linked cluster) and queries the `/metrics` endpoint for the `gateway_alive` and `gateway_latency` metrics. It then queries the local cluster for the number of mirror services that correspond to the target cluster of that service mirror. Using these three data points, it creates the output table for the command.
### Output changes
Currently the `gateways` command displays the P50, P95, and P99 latencies for each gateway
```shell
$ linkerd multicluster gateways
CLUSTER ALIVE NUM_SVC LATENCY_P50 LATENCY_P95 LATENCY_P99
k3d-x True 1 1ms 3ms 3ms
k3d-z True 0 1ms 3ms 3ms
```
With this change, we now just show the last observed latency. This involved adding the `gateway_latency` metric Gauge — different from the current latencies Observer.
```shell
$ linkerd multicluster gateways
CLUSTER ALIVE NUM_SVC LATENCY
k3d-x True 1 2ms
k3d-z True 0 3ms
```
This is because I have not found a Prometheus common library for taking the parsed metrics from `/metrics` and turning that into a histogram yet; I think we should be able to do this but I'm leaving as a follow-up for now.
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
* cli: reorganise diagnostics subcommand
Fixes#5192, #5193
This PR moves `metrics`, `diagnostics`(which prints out metrics of
control-plane components), `endpoints` and `install-sp` into a new `diagnostics`
subcommand.
Signed-off-by: Tarun Pothulapati <tarunpothulapati@outlook.com>