Search code examples
istiotelemetry

Evaluating Istio rule match using GreaterThan / LessThan


Looking at the capabilities of Istio Rule.match, .. https://istio.io/docs/reference/config/policy-and-telemetry/istio.policy.v1beta1/#Rule , how would one match on GreaterThan / LessThan , as opposed to just existance / equality checks

Eg. How would I be able to achieve something like this (header value > 24)

spec:
  match: match((request.headers["some-header"] | 24) >"24") 

Solution

  • The rule mentioned in the question will not work because of mismatched attribute types.


    However, it is possible to do with Common Expression Language (CEL).

    You can enable CEL in istio by using the policy.istio.io/lang annotation (set it to CEL).

    Then by using Type Values from the List of Standard Definitions we can use create functions to parse values into different types.

    For example: int() that gets a string and produces an int that we can then compare with _>_ (int, int) -> bool.