envoy icon indicating copy to clipboard operation
envoy copied to clipboard

Unable to parse envoy access log attribute value to int from string using CEL formatter

Open darshak-patel opened this issue 1 year ago • 6 comments

I’m currently utilizing envoy v1.29.2 and need to perform metric calculations using the x-envoy-upstream-service-time header. However, I’m encountering a challenge where I receive a string value for this header, whereas I require it to be in integer format for my calculations. Therefore, I opted to utilize the CEL formatter to handle type conversion, but I’m facing some difficulties in implementing it. Could you provide assistance or guidance in resolving this issue?

Expression: %CEL(int(response.headers['x-envoy-upstream-service-time']))%

Error: Incorrect configuration: %CEL(int(response.headers['x-envoy-upstream-service-time']))%. Couldn't find valid command at position 0

darshak-patel avatar Apr 05 '24 05:04 darshak-patel

cc @kyessenov @zirain

phlax avatar Apr 05 '24 09:04 phlax

I suspect this is because https://github.com/envoyproxy/envoy/blob/7b6b507850ed6a369ba162b53eaba99f5c57c7ca/source/common/formatter/substitution_formatter.cc#L41C54-L41C71 disallows ) in the subcommand of a formatter, causing it to reject function calls in CEL.

JonathanO avatar Apr 07 '24 10:04 JonathanO

Is there a way i can add %REQUEST_TX_DURATION% and %RESPONSE_TX_DURATION% to get envoy latency in access log (json_format)?

darshak-patel avatar Apr 08 '24 01:04 darshak-patel

I suspect this is because https://github.com/envoyproxy/envoy/blob/7b6b507850ed6a369ba162b53eaba99f5c57c7ca/source/common/formatter/substitution_formatter.cc#L41C54-L41C71 disallows ) in the subcommand of a formatter, causing it to reject function calls in CEL.

Does it mean we cannot convert any string value to int using CEL?

darshak-patel avatar Apr 08 '24 01:04 darshak-patel

?

darshak-patel avatar Apr 11 '24 12:04 darshak-patel

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

github-actions[bot] avatar May 11 '24 16:05 github-actions[bot]

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.

github-actions[bot] avatar May 18 '24 20:05 github-actions[bot]