Skip to content

Commit

Permalink
Design: CP Observability Metrics
Browse files Browse the repository at this point in the history
Signed-off-by: bitliu <[email protected]>
  • Loading branch information
Xunzhuo committed Oct 11, 2023
1 parent 3cdeabb commit dcbb582
Show file tree
Hide file tree
Showing 12 changed files with 377 additions and 74 deletions.
37 changes: 37 additions & 0 deletions api/v1alpha1/envoygateway_metric_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright Envoy Gateway Authors
// SPDX-License-Identifier: Apache-2.0
// The full text of the Apache license is available in the LICENSE file at
// the root of the repo.

package v1alpha1

// EnvoyGatewayMetrics defines control plane push/pull metrics configurations.
type EnvoyGatewayMetrics struct {
// Sinks defines the metric sinks where metrics are sent to.
Sinks []EnvoyGatewayMetricSink `json:"sinks,omitempty"`
// Prometheus defines the configuration for prometheus endpoint.
Prometheus *EnvoyGatewayPrometheusProvider `json:"prometheus,omitempty"`
}

// EnvoyGatewayMetricSink defines control plane
// metric sinks where metrics are sent to.
type EnvoyGatewayMetricSink struct {
// Type defines the metric sink type.
// EG control plane currently supports OpenTelemetry.
// +kubebuilder:validation:Enum=OpenTelemetry
// +kubebuilder:default=OpenTelemetry
Type MetricSinkType `json:"type"`
// Host define the sink service hostname.
Host string `json:"host"`
// Port defines the port the sink service is exposed on.
//
// +optional
// +kubebuilder:validation:Minimum=0
// +kubebuilder:default=4317
Port int32 `json:"port,omitempty"`
}

