linkerd2/viz/metrics-api
Alex Leong 75d613123c
Split linkerd viz authz out of StatSummary (#9186)
Fixes #9149
Fixes #9144 

The `linkerd viz authz` command uses the metrics-api StatSummary gRPC method, the same gRPC method used by `linkerd viz stat`.  This method is very complex and because it was designed for the use case of `linkerd viz stat`, it has certain limitations when it is used for `linkerd viz authz` such as #9149 and #9144.  These stem from the fact that the metrics processing which happens in StatSummary is keyed off of the resource and when there are multiple metrics samples per resource (such as when there are multiple httproutes for a server, for example) this leads to key conflicts and data in maps being overwritten.

Rather than trying to bend StatSummary into a use-case it was never intended for, we instead create a new gRPC endpoint called Authz specifically for the `linkerd viz authz` use-case.  This method returns authz related stats for the given workload resource, with separate rows for all combinations of server/route/authz which have metrics.  The updated output of `linkerd viz authz` looks like this:

```console
# with default-deny, before creating policy resources
> linkerd viz authz -n emojivoto po
ROUTE          SERVER        AUTHORIZATION                          UNAUTHORIZED  SUCCESS     RPS  LATENCY_P50  LATENCY_P95  LATENCY_P99  
default        default:deny                                               1.0rps    0.00%  0.0rps          0ms          0ms          0ms  
proxy-metrics  proxy-admin   authorizationpolicy/prometheus-scrape        0.0rps  100.00%  0.4rps          1ms          1ms          1ms  
proxy-probes   proxy-admin   authorizationpolicy/proxy-probes             0.0rps  100.00%  0.8rps          1ms          1ms          1ms  

# then, after creating policy resources
> linkerd viz authz -n emojivoto po
ROUTE          SERVER       AUTHORIZATION                          UNAUTHORIZED  SUCCESS     RPS  LATENCY_P50  LATENCY_P95  LATENCY_P99  
default        emoji-grpc   authorizationpolicy/emoji-grpc               0.0rps  100.00%  2.0rps          1ms          1ms          1ms  
proxy-metrics  proxy-admin  authorizationpolicy/prometheus-scrape        0.0rps  100.00%  0.4rps          1ms          1ms          1ms  
proxy-probes   proxy-admin  authorizationpolicy/proxy-probes             0.0rps  100.00%  0.8rps          1ms          1ms          1ms  
default        voting-grpc  authorizationpolicy/voting-grpc              0.0rps   80.00%  1.0rps          1ms          1ms          1ms  
default        web-http     authorizationpolicy/web-public               0.0rps   90.83%  2.0rps          2ms          2ms          3ms
```

Since StatSummary is no longer attempting to handle this use-case, we also simplify some of the groupBy queries that it used.

Signed-off-by: Alex Leong <alex@buoyant.io>
2022-08-19 11:17:48 -07:00
..
client Remove grpc-over-http (#8625) 2022-06-08 10:27:58 -07:00
cmd Remove grpc-over-http (#8625) 2022-06-08 10:27:58 -07:00
gen/viz Split linkerd viz authz out of StatSummary (#9186) 2022-08-19 11:17:48 -07:00
proto Split linkerd viz authz out of StatSummary (#9186) 2022-08-19 11:17:48 -07:00
util Split linkerd viz authz out of StatSummary (#9186) 2022-08-19 11:17:48 -07:00
Dockerfile Update Go to 1.18 (#9019) 2022-07-27 16:10:39 -07:00
authz.go Split linkerd viz authz out of StatSummary (#9186) 2022-08-19 11:17:48 -07:00
edges.go Refactor edges command (#6574) 2021-08-05 11:01:03 -07:00
edges_test.go enable `staticcheck` (#8037) 2022-03-10 15:43:35 -08:00
gateways.go Add peer label to TCP read and write stat queries (#5903) 2021-03-26 13:36:30 -04:00
grpc_server.go Remove grpc-over-http (#8625) 2022-06-08 10:27:58 -07:00
grpc_server_test.go Remove grpc-over-http (#8625) 2022-06-08 10:27:58 -07:00
policy.go Split linkerd viz authz out of StatSummary (#9186) 2022-08-19 11:17:48 -07:00
prometheus.go Add support for serverauthorization and httproute types to viz stat (#9074) 2022-08-09 12:57:50 -07:00
prometheus_test.go stat_summary: support service metrics using `authority` label (#6514) 2021-08-09 23:05:14 +05:30
stat_summary.go Add support for AuthorizationPolicy and HttpRoute to viz authz command (#9055) 2022-08-09 12:27:28 -07:00
stat_summary_test.go Remove grpc-over-http (#8625) 2022-06-08 10:27:58 -07:00
test_helper.go Split linkerd viz authz out of StatSummary (#9186) 2022-08-19 11:17:48 -07:00
top_routes.go Enable gocritic linting (#7906) 2022-02-17 22:45:25 +00:00
top_routes_test.go enable `staticcheck` (#8037) 2022-03-10 15:43:35 -08:00