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

api: add stats_matcher for envoy's stats #1761

21 changes: 21 additions & 0 deletions api/config/v1alpha1/metric_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ type ProxyMetrics struct {
Prometheus *PrometheusProvider `json:"prometheus,omitempty"`
// Sinks defines the metric sinks where metrics are sent to.
Sinks []MetricSink `json:"sinks,omitempty"`
// Matches defines configuration for metric matching rules
tmsnan marked this conversation as resolved.
Show resolved Hide resolved
// to reduce memory and CPU overhead from Envoy stats system.
// When Matches is nil(not set), gateway by default create and expose only a subset of
Copy link
Contributor

Choose a reason for hiding this comment

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

lines 15-19 can be removed, imo
also because its hard to define in docs what exactly the default stats are, for e.g. we currently also output http stats

// Envoy stats with prefixes(cluster_manager,listener_manager,server,cluster.xds-grpc)
// expressions match on the name of stats.
// When Matches is not empty, this option is to control creation of additional Envoy stats
// with prefix, suffix, and regex expressions match on the name of the stats.
Matches []Match `json:"matches,omitempty"`
}

type MetricSinkType string
Expand All @@ -29,6 +37,19 @@ type MetricSink struct {
OpenTelemetry *OpenTelemetrySink `json:"openTelemetry,omitempty"`
}

type Match struct {
tmsnan marked this conversation as resolved.
Show resolved Hide resolved
Type MatcherType `json:"type"`
Value string `json:"value"`
}

tmsnan marked this conversation as resolved.
Show resolved Hide resolved
type MatcherType string

const (
Prefix MatcherType = "Prefix"
Regex MatcherType = "Regex"
tmsnan marked this conversation as resolved.
Show resolved Hide resolved
Suffix MatcherType = "Suffix"
)

type OpenTelemetrySink struct {
// Host define the service hostname.
Host string `json:"host"`
Expand Down
20 changes: 20 additions & 0 deletions api/config/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 @@ -3926,6 +3926,26 @@ spec:
description: Metrics defines metrics configuration for managed
proxies.
properties:
matches:
description: Matches defines configuration for metric matching
rules to reduce memory and CPU overhead from Envoy stats
system. When Matches is nil(not set), gateway by default
create and expose only a subset of Envoy stats with prefixes(cluster_manager,listener_manager,server,cluster.xds-grpc)
expressions match on the name of stats. When Matches is
not empty, this option is to control creation of additional
Envoy stats with prefix, suffix, and regex expressions match
on the name of the stats.
items:
properties:
type:
type: string
value:
type: string
required:
- type
- value
type: object
type: array
prometheus:
description: Prometheus defines the configuration for Admin
endpoint `/stats/prometheus`.
Expand Down
27 changes: 27 additions & 0 deletions docs/latest/api/config_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,32 @@ _Appears in:_



## Match





_Appears in:_
- [ProxyMetrics](#proxymetrics)

| Field | Description |
| --- | --- |
| `type` _[MatcherType](#matchertype)_ | |
| `value` _string_ | |


## MatcherType

_Underlying type:_ `string`



_Appears in:_
- [Match](#match)



## MetricSink


Expand Down Expand Up @@ -783,6 +809,7 @@ _Appears in:_
| --- | --- |
| `prometheus` _[PrometheusProvider](#prometheusprovider)_ | Prometheus defines the configuration for Admin endpoint `/stats/prometheus`. |
| `sinks` _[MetricSink](#metricsink) array_ | Sinks defines the metric sinks where metrics are sent to. |
| `matches` _[Match](#match) array_ | Matches defines configuration for metric matching rules to reduce memory and CPU overhead from Envoy stats system. When Matches is nil(not set), gateway by default create and expose only a subset of Envoy stats with prefixes(cluster_manager,listener_manager,server,cluster.xds-grpc) expressions match on the name of stats. When Matches is not empty, this option is to control creation of additional Envoy stats with prefix, suffix, and regex expressions match on the name of the stats. |


## ProxyTelemetry
Expand Down