diff --git a/charts/linkerd-control-plane/templates/podmonitor.yaml b/charts/linkerd-control-plane/templates/podmonitor.yaml index 0909c8d44962f..9d00945a29cdd 100644 --- a/charts/linkerd-control-plane/templates/podmonitor.yaml +++ b/charts/linkerd-control-plane/templates/podmonitor.yaml @@ -60,6 +60,9 @@ spec: podMetricsEndpoints: - interval: {{ $podMonitor.scrapeInterval }} scrapeTimeout: {{ $podMonitor.scrapeTimeout }} + {{- if not (kindIs "invalid" $podMonitor.serviceMirror.honorTimestamps) }} + honorTimestamps: {{ $podMonitor.serviceMirror.honorTimestamps }} + {{- end }} relabelings: - sourceLabels: - __meta_kubernetes_pod_label_linkerd_io_control_plane_component @@ -99,6 +102,9 @@ spec: podMetricsEndpoints: - interval: {{ $podMonitor.scrapeInterval }} scrapeTimeout: {{ $podMonitor.scrapeTimeout }} + {{- if not (kindIs "invalid" $podMonitor.proxy.honorTimestamps) }} + honorTimestamps: {{ $podMonitor.proxy.honorTimestamps }} + {{- end }} relabelings: - sourceLabels: - __meta_kubernetes_pod_container_name diff --git a/charts/linkerd-control-plane/values.yaml b/charts/linkerd-control-plane/values.yaml index 0735571633230..f809d36cc6de1 100644 --- a/charts/linkerd-control-plane/values.yaml +++ b/charts/linkerd-control-plane/values.yaml @@ -727,9 +727,16 @@ podMonitor: serviceMirror: # -- Enables the creation of PodMonitor for the Service Mirror component enabled: true + # -- Sets honorTimestamps for the Service Mirror PodMonitor endpoint. When set to false, + # Prometheus uses scrape time instead of exporter-provided timestamps. + honorTimestamps: false proxy: # -- Enables the creation of PodMonitor for the data-plane enabled: true + # -- Sets honorTimestamps for the proxy PodMonitor endpoint. When set to false, + # Prometheus uses scrape time instead of exporter-provided timestamps, + # preventing duplicate timestamp drops in clusters with frequent pod restarts. + honorTimestamps: false # Egress related configuration diff --git a/pkg/charts/linkerd2/values.go b/pkg/charts/linkerd2/values.go index de5c89d461e5f..770942c5b0947 100644 --- a/pkg/charts/linkerd2/values.go +++ b/pkg/charts/linkerd2/values.go @@ -269,7 +269,8 @@ type ( // PodMonitorComponent contains the fields to configure the Prometheus Operator `PodMonitor` for other components PodMonitorComponent struct { - Enabled bool `json:"enabled"` + Enabled bool `json:"enabled"` + HonorTimestamps *bool `json:"honorTimestamps,omitempty"` } // PolicyController contains the fields to configure the policy controller container diff --git a/pkg/charts/linkerd2/values_test.go b/pkg/charts/linkerd2/values_test.go index 62bf3a3f7a0dc..b29f4efde2b1b 100644 --- a/pkg/charts/linkerd2/values_test.go +++ b/pkg/charts/linkerd2/values_test.go @@ -88,8 +88,8 @@ func TestNewValues(t *testing.T) { - linkerd-viz `, }, - ServiceMirror: &PodMonitorComponent{Enabled: true}, - Proxy: &PodMonitorComponent{Enabled: true}, + ServiceMirror: &PodMonitorComponent{Enabled: true, HonorTimestamps: func() *bool { b := false; return &b }()}, + Proxy: &PodMonitorComponent{Enabled: true, HonorTimestamps: func() *bool { b := false; return &b }()}, }, DestinationController: &DestinationController{ MeshedHttp2ClientProtobuf: map[string]interface{}{