gateway icon indicating copy to clipboard operation
gateway copied to clipboard

Enriching the Prometheus metric labels emitted by Envoy from HCM/TcpProxy StatPrefix

Open shuji-2019 opened this issue 1 year ago • 6 comments

Description:

Currently HCM ^1 StatPrefix ^3 can be http or https, TcpProxy ^2 StatPrefix ^4 can be tcp, passthrough or terminate. That maybe not enough for production usage.

Because it's common to deploy many listeners for different domains, even serve multiple domains by single listener in which domains are distinguished via FilterChainMatch.SNI ^5. If all listeners share the same StatPrefix, it's difficult to tell how many traffic does specified domain have received. Consider sample from Envoy's /stats/prometheus.

# TYPE envoy_listener_http_downstream_rq_completed counter
envoy_listener_http_downstream_rq_completed{envoy_http_conn_manager_prefix="https",envoy_listener_address="0.0.0.0_8080"} 0
envoy_listener_http_downstream_rq_completed{envoy_http_conn_manager_prefix="https",envoy_listener_address="0.0.0.0_8081"} 0
envoy_listener_http_downstream_rq_completed{envoy_http_conn_manager_prefix="https",envoy_listener_address="0.0.0.0_8082"} 0
envoy_listener_http_downstream_rq_completed{envoy_http_conn_manager_prefix="https",envoy_listener_address="0.0.0.0_8083"} 0
envoy_listener_http_downstream_rq_completed{envoy_http_conn_manager_prefix="http",envoy_listener_address="0.0.0.0_8084"} 1
envoy_listener_http_downstream_rq_completed{envoy_http_conn_manager_prefix="http",envoy_listener_address="0.0.0.0_8085"} 6
envoy_listener_http_downstream_rq_completed{envoy_http_conn_manager_prefix="http",envoy_listener_address="0.0.0.0_8086"} 0
envoy_listener_http_downstream_rq_completed{envoy_http_conn_manager_prefix="http",envoy_listener_address="0.0.0.0_8087"} 0
envoy_listener_http_downstream_rq_completed{envoy_http_conn_manager_prefix="https",envoy_listener_address="0.0.0.0_7021"} 0
envoy_listener_http_downstream_rq_completed{envoy_http_conn_manager_prefix="https",envoy_listener_address="0.0.0.0_8088"} 0

Relevant Links:

shuji-2019 avatar Apr 10 '24 07:04 shuji-2019

This issue has been automatically marked as stale because it has not had activity in the last 30 days.

github-actions[bot] avatar May 10 '24 08:05 github-actions[bot]

@shuji-2019 would https://github.com/envoyproxy/gateway/issues/3318 solve this use case ?

arkodg avatar May 23 '24 01:05 arkodg

@shuji-2019 would #3318 solve this use case ?

#3318 can't solve this use case.

To solve this use case, meaningful stat_prefix should be set for HCM ^1 or TCPProxy ^2. Like which hostname or port does the HCM or TCPProxy is serving for.

BTW, shuji-2019 is me and that account is abandoned.

aoledk avatar May 23 '24 03:05 aoledk

there may be multiple hostnames per hcm

arkodg avatar May 23 '24 22:05 arkodg

  • For HTTP listeners on same port, will be translated to default_filter_chain, each hostname to single VirtualHost in same HCM. It's not suitable to set all hostnames as stat_prefix, maybe just contain http and port.

  • For HTTPS listeners on same port, will be translated to filter_chains, each listener to single HCM with SNI match own hostname (only one hostname). stat_prefix can be set as hostname.

  • For TCP listeners (only single TCP listener is allowed on single port), will be translated to filter_chains, each listener to single TCPProxy with no match. stat_prefix maybe contain tcp and port.

  • For TLS listeners on same port, will be translated to filter_chains, each listener to single TCPProxy with SNI match own hostname (only one hostname). stat_prefix can be set as hostname.

aoledk avatar May 24 '24 10:05 aoledk

This issue has been automatically marked as stale because it has not had activity in the last 30 days.

github-actions[bot] avatar Jun 23 '24 12:06 github-actions[bot]

This issue has been automatically marked as stale because it has not had activity in the last 30 days.

github-actions[bot] avatar Aug 02 '24 12:08 github-actions[bot]

can this be closed ?

shawnh2 avatar Aug 03 '24 01:08 shawnh2

can this be closed ?

It's fine to close this.

aoledk avatar Aug 05 '24 07:08 aoledk