// EnvoyGatewayPrometheusProvider will expose prometheus endpoint
// `/stats/prometheus` and reuse Envoy Gateway admin port.
type EnvoyGatewayPrometheusProvider struct {
}
13 changes: 13 additions & 0 deletions api/v1alpha1/envoygateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ type EnvoyGatewaySpec struct {
// +optional
// +kubebuilder:default={default: info}
Logging *EnvoyGatewayLogging `json:"logging,omitempty"`

// Telemetry defines telemetry related configurations for envoy gateway.
//
// +optional
Telemetry *EnvoyGatewayTelemetry `json:"telemetry,omitempty"`

// Admin defines the desired admin related abilities.
// If unspecified, the Admin is used with default configuration
// parameters.
Expand Down Expand Up @@ -79,6 +85,13 @@ type EnvoyGatewaySpec struct {
ExtensionAPIs *ExtensionAPISettings `json:"extensionApis,omitempty"`
}

// EnvoyGatewayTelemetry defines telemetry configurations for envoy gateway control plane.
// Control plane will focus on metrics observability telemetry and tracing telemetry later.
type EnvoyGatewayTelemetry struct {
// Metrics defines metrics configuration for envoy gateway.
Metrics *EnvoyGatewayMetrics `json:"metrics,omitempty"`
}

// EnvoyGatewayLogging defines logging for Envoy Gateway.
type EnvoyGatewayLogging struct {
// Level is the logging level. If unspecified, defaults to "info".
Expand Down
26 changes: 13 additions & 13 deletions api/v1alpha1/envoyproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,44 +129,44 @@ type ProxyLogging struct {
// and the log level is the value. If unspecified, defaults to "default: warn".
//
// +kubebuilder:default={default: warn}
Level map[LogComponent]LogLevel `json:"level,omitempty"`
Level map[ProxyLogComponent]LogLevel `json:"level,omitempty"`
}

// LogComponent defines a component that supports a configured logging level.
// ProxyLogComponent defines a component that supports a configured logging level.
// +kubebuilder:validation:Enum=system;upstream;http;connection;admin;client;filter;main;router;runtime
type LogComponent string
type ProxyLogComponent string

const (
// LogComponentDefault defines the default logging component.
// See more details: https://www.envoyproxy.io/docs/envoy/latest/operations/cli#cmdoption-l
LogComponentDefault LogComponent = "default"
LogComponentDefault ProxyLogComponent = "default"

// LogComponentUpstream defines the "upstream" logging component.
LogComponentUpstream LogComponent = "upstream"
LogComponentUpstream ProxyLogComponent = "upstream"

// LogComponentHTTP defines the "http" logging component.
LogComponentHTTP LogComponent = "http"
LogComponentHTTP ProxyLogComponent = "http"

// LogComponentConnection defines the "connection" logging component.
LogComponentConnection LogComponent = "connection"
LogComponentConnection ProxyLogComponent = "connection"

// LogComponentAdmin defines the "admin" logging component.
LogComponentAdmin LogComponent = "admin"
LogComponentAdmin ProxyLogComponent = "admin"

// LogComponentClient defines the "client" logging component.
LogComponentClient LogComponent = "client"
LogComponentClient ProxyLogComponent = "client"

// LogComponentFilter defines the "filter" logging component.
LogComponentFilter LogComponent = "filter"
LogComponentFilter ProxyLogComponent = "filter"

// LogComponentMain defines the "main" logging component.
LogComponentMain LogComponent = "main"
LogComponentMain ProxyLogComponent = "main"

// LogComponentRouter defines the "router" logging component.
LogComponentRouter LogComponent = "router"
LogComponentRouter ProxyLogComponent = "router"

// LogComponentRuntime defines the "runtime" logging component.
LogComponentRuntime LogComponent = "runtime"
LogComponentRuntime ProxyLogComponent = "runtime"
)

// ProxyBootstrap defines Envoy Bootstrap configuration.
Expand Down
16 changes: 8 additions & 8 deletions api/v1alpha1/metric_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@

package v1alpha1

type MetricSinkType string

const (
MetricSinkTypeOpenTelemetry MetricSinkType = "OpenTelemetry"
)

type ProxyMetrics struct {
// Prometheus defines the configuration for Admin endpoint `/stats/prometheus`.
Prometheus *PrometheusProvider `json:"prometheus,omitempty"`
Prometheus *ProxyPrometheusProvider `json:"prometheus,omitempty"`
// Sinks defines the metric sinks where metrics are sent to.
Sinks []MetricSink `json:"sinks,omitempty"`
// Matches defines configuration for selecting specific metrics instead of generating all metrics stats
Expand All @@ -23,12 +29,6 @@ type ProxyMetrics struct {
EnableVirtualHostStats bool `json:"enableVirtualHostStats,omitempty"`
}

type MetricSinkType string

const (
MetricSinkTypeOpenTelemetry MetricSinkType = "OpenTelemetry"
)

type MetricSink struct {
// Type defines the metric sink type.
// EG currently only supports OpenTelemetry.
Expand Down Expand Up @@ -71,5 +71,5 @@ type OpenTelemetrySink struct {
// TODO: add support for customizing OpenTelemetry sink in https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/stat_sinks/open_telemetry/v3/open_telemetry.proto#envoy-v3-api-msg-extensions-stat-sinks-open-telemetry-v3-sinkconfig
}

type PrometheusProvider struct {
type ProxyPrometheusProvider struct {
}
14 changes: 7 additions & 7 deletions api/v1alpha1/validation/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,20 +560,20 @@ func TestEnvoyGatewayAdmin(t *testing.T) {
func TestGetEnvoyProxyDefaultComponentLevel(t *testing.T) {
cases := []struct {
logging egv1a1.ProxyLogging
component egv1a1.LogComponent
component egv1a1.ProxyLogComponent
expected egv1a1.LogLevel
}{
{
logging: egv1a1.ProxyLogging{
Level: map[egv1a1.LogComponent]egv1a1.LogLevel{
Level: map[egv1a1.ProxyLogComponent]egv1a1.LogLevel{
egv1a1.LogComponentDefault: egv1a1.LogLevelInfo,
},
},
expected: egv1a1.LogLevelInfo,
},
{
logging: egv1a1.ProxyLogging{
Level: map[egv1a1.LogComponent]egv1a1.LogLevel{
Level: map[egv1a1.ProxyLogComponent]egv1a1.LogLevel{
egv1a1.LogComponentDefault: egv1a1.LogLevelInfo,
},
},
Expand All @@ -600,15 +600,15 @@ func TestGetEnvoyProxyComponentLevelArgs(t *testing.T) {
},
{
logging: egv1a1.ProxyLogging{
Level: map[egv1a1.LogComponent]egv1a1.LogLevel{
Level: map[egv1a1.ProxyLogComponent]egv1a1.LogLevel{
egv1a1.LogComponentDefault: egv1a1.LogLevelInfo,
},
},
expected: "",
},
{
logging: egv1a1.ProxyLogging{
Level: map[egv1a1.LogComponent]egv1a1.LogLevel{
Level: map[egv1a1.ProxyLogComponent]egv1a1.LogLevel{
egv1a1.LogComponentDefault: egv1a1.LogLevelInfo,
egv1a1.LogComponentAdmin: egv1a1.LogLevelWarn,
},
Expand All @@ -617,7 +617,7 @@ func TestGetEnvoyProxyComponentLevelArgs(t *testing.T) {
},
{
logging: egv1a1.ProxyLogging{
Level: map[egv1a1.LogComponent]egv1a1.LogLevel{
Level: map[egv1a1.ProxyLogComponent]egv1a1.LogLevel{
egv1a1.LogComponentDefault: egv1a1.LogLevelInfo,
egv1a1.LogComponentAdmin: egv1a1.LogLevelWarn,
egv1a1.LogComponentFilter: egv1a1.LogLevelDebug,
Expand All @@ -627,7 +627,7 @@ func TestGetEnvoyProxyComponentLevelArgs(t *testing.T) {
},
{
logging: egv1a1.ProxyLogging{
Level: map[egv1a1.LogComponent]egv1a1.LogLevel{
Level: map[egv1a1.ProxyLogComponent]egv1a1.LogLevel{
egv1a1.LogComponentDefault: egv1a1.LogLevelInfo,
egv1a1.LogComponentAdmin: egv1a1.LogLevelWarn,
egv1a1.LogComponentFilter: egv1a1.LogLevelDebug,
Expand Down
114 changes: 97 additions & 17 deletions api/v1alpha1/zz_generated.deepcopy.go

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

Loading

0 comments on commit dcbb582

Please sign in to comment.