Skip to content

duplicate endpoint stats #44117

@zirain

Description

@zirain

Same endpoint exists in multiple priority levels (e.g., priority 0 and priority 1), it will generate multiple metrics with the same labels.

reproduce yaml:

admin:
  address:
    socket_address:
      address: 0.0.0.0
      port_value: 9901

static_resources:
  listeners:
  - name: listener_0
    address:
      socket_address:
        address: 0.0.0.0
        port_value: 10000
    filter_chains:
    - filters:
      - name: envoy.filters.network.http_connection_manager
        typed_config:
          "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
          stat_prefix: ingress_http
          route_config:
            name: local_route
            virtual_hosts:
            - name: backend
              domains: ["*"]
              routes:
              - match:
                  prefix: "/"
                route:
                  cluster: test_cluster
          http_filters:
          - name: envoy.filters.http.router
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router

  clusters:
  - name: test_cluster
    type: STATIC
    lb_policy: ROUND_ROBIN
    
    # Enable per-endpoint stats - this is required to see endpoint_healthy metrics
    track_cluster_stats:
      per_endpoint_stats: true
    
    # Configure multiple priorities with the SAME endpoint
    # This reproduces the duplicate metrics issue
    load_assignment:
      cluster_name: test_cluster
      endpoints:
      # Priority 0 - endpoint is healthy
      - priority: 0
        lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: 127.0.0.1
                port_value: 8443
            hostname: "test-endpoint.example.local"
          health_status: HEALTHY  # This will show healthy=1
      
      # Priority 1 - SAME endpoint but unhealthy
      - priority: 1
        lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: 127.0.0.1
                port_value: 8443
            hostname: "test-endpoint.example.local"
          health_status: UNHEALTHY  # This will show healthy=0

output:

curl -s http://localhost:9901/stats | grep endpoint | grep healthy
cluster.test_cluster.endpoint.127.0.0.1_8443.healthy: 1
cluster.test_cluster.endpoint.127.0.0.1_8443.healthy: 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions