diff --git a/packages/system/observability-proxy/templates/deployment.yaml b/packages/system/observability-proxy/templates/deployment.yaml index 581c15fde..d49de140b 100644 --- a/packages/system/observability-proxy/templates/deployment.yaml +++ b/packages/system/observability-proxy/templates/deployment.yaml @@ -38,6 +38,9 @@ spec: - --cluster-domain={{ $clusterDomain }} - --root-tenant={{ .Values.observabilityProxy.rootTenant }} - --auth-cache-ttl={{ .Values.observabilityProxy.authCacheTTL }} + - --metrics-shortterm-store={{ .Values.observabilityProxy.metrics.shorttermStore }} + - --metrics-longterm-store={{ .Values.observabilityProxy.metrics.longtermStore }} + - --metrics-shortterm-retention={{ .Values.observabilityProxy.metrics.shorttermRetention }} ports: - name: http containerPort: 8080 diff --git a/packages/system/observability-proxy/templates/tenant-clusterroles.yaml b/packages/system/observability-proxy/templates/tenant-clusterroles.yaml index 23460352f..a2bf94f3c 100644 --- a/packages/system/observability-proxy/templates/tenant-clusterroles.yaml +++ b/packages/system/observability-proxy/templates/tenant-clusterroles.yaml @@ -1,7 +1,7 @@ # Aggregated into cozy-tenant-view (and consequently use, admin, super-admin). -# No API server serves cozystack.io logs: the rule exists only for the -# SubjectAccessReview the observability proxy asks before it answers a read -# under /apis/cozystack.io/v1alpha1/namespaces//logs/. +# No API server serves cozystack.io logs or metrics: the rule exists only for +# the SubjectAccessReview the observability proxy asks before it answers a +# read under /apis/cozystack.io/v1alpha1/namespaces//{logs,metrics}/. apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: @@ -10,5 +10,5 @@ metadata: rbac.cozystack.io/aggregate-to-tenant-view: "true" rules: - apiGroups: ["cozystack.io"] - resources: ["logs"] + resources: ["logs", "metrics"] verbs: ["list"] diff --git a/packages/system/observability-proxy/tests/deployment_test.yaml b/packages/system/observability-proxy/tests/deployment_test.yaml index ddf9d34b8..a5e948920 100644 --- a/packages/system/observability-proxy/tests/deployment_test.yaml +++ b/packages/system/observability-proxy/tests/deployment_test.yaml @@ -40,6 +40,35 @@ tests: path: spec.template.spec.containers[0].args content: --auth-cache-ttl=10s + - it: passes the metrics store names and short-term retention + asserts: + - contains: + path: spec.template.spec.containers[0].args + content: --metrics-shortterm-store=shortterm + - contains: + path: spec.template.spec.containers[0].args + content: --metrics-longterm-store=longterm + - contains: + path: spec.template.spec.containers[0].args + content: --metrics-shortterm-retention=72h + + - it: follows renamed metrics stores + set: + observabilityProxy.metrics: + shorttermStore: fast + longtermStore: slow + shorttermRetention: 24h + asserts: + - contains: + path: spec.template.spec.containers[0].args + content: --metrics-shortterm-store=fast + - contains: + path: spec.template.spec.containers[0].args + content: --metrics-longterm-store=slow + - contains: + path: spec.template.spec.containers[0].args + content: --metrics-shortterm-retention=24h + - it: falls back to cozy.local when the platform passes no cluster domain asserts: - contains: diff --git a/packages/system/observability-proxy/tests/rbac_test.yaml b/packages/system/observability-proxy/tests/rbac_test.yaml index af339b5d0..ef96c65d7 100644 --- a/packages/system/observability-proxy/tests/rbac_test.yaml +++ b/packages/system/observability-proxy/tests/rbac_test.yaml @@ -2,7 +2,7 @@ suite: observability-proxy RBAC # The proxy authenticates and authorizes every request through the API server, # so a dropped verb here turns every request into an error at runtime rather # than a render failure. The tenant role is what lets a namespace viewer pass -# the SubjectAccessReview the proxy asks for the namespace logs root. +# the SubjectAccessReview the proxy asks for the namespace logs and metrics roots. templates: - templates/rbac.yaml - templates/tenant-clusterroles.yaml @@ -50,7 +50,7 @@ tests: name: observability-proxy namespace: cozy-observability-proxy - - it: aggregates list on cozystack.io logs into the tenant view role + - it: aggregates list on cozystack.io logs and metrics into the tenant view role template: templates/tenant-clusterroles.yaml asserts: - isKind: @@ -63,5 +63,5 @@ tests: path: rules value: - apiGroups: ["cozystack.io"] - resources: ["logs"] + resources: ["logs", "metrics"] verbs: ["list"] diff --git a/packages/system/observability-proxy/values.yaml b/packages/system/observability-proxy/values.yaml index 919e450a9..67334a237 100644 --- a/packages/system/observability-proxy/values.yaml +++ b/packages/system/observability-proxy/values.yaml @@ -7,6 +7,13 @@ observabilityProxy: replicas: 2 rootTenant: tenant-root authCacheTTL: 10s + # Names and retention of the root tenant's metricsStorages + # (packages/system/monitoring/values.yaml). The retention is a Go + # duration: 3d is written 72h. + metrics: + shorttermStore: shortterm + longtermStore: longterm + shorttermRetention: 72h resources: requests: cpu: 10m