-
Notifications
You must be signed in to change notification settings - Fork 709
fix: otel sink json access logging without text field #5498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4bb15af
5ea3f3b
fac129c
2153e2d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -336,10 +336,10 @@ func buildXdsAccessLog(al *ir.AccessLog, accessLogType ir.ProxyAccessLogType) ([ | |
| ResourceAttributes: convertToKeyValueList(otel.Resources, false), | ||
| } | ||
|
|
||
| if otel.Text == nil { | ||
| return nil, errors.New("otel.Text is nil") | ||
| var format string | ||
| if otel.Text != nil && *otel.Text != "" { | ||
| format = *otel.Text | ||
|
||
| } | ||
| format := *otel.Text | ||
|
|
||
| if format != "" { | ||
| al.Body = &otlpcommonv1.AnyValue{ | ||
|
|
@@ -349,9 +349,17 @@ func buildXdsAccessLog(al *ir.AccessLog, accessLogType ir.ProxyAccessLogType) ([ | |
| } | ||
| } | ||
|
|
||
| al.Attributes = convertToKeyValueList(otel.Attributes, true) | ||
| var attrs map[string]string | ||
|
||
| if len(otel.Attributes) != 0 { | ||
| attrs = otel.Attributes | ||
| } else if len(otel.Attributes) == 0 && format == "" { | ||
| // if there are no attributes and text format is unset, use the default EnvoyJSONLogFields | ||
| attrs = EnvoyJSONLogFields | ||
| } | ||
|
|
||
| al.Attributes = convertToKeyValueList(attrs, true) | ||
| formatters := accessLogOpenTelemetryFormatters(format, attrs) | ||
|
|
||
| formatters := accessLogOpenTelemetryFormatters(format, otel.Attributes) | ||
| if len(formatters) != 0 { | ||
| al.Formatters = formatters | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| apiVersion: gateway.networking.k8s.io/v1 | ||
| kind: Gateway | ||
| metadata: | ||
| name: accesslog-gtw | ||
| namespace: gateway-conformance-infra | ||
| spec: | ||
| gatewayClassName: {GATEWAY_CLASS_NAME} | ||
| listeners: | ||
| - name: http | ||
| port: 80 | ||
| protocol: HTTP | ||
| allowedRoutes: | ||
| namespaces: | ||
| from: Same | ||
| infrastructure: | ||
| parametersRef: | ||
| group: gateway.envoyproxy.io | ||
| kind: EnvoyProxy | ||
| name: accesslog-otel | ||
| --- | ||
| apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
| kind: EnvoyProxy | ||
| metadata: | ||
| name: accesslog-otel | ||
| namespace: gateway-conformance-infra | ||
| spec: | ||
| ipFamily: IPv4 | ||
| telemetry: | ||
| accessLog: | ||
| settings: | ||
| - matches: | ||
| - "'x-envoy-logged' in request.headers" | ||
| sinks: | ||
| - type: OpenTelemetry | ||
| openTelemetry: | ||
| backendRefs: | ||
| - name: otel-collector | ||
| namespace: monitoring | ||
| port: 4317 | ||
| resources: | ||
| k8s.cluster.name: "envoy-gateway" | ||
| shutdown: | ||
| drainTimeout: 5s | ||
| minDrainDuration: 1s | ||
| --- | ||
| apiVersion: gateway.networking.k8s.io/v1 | ||
| kind: HTTPRoute | ||
| metadata: | ||
| name: accesslog-otel | ||
| namespace: gateway-conformance-infra | ||
| spec: | ||
| parentRefs: | ||
| - name: accesslog-gtw | ||
| rules: | ||
| - matches: | ||
| - path: | ||
| type: PathPrefix | ||
| value: /otel | ||
| backendRefs: | ||
| - name: infra-backend-v2 | ||
| port: 8080 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| apiVersion: gateway.networking.k8s.io/v1 | ||
| kind: Gateway | ||
| metadata: | ||
| name: accesslog-gtw | ||
| namespace: gateway-conformance-infra | ||
| spec: | ||
| gatewayClassName: {GATEWAY_CLASS_NAME} | ||
| listeners: | ||
| - name: http | ||
| port: 80 | ||
| protocol: HTTP | ||
| allowedRoutes: | ||
| namespaces: | ||
| from: Same | ||
| infrastructure: | ||
| parametersRef: | ||
| group: gateway.envoyproxy.io | ||
| kind: EnvoyProxy | ||
| name: accesslog-otel | ||
| --- | ||
| apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
| kind: EnvoyProxy | ||
| metadata: | ||
| name: accesslog-otel | ||
| namespace: gateway-conformance-infra | ||
| spec: | ||
| ipFamily: IPv4 | ||
| telemetry: | ||
| accessLog: | ||
| settings: | ||
| - format: | ||
| type: JSON | ||
| json: | ||
| time: "%START_TIME%" | ||
| method: "%REQ(:METHOD)%" | ||
| metadata: "%METADATA(ROUTE:envoy-gateway:resources)%" | ||
| x-envoy-original-path: "%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%" | ||
| protocol: "%PROTOCOL%" | ||
| responseCode: "%RESPONSE_CODE%" | ||
| responseFlags: "%RESPONSE_FLAGS%" | ||
| bytesReceived: "%BYTES_RECEIVED%" | ||
| bytesSent: "%BYTES_SENT%" | ||
| duration: "%DURATION%" | ||
| x-forwarded-for: "%REQ(X-FORWARDED-FOR)%" | ||
| user-agent: "%REQ(USER-AGENT)%" | ||
| x-request-id: "%REQ(X-REQUEST-ID)%" | ||
| authority: "%REQ(:AUTHORITY)%" | ||
| upstreamHost: "%UPSTREAM_HOST%" | ||
| matches: | ||
| - "'x-envoy-logged' in request.headers" | ||
| sinks: | ||
| - type: OpenTelemetry | ||
| openTelemetry: | ||
| backendRefs: | ||
| - name: otel-collector | ||
| namespace: monitoring | ||
| port: 4317 | ||
| resources: | ||
| k8s.cluster.name: "envoy-gateway" | ||
| shutdown: | ||
| drainTimeout: 5s | ||
| minDrainDuration: 1s | ||
| --- | ||
| apiVersion: gateway.networking.k8s.io/v1 | ||
| kind: HTTPRoute | ||
| metadata: | ||
| name: accesslog-otel | ||
| namespace: gateway-conformance-infra | ||
| spec: | ||
| parentRefs: | ||
| - name: accesslog-gtw | ||
| rules: | ||
| - matches: | ||
| - path: | ||
| type: PathPrefix | ||
| value: /otel | ||
| backendRefs: | ||
| - name: infra-backend-v2 | ||
| port: 8080 |
Uh oh!
There was an error while loading. Please reload this page.