Support for object types in istio.policy.v1beta1.Value

#1

In order to be able to correctly map access log entries to our backend’s Elasticsearch schema, we need to be able to define nested objects in a LogEntry template, so that the json output looks something like this:

{
	"level": "info",
	"time": "2019-03-29T17:03:21.957247Z",
	"instance": "accesslog.logentry.istio-system",
	"application": "istio-ingressgateway",
	"extra_data": {
		"request": {
			"method": "GET"
		},
		"response": {
			"code": 200
		}
	}
}

For this to work, the template would have to look something like

apiVersion: "config.istio.io/v1alpha2"
kind: logentry
metadata:
  name: accesslog
  namespace: istio-system
spec:
  severity: info
  timestamp: request.time
  variables:
    application: source.labels["app"]
    extra_data:
      request:
        method: request.method
      response:
        code: response.code
  monitored_resource_type: '"UNSPECIFIED"'

Currently istio.policy.v1beta1.Value doesn’t support a map-like structure to be able to parse extra_data. Are there any workarounds? Or is there a plan to support maps as a type in the future?

0 Likes

#2

Hi!

The current workaround is to flatten the values into a stringmap:

variables:
  extra_data:
    request_method: request.method
    response_code: response.code

We do have plans to adopt Common Expression Language (https://github.com/google/cel-spec) which has a full support for protos, JSONs, lists, and maps. I would imagine we would need a new value type OBJECT that represents a JSON, once we are ready to utilize CEL runtime.

You are welcome to provide more comments in the expression language issue:

Regards,
–kuat

0 Likes

#3

Flattening the list still doesn’t work for me. Adding

  extra_data:
    request_method: request.method

gives me

admission webhook “mixer.validation.istio.io” denied the request: json: cannot unmarshal object into Go value of type string

I’m on 1.1.0. It doesn’t look like Mixer can take ANY nested object beyond the one level down below variables.

0 Likes

#4

Oops, yeah, sorry. What I meant was one-level flattened list:

variables:
  extra_data_request_method: request.method
0 Likes