Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow overriding stat name via Upstream label #10654

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

stevenctl
Copy link

Description

Allow using the label ~internal.solo.io/cluster-stat-name to manually set the alt_stat_name on the Envoy cluster that will result from an Upstream. This allows synthetic Upstreams to specify parseable alt_stat_name.

API changes

(Internal) ~internal.solo.io/cluster-stat-name can be set from code that generates Upstream synthetically. The ~ prevents users from setting this label and hijacking some services stats.

Code changes

  • Add new label, it overrides statnames that would otherwise be generated.

Context

ServiceEntry support that will eventually land in kgateway, but we want it to produce parseable stat names in the near terrm.

@stevenctl stevenctl force-pushed the stevenctl/stat-name-override branch from fb99f7f to 14f10b9 Compare February 24, 2025 18:12
Entry("non-kube upstream", createStaticUpstream("name", "ns", nil), "name_ns"),
Entry("non-kube upstream", createStaticUpstream("name", "ns", map[string]string{
translator.ClusterStatNameLabel: translator.FormatClusterStatName("istio-se_", "usname", "usns", "svcns", "svcName", 123),
}), "istio-se_usname_usns_svcns_svcName_123"),
Copy link
Author

Choose a reason for hiding this comment

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

@krisztianfekete can you spot check this output would be correctly parsed

changelog:
- type: NON_USER_FACING
description: >-
Allow using the label `~internal.solo.io/cluster-stat-name` to manually set
Copy link

Choose a reason for hiding this comment

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

Suggested change
Allow using the label `~internal.solo.io/cluster-stat-name` to manually set
Allow using the label `internal.solo.io/cluster-stat-name` to manually set

Copy link
Author

Choose a reason for hiding this comment

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

Just changed the actual label. I think we want the ~, otherwise any user in any namespace could break the metric for any service in any other namespace.

const ClusterStatNameLabel = "internal.solo.io/cluster-stat-name"

// FormatClusterStatName produces a parseable alt_stat_name.
func FormatClusterStatName(
Copy link

Choose a reason for hiding this comment

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

do we need to export this? will it be used externally? (besides in the translator test)

Copy link
Author

Choose a reason for hiding this comment

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

I may use it in solo-projects. I technically don't have to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants