Search code examples
rate-limitingenvoyproxystatsd

How can I get envoyproxy/ratelimit statistics for descriptors without value?


I am using envoyproxy/ratelimit (along with Istio) to setup a global rate limiting in my k8s cluster for a given service. The rate limit is based on a header (in my case the username) so that each username is limited by the number of RPS. The following configuration was used to achieve this:

    domain: ratelimit
    descriptors:
      - key: USERNAME
        rate_limit:
          unit: second
          requests_per_unit: 100
        shadow_mode: true

Also, I used a EnvoyFilter (Istio CRD) to define which header will used.

The resulting metric does not show a label for a specific user, just for the entire descriptor:

ratelimit_service_rate_limit_within_limit{app="ratelimit",domain="ratelimit",instance="xxx",job="kubernetes-pods",key1="USERNAME",kubernetes_namespace="xxx",kubernetes_pod_name="ratelimit-xxx",pod_template_hash="xxx",security_istio_io_tlsMode="istio",service_istio_io_canonical_name="ratelimit",service_istio_io_canonical_revision="latest"}

So my question is: how can I get the metrics for a specific username? Considering my configuration is applied to all of them and not for a specific value.


Solution

  • Thanks to this PR you can now add a detailed_metric parameter to enable this behavior, as shown in this example.