This page provides some pointers that could assist in addressing issues encountered while using the OPA-Envoy plugin. If none of these tips work, feel free to join slack.openpolicyagent.org and ask for help.

Debugging Performance Issues

Benchmarking Queries

The opa bench command evaluates a Rego query multiple times and reports metrics. You can also profile your polices using opa eval to understand expression evaluation time. More information on improving policy performance can be found here.

Analyzing Decision Logs

The OPA-Envoy plugin logs every decision that it makes. These logs contain lots of useful information including metrics like gRPC server handler time and Rego query evaluation time which can help in measuring the OPA-Envoy plugin’s performance. To enable local console logging of decisions see this.

Envoy External Authorization Filter Configuration

Envoy’s External authorization gRPC service configuration uses either Envoy’s in-built gRPC client, or the Google C++ gRPC client. From the benchmarking results, lower latency numbers are seen while using Envoy’s gRPC client versus Google’s. Experimenting with the gRPC service configuration may help in improving performance.

The filter configuration also has a status_on_error field that can be used to indicate a network error between the filter and the OPA-Envoy plugin. The default status on such an error is HTTP 403 Forbidden. Changing the default value of this field will help uncover potential network issues as 403 Forbidden is also generated when a request is denied.

Interacting with the gRPC server

This section provides examples of interacting with the Envoy External Authorization gRPC server using the grpcurl tool.

  • List all services exposed by the server

    1. $ grpcurl -plaintext localhost:9191 list

    Output:

    1. envoy.service.auth.v2.Authorization
    2. envoy.service.auth.v3.Authorization
    3. grpc.reflection.v1alpha.ServerReflection
  • Invoke a v3 Check RPC on the server

    1. $ grpcurl -plaintext -d '
    2. {
    3. "attributes": {
    4. "request": {
    5. "http": {
    6. "method": "GET",
    7. "path": "/api/v1/products"
    8. }
    9. }
    10. }
    11. }' localhost:9191 envoy.service.auth.v3.Authorization/Check

    Output:

    1. {
    2. "status": {
    3. },
    4. "okResponse": {
    5. "headers": [
    6. {
    7. "header": {
    8. "key": "x-ext-auth-allow",
    9. "value": "yes"
    10. }
    11. }
    12. ]
    13. }
    14. }