Skip to content

stats: make the stat name of endpoint configurable#45044

Open
wbpcode wants to merge 2 commits into
envoyproxy:mainfrom
wbpcode:dev-enhanc-host-stats
Open

stats: make the stat name of endpoint configurable#45044
wbpcode wants to merge 2 commits into
envoyproxy:mainfrom
wbpcode:dev-enhanc-host-stats

Conversation

@wbpcode
Copy link
Copy Markdown
Member

@wbpcode wbpcode commented May 13, 2026

Commit Message: stats: make the stat name of endpoint configurable
Additional Description:

Make the stat name of endpoint configurable to close #44117. Before this PR, only the ip:port will be used as stat name in the per endpoint metrics. But if there are multiple endpoints with same ip:port, then the metrics will be corrupted.

(I initially want to add priority to per endpoint metrics as a tag to resolve this problem, but seems there is requirement to support duplicate endpoints in same priority, so I guess current way should be more flexible).

Risk Level: low.
Testing: unit.
Docs Changes: n/a.
Release Notes: added.
Platform Specific Features: n/a.

Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @mattklein123
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #45044 was opened by wbpcode.

see: more, trace.

@wbpcode
Copy link
Copy Markdown
Member Author

wbpcode commented May 13, 2026

/retest

Copy link
Copy Markdown
Member

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/wait

// This is useful when there are duplicate addresses in the cluster, for example when multiple
// endpoints share the same address but have different hostnames or metadata.
// In this case, the stat name can be used to differentiate between these endpoints in stats and logs.
string stat_name = 5;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The per-endpoint stats export two labels: the ip:port, and the hostname (if present). Which of these is this overriding? Or is it replacing both of those with a 3rd tag? Please document whatever the behavior is clearly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

for (auto& host : host_set->hosts()) {
absl::string_view endpoint_observability_name = host->observabilityName();
Network::Address::InstanceConstSharedPtr address;
if (endpoint_observability_name.empty()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

observabilityName() returns address_->asStringView() as a fallback, so I think this condition is always false.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a special case: LogicHost, whose address may be updated dynamically. That will not support the stat_name and also won't fallback to ip:port by default.

My plan is to remove logic host in the future because current default host implementation also could support multiple addresses.

Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
@wbpcode
Copy link
Copy Markdown
Member Author

wbpcode commented May 15, 2026

cc @ggreenway updated the comment to make it more clear.

@wbpcode
Copy link
Copy Markdown
Member Author

wbpcode commented May 15, 2026

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

duplicate endpoint stats

3 participants