Skip to content
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

Access log for multi-zone traffic (SNI) #8170

Closed
bcollard opened this issue Oct 27, 2023 · 6 comments
Closed

Access log for multi-zone traffic (SNI) #8170

bcollard opened this issue Oct 27, 2023 · 6 comments
Labels
kind/feature New feature triage/rotten closed due to lack of information for too long, rejected feature...

Comments

@bcollard
Copy link

Description

Given service A in zone A, and in zone B the following services:

  • service B, version 1
  • service B, version 2

The traffic will leave service A, then go through service A sidecar (outbound TCP listener), then (no egress here) zone B ingress, then service B v1 or v2 sidecar

1st demand
I wish I could know where the traffic is heading to when looking at service A's sidecar logs.
The %UPSTREAM_CLUSTER% log command is missing. With that, I would know the upstream cluster name.

When the traffic is HTTP, we can also do weighted traffic, as shown in this excerpt, and knowing which cluster is targeted when looking at the access log would be helpful.

 "route": {
                  "weightedClusters": {
                   "clusters": [
                    {
                     "name": "backend_kuma-demo_svc_3001-_0_",
                     "weight": 20
                    },
                    {
                     "name": "backend_kuma-demo_svc_3001-_1_",
                     "weight": 40
                    },
                    {
                     "name": "backend_kuma-demo_svc_3001-_2_",
                     "weight": 40
                    }
                   ]

2nd demand
On the zone B ingress pod, we could log the SNI header. Example with a service having several versions of it: backend_kuma-demo_svc_3001{mesh=default,version=v1}

Suggested log format on the Ingress listener (access log is available at the Listener level, or at the TCP filter level)
[%START_TIME%] %REQUESTED_SERVER_NAME% %PROTOCOL% %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %UPSTREAM_CLUSTER% \"%UPSTREAM_HOST%\"\n"

%REQUESTED_SERVER_NAME% holds the SNI

@bcollard bcollard added kind/feature New feature triage/pending This issue will be looked at on the next triage meeting labels Oct 27, 2023
@jakubdyszkiewicz
Copy link
Contributor

Triage:

  1. Needs reproducing. Maybe it's just a matter of setting proper format
  2. We don't have a way to target zone proxies by policies.

@jakubdyszkiewicz jakubdyszkiewicz added triage/needs-reproducing Someone else should try to reproduce this and removed triage/pending This issue will be looked at on the next triage meeting labels Oct 30, 2023
@michaelbeaumont
Copy link
Contributor

@bcollard

What do you mean by

The %UPSTREAM_CLUSTER% log command is missing.
?

Have you tried changing the log format to include %UPSTREAM_CLUSTER%?

@michaelbeaumont
Copy link
Contributor

Opened #8417

@michaelbeaumont michaelbeaumont added triage/needs-information Reviewed and some extra information was asked to the reporter and removed triage/needs-reproducing Someone else should try to reproduce this labels Nov 20, 2023
@slonka
Copy link
Contributor

slonka commented Nov 27, 2023

@bcollard
Copy link
Author

bcollard commented Dec 4, 2023

yes, I found this snippet that works:

apiVersion: kuma.io/v1alpha1
kind: MeshAccessLog
metadata:
  name: default
  namespace: kong-mesh-system
  labels:
    kuma.io/mesh: default
spec:
  targetRef:
    kind: Mesh
  from:
    - targetRef:
        kind: Mesh
      default:
        backends:
          - type: File
            file:
              path: /dev/stdout
  to:
    - targetRef:
        kind: Mesh
      default:
        backends:
          - type: File
            file:
              path: /dev/stdout
              format:
                type: Plain
                plain: '[%START_TIME%] %KUMA_MESH% "%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% "%REQ(X-FORWARDED-FOR)%" "%REQ(USER-AGENT)%" "%REQ(X-REQUEST-ID)%" "%REQ(:AUTHORITY)%" "%KUMA_SOURCE_SERVICE%" "%KUMA_DESTINATION_SERVICE%" "%KUMA_SOURCE_ADDRESS_WITHOUT_PORT%" "%UPSTREAM_HOST%" - upstream cluster %UPSTREAM_CLUSTER%'

So ✅ for the 1st demand.

Any plan to allow customization of the log format on the zone ingress (and egress)?

@lukidzi lukidzi added triage/pending This issue will be looked at on the next triage meeting and removed triage/needs-information Reviewed and some extra information was asked to the reporter labels Dec 5, 2023
@jakubdyszkiewicz
Copy link
Contributor

Closing, because 1st is solved and 2nd will be covered in #8417

@jakubdyszkiewicz jakubdyszkiewicz closed this as not planned Won't fix, can't repro, duplicate, stale Dec 11, 2023
@jakubdyszkiewicz jakubdyszkiewicz added triage/rotten closed due to lack of information for too long, rejected feature... and removed triage/pending This issue will be looked at on the next triage meeting labels Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature triage/rotten closed due to lack of information for too long, rejected feature...
Projects
None yet
Development

No branches or pull requests

5 participants