Expanding CEXL?

Hey folks,

Are there any plans to expand operators / functions available in CEXL?
We were trying to add a custom dimension to bucket response.code by type (i.e. 1xx, 2xx, 3xx, 4xx, 5xx) but are unable to do so in the current implementation.

First we went looking for something like a regexp replace but there isn’t one. Then we tried match(response.code, "5.*") etc but got type errors (response.code being INT64). Then we tried something like response.code >= 400 && response.code < 500 but GTE & LT are also missing. We also tried "" + response.code to see if we could get a type conversion but alas not.

I really expected to be able to do this :frowning:

Well, actually we could do it by enumerating every response code we want to bucket but it gets very nasty very fast:
condition(response.code == 500 || response.code == 501 || response.code == 502, "5XX", condition(response.code == 400 || response.code == 401 || response.code == 402, "4XX", condition(response.code == 300 || response.code == 301 || response.code == 302, "3XX"))) (and this is just the first 3 response codes for each status. Even limiting it to just the common codes would mean ~ 20 or so.

Hi!

What version of istio are you using? The comparison operators have been added to 1.1, so they are available for use in RC4.

Longer term, we’re trying to converge CEXL with CEL: https://github.com/google/cel-spec
CEL runtime has been merged into master and can be enabled opt-in using a special annotation per instance or rule. CEL has a full spectrum of conversions, so string(response.code) should work as expected.

Hey @kuat

I should’ve checked the preliminary docs … we’re still running 1.0.5 atm.
Once 1.1 gets released we’ll give it a go.

Do you have a link to docs (or code) regarding the CEL annotation?

Thanks for the reply.

The annotation is “policy.istio.io/lang” with values CEXL (default), COMPAT (auto-convert to CEL), and CEL (true CEL).
Unfortunately, we did not merge this feature into 1.1, so it is only available on master.

1.1 has comparison operators, toLower in existing language runtime. If you do need another extension, please reach out in issues. We’d be happy to consider adding it to both language runtimes.

Reference:

Cool, thanks. We can make do with the comparators for now; it’s not pretty but it should work.

I’ve documented the use case / ideas for what could improve it here https://github.com/istio/istio/issues/12454 though I’m not sure how practical any of them might be.