gateway icon indicating copy to clipboard operation
gateway copied to clipboard

allow the change altStatName for backend

Open zirain opened this issue 2 months ago • 14 comments

Currently, we build cluster name with the rule like httproute/default/backend/rule/0, this's fine for mostly of the cases.

The problem is that when we want to know what the exract hostname/backend name in metrics or tracing spane name.

Image

Maybe we should provide a way to customize it directly beside ClusterStatName in EnvoyProxy.

xref: https://envoyproxy.slack.com/archives/C03E6NHLESV/p1762944475362659

cc @envoyproxy/gateway-maintainers

zirain avatar Nov 15 '25 01:11 zirain

sure, can we added once https://github.com/envoyproxy/gateway/pull/6310 lands

arkodg avatar Nov 15 '25 01:11 arkodg

@arkodg as #6310 landed, we can add another knob for cluster stats name?

zirain avatar Nov 25 '25 04:11 zirain

Sure +1

arkodg avatar Nov 25 '25 05:11 arkodg

Rethink about this, for a httproute like following:

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: backend
spec:
  parentRefs:
    - group: gateway.networking.k8s.io
      kind: Gateway
      name: eg
  hostnames:
    - mtls.example.com
  rules:
    - name: force-trace-rule
      matches:
        - path:
            type: PathPrefix
            value: /v1
      backendRefs:
        - group: gateway.envoyproxy.io
          kind: Backend
          name: backend
    - name: normal-sampling-rule
      matches:
        - path:
            type: PathPrefix
            value: /v2
      backendRefs:
        - group: gateway.envoyproxy.io
          kind: Backend
          name: backend-v2

the goal is make sure that we know the hostname from the span or stat. As BackendTrafficPolicy is targeting to xRoute, seems not working for this case.

zirain avatar Nov 26 '25 03:11 zirain

do we need a similar things like BackendTrafficPolicy, but target ref to Service/ServiceImport/Backend like BackednTLSPolicy.

zirain avatar Nov 26 '25 05:11 zirain

you could use %BACKEND_REFS or %HOSTNAME (listener/route)

arkodg avatar Nov 26 '25 19:11 arkodg

BACKEND_REFS may help if we the name is well-formed, but it would be better to have without namespace.

%HOSTNAME may not work if URLRewrite happened.

zirain avatar Nov 26 '25 22:11 zirain

you can then target a BTP to a specific rule and only specific statName for it, and merge it back with parent BTP

arkodg avatar Nov 26 '25 22:11 arkodg

you can then target a BTP to a specific rule and only specific statName for it, and merge it back with parent BTP

so we need N * BTP, and N is the number of the rule, which is a little crazy some time.

zirain avatar Nov 26 '25 23:11 zirain

also it won't work when there're multiple backend in one rule.

zirain avatar Nov 26 '25 23:11 zirain

@arkodg what about introuduce a new command named %BACKEND_HOSTNAME%

  1. For Service/ServiceImport, it will result svc-name.svc-ns.svc.cluster.local
  2. For Backend, it will use the hostname if there's only one fqdn otherwise fallback to name.namespace.

zirain avatar Nov 27 '25 09:11 zirain

wdyt @envoyproxy/gateway-maintainers

arkodg avatar Dec 01 '25 19:12 arkodg

Community Meeting Notes:

  1. Can this information be provided using trace tags rather than the requested field
  2. Does the user want to see this replace the "ingress" label or the router "backend" label

Generally, +1 to BTP override of EP trace settings.

guydc avatar Dec 11 '25 15:12 guydc

Community Meeting Notes:

  1. Can this information be provided using trace tags rather than the requested field
  2. Does the user want to see this replace the "ingress" label or the router "backend" label

Generally, +1 to BTP override of EP trace settings.

Trace will be fixed with this new API. The case is that we need to link the metrics with trace and accesslog, that's why we need to override the altStatName on cluster.

zirain avatar Dec 12 '25 01:12 zirain