Skip to content

Commit

Permalink
[stackdriver] add default 1 hour stale metric expiry. (#36331)
Browse files Browse the repository at this point in the history
* [stackdriver] add default 1 hour stale metric expiry.

* gen

* ut
  • Loading branch information
bianpengyuan committed Dec 1, 2021
1 parent 462a48c commit a21c2c4
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 19 deletions.
Expand Up @@ -360,7 +360,10 @@ spec:
"@type": "type.googleapis.com/google.protobuf.StringValue"
value: |
{{- if not .Values.telemetry.v2.stackdriver.configOverride }}
{"access_logging": "{{ .Values.telemetry.v2.stackdriver.outboundAccessLogging }}"}
{
"access_logging": "{{ .Values.telemetry.v2.stackdriver.outboundAccessLogging }}",
"metric_expiry_duration": "3600s"
}
{{- else }}
{{ toJson .Values.telemetry.v2.stackdriver.configOverride | indent 18 }}
{{- end }}
Expand Down Expand Up @@ -395,7 +398,12 @@ spec:
"@type": "type.googleapis.com/google.protobuf.StringValue"
value: |
{{- if not .Values.telemetry.v2.stackdriver.configOverride }}
{"disable_server_access_logging": {{ not .Values.telemetry.v2.stackdriver.logging }}, "access_logging": "{{ .Values.telemetry.v2.stackdriver.inboundAccessLogging }}", "disable_host_header_fallback": true}
{
"disable_server_access_logging": {{ not .Values.telemetry.v2.stackdriver.logging }},
"access_logging": "{{ .Values.telemetry.v2.stackdriver.inboundAccessLogging }}",
"disable_host_header_fallback": true,
"metric_expiry_duration": "3600s"
}
{{- else }}
{{ toJson .Values.telemetry.v2.stackdriver.configOverride | indent 18 }}
{{- end }}
Expand Down Expand Up @@ -429,7 +437,11 @@ spec:
"@type": "type.googleapis.com/google.protobuf.StringValue"
value: |
{{- if not .Values.telemetry.v2.stackdriver.configOverride }}
{"access_logging": "{{ .Values.telemetry.v2.stackdriver.outboundAccessLogging }}", "disable_host_header_fallback": true}
{
"access_logging": "{{ .Values.telemetry.v2.stackdriver.outboundAccessLogging }}",
"disable_host_header_fallback": true,
"metric_expiry_duration": "3600s"
}
{{- else }}
{{ toJson .Values.telemetry.v2.stackdriver.configOverride | indent 18 }}
{{- end }}
Expand Down Expand Up @@ -476,7 +488,10 @@ spec:
"@type": "type.googleapis.com/google.protobuf.StringValue"
value: |
{{- if not .Values.telemetry.v2.stackdriver.configOverride }}
{"access_logging": "{{ .Values.telemetry.v2.stackdriver.outboundAccessLogging }}"}
{
"access_logging": "{{ .Values.telemetry.v2.stackdriver.outboundAccessLogging }}",
"metric_expiry_duration": "3600s"
}
{{- else }}
{{ toJson .Values.telemetry.v2.stackdriver.configOverride | indent 18 }}
{{- end }}
Expand Down Expand Up @@ -509,7 +524,11 @@ spec:
"@type": "type.googleapis.com/google.protobuf.StringValue"
value: |
{{- if not .Values.telemetry.v2.stackdriver.configOverride }}
{"disable_server_access_logging": {{ not .Values.telemetry.v2.stackdriver.logging }}, "access_logging": "{{ .Values.telemetry.v2.stackdriver.inboundAccessLogging }}"}
{
"disable_server_access_logging": {{ not .Values.telemetry.v2.stackdriver.logging }},
"access_logging": "{{ .Values.telemetry.v2.stackdriver.inboundAccessLogging }}",
"metric_expiry_duration": "3600s"
}
{{- else }}
{{ toJson .Values.telemetry.v2.stackdriver.configOverride | indent 18 }}
{{- end }}
Expand Down Expand Up @@ -541,7 +560,10 @@ spec:
"@type": "type.googleapis.com/google.protobuf.StringValue"
value: |
{{- if not .Values.telemetry.v2.stackdriver.configOverride }}
{"access_logging": "{{ .Values.telemetry.v2.stackdriver.outboundAccessLogging }}"}
{
"access_logging": "{{ .Values.telemetry.v2.stackdriver.outboundAccessLogging }}",
"metric_expiry_duration": "3600s"
}
{{- else }}
{{ toJson .Values.telemetry.v2.stackdriver.configOverride | indent 18 }}
{{- end }}
Expand Down
34 changes: 28 additions & 6 deletions manifests/charts/istiod-remote/templates/telemetryv2_1.13.yaml
Expand Up @@ -360,7 +360,10 @@ spec:
"@type": "type.googleapis.com/google.protobuf.StringValue"
value: |
{{- if not .Values.telemetry.v2.stackdriver.configOverride }}
{"access_logging": "{{ .Values.telemetry.v2.stackdriver.outboundAccessLogging }}"}
{
"access_logging": "{{ .Values.telemetry.v2.stackdriver.outboundAccessLogging }}",
"metric_expiry_duration": "3600s"
}
{{- else }}
{{ toJson .Values.telemetry.v2.stackdriver.configOverride | indent 18 }}
{{- end }}
Expand Down Expand Up @@ -395,7 +398,12 @@ spec:
"@type": "type.googleapis.com/google.protobuf.StringValue"
value: |
{{- if not .Values.telemetry.v2.stackdriver.configOverride }}
{"disable_server_access_logging": {{ not .Values.telemetry.v2.stackdriver.logging }}, "access_logging": "{{ .Values.telemetry.v2.stackdriver.inboundAccessLogging }}", "disable_host_header_fallback": true}
{
"disable_server_access_logging": {{ not .Values.telemetry.v2.stackdriver.logging }},
"access_logging": "{{ .Values.telemetry.v2.stackdriver.inboundAccessLogging }}",
"disable_host_header_fallback": true,
"metric_expiry_duration": "3600s"
}
{{- else }}
{{ toJson .Values.telemetry.v2.stackdriver.configOverride | indent 18 }}
{{- end }}
Expand Down Expand Up @@ -429,7 +437,11 @@ spec:
"@type": "type.googleapis.com/google.protobuf.StringValue"
value: |
{{- if not .Values.telemetry.v2.stackdriver.configOverride }}
{"access_logging": "{{ .Values.telemetry.v2.stackdriver.outboundAccessLogging }}", "disable_host_header_fallback": true}
{
"access_logging": "{{ .Values.telemetry.v2.stackdriver.outboundAccessLogging }}",
"disable_host_header_fallback": true,
"metric_expiry_duration": "3600s"
}
{{- else }}
{{ toJson .Values.telemetry.v2.stackdriver.configOverride | indent 18 }}
{{- end }}
Expand Down Expand Up @@ -476,7 +488,10 @@ spec:
"@type": "type.googleapis.com/google.protobuf.StringValue"
value: |
{{- if not .Values.telemetry.v2.stackdriver.configOverride }}
{"access_logging": "{{ .Values.telemetry.v2.stackdriver.outboundAccessLogging }}"}
{
"access_logging": "{{ .Values.telemetry.v2.stackdriver.outboundAccessLogging }}",
"metric_expiry_duration": "3600s"
}
{{- else }}
{{ toJson .Values.telemetry.v2.stackdriver.configOverride | indent 18 }}
{{- end }}
Expand Down Expand Up @@ -509,7 +524,11 @@ spec:
"@type": "type.googleapis.com/google.protobuf.StringValue"
value: |
{{- if not .Values.telemetry.v2.stackdriver.configOverride }}
{"disable_server_access_logging": {{ not .Values.telemetry.v2.stackdriver.logging }}, "access_logging": "{{ .Values.telemetry.v2.stackdriver.inboundAccessLogging }}"}
{
"disable_server_access_logging": {{ not .Values.telemetry.v2.stackdriver.logging }},
"access_logging": "{{ .Values.telemetry.v2.stackdriver.inboundAccessLogging }}",
"metric_expiry_duration": "3600s"
}
{{- else }}
{{ toJson .Values.telemetry.v2.stackdriver.configOverride | indent 18 }}
{{- end }}
Expand Down Expand Up @@ -541,7 +560,10 @@ spec:
"@type": "type.googleapis.com/google.protobuf.StringValue"
value: |
{{- if not .Values.telemetry.v2.stackdriver.configOverride }}
{"access_logging": "{{ .Values.telemetry.v2.stackdriver.outboundAccessLogging }}"}
{
"access_logging": "{{ .Values.telemetry.v2.stackdriver.outboundAccessLogging }}",
"metric_expiry_duration": "3600s"
}
{{- else }}
{{ toJson .Values.telemetry.v2.stackdriver.configOverride | indent 18 }}
{{- end }}
Expand Down
3 changes: 3 additions & 0 deletions pilot/pkg/model/telemetry.go
Expand Up @@ -18,6 +18,7 @@ import (
"sort"
"strings"
"sync"
"time"

listener "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3"
httpwasm "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/wasm/v3"
Expand All @@ -26,6 +27,7 @@ import (
wasm "github.com/envoyproxy/go-control-plane/envoy/extensions/wasm/v3"
"github.com/gogo/protobuf/types"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/known/durationpb"
wrappers "google.golang.org/protobuf/types/known/wrapperspb"

sd "istio.io/api/envoy/extensions/stackdriver/config/v1alpha1"
Expand Down Expand Up @@ -834,6 +836,7 @@ func generateSDConfig(class networking.ListenerClass, telemetryConfig telemetryF
cfg.AccessLogging = sd.PluginConfig_ERRORS_ONLY
}
}
cfg.MetricExpiryDuration = durationpb.New(1 * time.Hour)
// In WASM we are not actually processing protobuf at all, so we need to encode this to JSON
cfgJSON, _ := protomarshal.MarshalProtoNames(&cfg)
return networking.MessageToAny(&wrappers.StringValue{Value: string(cfgJSON)})
Expand Down
14 changes: 7 additions & 7 deletions pilot/pkg/model/telemetry_test.go
Expand Up @@ -565,7 +565,7 @@ func TestTelemetryFilters(t *testing.T) {
networking.ListenerProtocolHTTP,
nil,
map[string]string{
"istio.stackdriver": `{}`,
"istio.stackdriver": `{"metric_expiry_duration":"3600s"}`,
},
},
{
Expand All @@ -576,7 +576,7 @@ func TestTelemetryFilters(t *testing.T) {
networking.ListenerProtocolHTTP,
nil,
map[string]string{
"istio.stackdriver": `{"metrics_overrides":{"client/request_count":{"tag_overrides":{"add":"bar"}}}}`,
"istio.stackdriver": `{"metric_expiry_duration":"3600s","metrics_overrides":{"client/request_count":{"tag_overrides":{"add":"bar"}}}}`,
},
},
{
Expand All @@ -590,7 +590,7 @@ func TestTelemetryFilters(t *testing.T) {
networking.ListenerProtocolHTTP,
nil,
map[string]string{
"istio.stackdriver": `{}`,
"istio.stackdriver": `{"metric_expiry_duration":"3600s"}`,
},
},
{
Expand Down Expand Up @@ -630,7 +630,7 @@ func TestTelemetryFilters(t *testing.T) {
networking.ListenerProtocolHTTP,
&meshconfig.MeshConfig_DefaultProviders{Metrics: []string{"prometheus"}},
map[string]string{
"istio.stackdriver": `{}`,
"istio.stackdriver": `{"metric_expiry_duration":"3600s"}`,
},
},
{
Expand All @@ -643,7 +643,7 @@ func TestTelemetryFilters(t *testing.T) {
networking.ListenerProtocolHTTP,
nil,
map[string]string{
"istio.stackdriver": `{"access_logging":"ERRORS_ONLY"}`,
"istio.stackdriver": `{"access_logging":"ERRORS_ONLY","metric_expiry_duration":"3600s"}`,
},
},
{
Expand All @@ -656,7 +656,7 @@ func TestTelemetryFilters(t *testing.T) {
networking.ListenerProtocolHTTP,
&meshconfig.MeshConfig_DefaultProviders{AccessLogging: []string{"stackdriver"}},
map[string]string{
"istio.stackdriver": `{"disable_host_header_fallback":true,"access_logging":"FULL"}`,
"istio.stackdriver": `{"disable_host_header_fallback":true,"access_logging":"FULL","metric_expiry_duration":"3600s"}`,
},
},
{
Expand All @@ -670,7 +670,7 @@ func TestTelemetryFilters(t *testing.T) {
AccessLogging: []string{"stackdriver"},
},
map[string]string{
"istio.stackdriver": `{"disable_host_header_fallback":true,"access_logging":"FULL"}`,
"istio.stackdriver": `{"disable_host_header_fallback":true,"access_logging":"FULL","metric_expiry_duration":"3600s"}`,
},
},
}
Expand Down

0 comments on commit a21c2c4

Please sign in to comment.