Repository navigation
Description
Hi all,
I am seeing the following behavior with HTTP connection manager stats and wanted to check if the behavior is expected.
Below is my dynamic listener config
"dynamic_listeners": [
{
"name": "listener",
"active_state": {
"listener": {
"@type": "type.googleapis.com/envoy.config.listener.v3.Listener",
"name": "listener",
},
"filter_chains": [
{
"filter_chain_match": {
"server_names": [
"foo.com"
]
},
"filters": [
{
"name": "envoy.http_connection_manager",
"typed_config": {
"@type": "type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager",
"stat_prefix": "foo",
"rds": {
"config_source": {
"ads": {},
"resource_api_version": "V3"
},
"route_config_name": "foo"
},
]
},
{
"filter_chain_match": {
"server_names": [
"bar.com"
]
},
"filters": [
{
"name": "envoy.http_connection_manager",
"typed_config": {
"@type": "type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager",
"stat_prefix": "bar",
"rds": {
"config_source": {
"ads": {},
"resource_api_version": "V3"
},
"route_config_name": "bar"
},
]
}
]
and with this config, on the stats endpoint, I was seeing the following stats:
http.foo.downstream_cx_active: 0
http.bar.downstream_cx_active:0
.
I have then made an update to the filter chain wherein I removed the filter chain corresponding to bar.com, i.e there's only one HTTP connection manager now matching on foo.com, I was expecting that there won't be anymore HTTP connection manager related stats from stat_prefix bar, but that's not happening. Even after filter chain and listener update, I am seeing stats such as http.bar.downstream_cx_active: 0. The envoy config also seems to be correct, but I am able to see stats corresponding to deleted HTTP connection manager.
May I know if this is the expected behavior from envoy stats?
Activity
[-]Seeing stats for http connection manager that has been removed from the filter chain on the stats endpoint[/-][+]Seeing stats for http connection manager that has been removed from the filter chain[/+]ggreenway commentedon Aug 13, 2021
Do the extra stats stay there forever, or only for awhile? I think it is expected that they would remain while the old listener config is draining. I think the default time for that is 15 minutes.
akhila1012 commentedon Aug 13, 2021
Hello @ggreenway, it's not for a while, I don't see them vanishing until I re-start envoy again. I have enabled debug logs and checked that the stats stay around even after the old listener is completely drained.
I am observing this happen with all the downstream stats. For example, I have had other filters in the filter chain whose stats also stay around after the filters are removed. Same is not the case for upstream ones i..e when I remove a cluster from a config, the upstream stats corresponding to the cluster are removed once the cluster is removed.
ggreenway commentedon Aug 13, 2021
cc @mattklein123. This seems unexpected to me; is it possible the listener never finishes draining?
mattklein123 commentedon Aug 13, 2021
This is not expected. It's possible this is a bug around the listener intelligent / filter chain update only feature? cc @jmarantz @lambdai
mattklein123 commentedon Aug 13, 2021
(I'm wondering if a scope is shared across the entire listener, but really it should be per-filter chain.)
akhila1012 commentedon Aug 13, 2021
These were the envoy debug logs from the time I removed the filter chain
mattklein123 commentedon Aug 13, 2021
Yeah I just looked and I believe the issue is we have a scope for the entire listener, when we actually need it to be per-filter chain. Will switch this to bug, thanks for reporting! cc @lambdai for a potential fix.
nitgoy commentedon Aug 14, 2021
Plugging in the related feature ask #15185. Not sure if that'd help or suffer from exact same issue. But if metrics could be split by filter chain names then we don't need to rely on stat_prefix supplied to individual filters.
lambdai commentedon Aug 14, 2021
Is there any concerns around the overhead on introducing new stats scopes?
mattklein123 commentedon Aug 16, 2021
IMO no, scopes are pretty lightweight and I don't see an issue with having one per filter chain. @jmarantz wdyt?
jmarantz commentedon Aug 16, 2021
What's the lifetime of the filter chain? The filters are request-scoped and recycling scopes at that level might have some overhead. But if they last until an xDS update changes the filter configuration that seems fine.
lambdai commentedon Aug 17, 2021
Thank you for the confirm! The lifetime should be along with filter chain config. It lasts 1+ LDS update.