Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions api/v1alpha1/gateway_parameters_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,13 @@ type StatsConfig struct {
//
// +optional
StatsRoutePrefixRewrite *string `json:"statsRoutePrefixRewrite,omitempty"`

// Matcher configures inclusion or exclusion lists for Envoy stats.
// Only one of inclusionList or exclusionList may be set.
// If unset, Envoy's default stats emission behavior applies.
//
// +optional
Matcher *StatsMatcher `json:"matcher,omitempty"`
}

func (in *StatsConfig) GetEnabled() *bool {
Expand Down Expand Up @@ -630,6 +637,40 @@ func (in *StatsConfig) GetStatsRoutePrefixRewrite() *string {
return in.StatsRoutePrefixRewrite
}

func (in *StatsConfig) GetMatcher() *StatsMatcher {
if in == nil {
return nil
}
return in.Matcher
}

// StatsMatcher specifies mutually exclusive inclusion or exclusion lists for Envoy stats.
// See Envoy's envoy.config.metrics.v3.StatsMatcher for details.
// +kubebuilder:validation:ExactlyOneOf=inclusionList;exclusionList
type StatsMatcher struct {
// inclusionList specifies which stats to include, using string matchers.
// +optional
InclusionList []StringMatcher `json:"inclusionList,omitempty"`

// exclusionList specifies which stats to exclude, using string matchers.
// +optional
ExclusionList []StringMatcher `json:"exclusionList,omitempty"`
}

func (in *StatsMatcher) GetInclusionList() []StringMatcher {
if in == nil {
return nil
}
return in.InclusionList
}

func (in *StatsMatcher) GetExclusionList() []StringMatcher {
if in == nil {
return nil
}
return in.ExclusionList
}

// Agentgateway configures the agentgateway dataplane integration to be enabled if the `agentgateway` GatewayClass is used.
type Agentgateway struct {
// Whether to enable the extension.
Expand Down
34 changes: 34 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7281,6 +7281,112 @@ spec:
description: Whether to expose metrics annotations and ports
for scraping metrics.
type: boolean
matcher:
description: |-
Matcher configures inclusion or exclusion lists for Envoy stats.
Only one of inclusionList or exclusionList may be set.
If unset, Envoy's default stats emission behavior applies.
properties:
exclusionList:
description: exclusionList specifies which stats to exclude,
using string matchers.
items:
description: Specifies the way to match a string.
properties:
contains:
description: |-
The input string must contain the substring specified here.
Example: abc matches the value xyz.abc.def
type: string
exact:
description: |-
The input string must match exactly the string specified here.
Example: abc matches the value abc
type: string
ignoreCase:
description: |-
If true, indicates the exact/prefix/suffix/contains matching should be
case insensitive. This has no effect on the regex match.
For example, the matcher data will match both input string Data and data if this
option is set to true.
type: boolean
prefix:
description: |-
The input string must have the prefix specified here.
Note: empty prefix is not allowed, please use regex instead.
Example: abc matches the value abc.xyz
type: string
safeRegex:
description: |-
The input string must match the Google RE2 regular expression specified here.
See https://github.com/google/re2/wiki/Syntax for the syntax.
type: string
suffix:
description: |-
The input string must have the suffix specified here.
Note: empty prefix is not allowed, please use regex instead.
Example: abc matches the value xyz.abc
type: string
type: object
x-kubernetes-validations:
- message: exactly one of the fields in [exact prefix
suffix contains safeRegex] must be set
rule: '[has(self.exact),has(self.prefix),has(self.suffix),has(self.contains),has(self.safeRegex)].filter(x,x==true).size()
== 1'
type: array
inclusionList:
description: inclusionList specifies which stats to include,
using string matchers.
items:
description: Specifies the way to match a string.
properties:
contains:
description: |-
The input string must contain the substring specified here.
Example: abc matches the value xyz.abc.def
type: string
exact:
description: |-
The input string must match exactly the string specified here.
Example: abc matches the value abc
type: string
ignoreCase:
description: |-
If true, indicates the exact/prefix/suffix/contains matching should be
case insensitive. This has no effect on the regex match.
For example, the matcher data will match both input string Data and data if this
option is set to true.
type: boolean
prefix:
description: |-
The input string must have the prefix specified here.
Note: empty prefix is not allowed, please use regex instead.
Example: abc matches the value abc.xyz
type: string
safeRegex:
description: |-
The input string must match the Google RE2 regular expression specified here.
See https://github.com/google/re2/wiki/Syntax for the syntax.
type: string
suffix:
description: |-
The input string must have the suffix specified here.
Note: empty prefix is not allowed, please use regex instead.
Example: abc matches the value xyz.abc
type: string
type: object
x-kubernetes-validations:
- message: exactly one of the fields in [exact prefix
suffix contains safeRegex] must be set
rule: '[has(self.exact),has(self.prefix),has(self.suffix),has(self.contains),has(self.safeRegex)].filter(x,x==true).size()
== 1'
type: array
type: object
x-kubernetes-validations:
- message: exactly one of the fields in [inclusionList exclusionList]
must be set
rule: '[has(self.inclusionList),has(self.exclusionList)].filter(x,x==true).size()
== 1'
routePrefixRewrite:
description: The Envoy stats endpoint to which the metrics
are written
Expand Down
35 changes: 35 additions & 0 deletions internal/kgateway/helm/envoy/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,41 @@ data:
cluster: {{ include "kgateway.gateway.fullname" . }}.{{ .Release.Namespace }}
metadata:
role: kgateway-kube-gateway-api~{{ $gateway.gatewayNamespace }}~{{ $gateway.gatewayName | default (include "kgateway.gateway.fullname" .) }}
{{ if $statsConfig.matcher }}
stats_config:
stats_matcher:
{{ if $statsConfig.matcher.inclusionList }}
inclusion_list:
patterns:
{{ range $statsConfig.matcher.inclusionList }}
{{ if .exact }}
- exact: {{ .exact }}
{{ else if .prefix }}
- prefix: {{ .prefix }}
{{ else if .suffix }}
- suffix: {{ .suffix }}
{{ else if .safeRegex }}
- safe_regex:
regex: {{ .safeRegex }}
{{ end }}
{{ end }}
{{ else if $statsConfig.matcher.exclusionList }}
exclusion_list:
patterns:
{{ range $statsConfig.matcher.exclusionList }}
{{ if .exact }}
- exact: {{ .exact }}
{{ else if .prefix }}
- prefix: {{ .prefix }}
{{ else if .suffix }}
- suffix: {{ .suffix }}
{{ else if .safeRegex }}
- safe_regex:
regex: {{ .safeRegex }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
static_resources:
{{- if and $gateway.xds.tls $gateway.xds.tls.enabled }}
secrets:
Expand Down
Loading
Loading