CodeScoring.Save Monitoring
CodeScoring.Save exports metrics in the Prometheus format. This page describes which component exports which metrics, how to set up metric collection in Kubernetes, and what the metrics mean. It also provides ready-made PromQL queries, a Grafana dashboard, and starter alerting rules.
Metrics endpoints
The worker component runs only with REDIS_ENABLED: "true" and PostgreSQL. Scheduled cleanup policy runs are executed by worker, while a policy run started manually from the web interface or through the API is executed by backend. So the cleanup_* metrics can come from both components: collect metrics from both backend and worker.
Every series carries the otel_scope_name and otel_scope_version labels. Service attributes (service_name, service_version) are available in the target_info metric.
Kubernetes setup
Metrics Services
Create separate Services that expose the backend metrics port and the worker HEALTH_PORT. The Services select pods by the app=backend and app=worker labels:
If you changed METRICS_PORT or HEALTH_PORT, use the same values in port and targetPort.
ServiceMonitor (Prometheus Operator)
One ServiceMonitor with two endpoints. Each endpoint applies only to the Services that have a port with that name:
jobLabel takes the job name from the app.kubernetes.io/part-of label of the Services, so the series of both backend and worker get job="codescoring-save". The queries, alerting rules, and the dashboard on this page select Save metrics by this label.
Prometheus Operator picks up only the ServiceMonitors that match serviceMonitorSelector and serviceMonitorNamespaceSelector of your Prometheus resource. If these selectors are set, add the required labels to the ServiceMonitor, for example release: kube-prometheus-stack.
Annotations (Prometheus without the Operator)
If Prometheus discovers targets by prometheus.io/* annotations, add them to the backend and worker pod templates:
The queries on this page select Save metrics by job="codescoring-save". Collect the Save pods in a separate scrape job with this name:
If your generic job for annotated pods also scrapes the codescoring-save namespace, exclude this namespace from it so the metrics are not collected twice.
Verification
Check that both components export metrics:
In Prometheus, up{job="codescoring-save"} must equal 1 for every backend and worker pod.
Metrics reference
A counter appears in /metrics only after its first increment. Right after startup backend exports only the http_* metrics.
HTTP (backend)
The path label holds the route template, not the request URL: /api/v1/projects/:project, /v2/{name}/blobs/{digest}, /maven/:project/:repository/*path. Requests that match no route are counted with path="<unmatched>".
Histogram bucket boundaries in seconds: 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30.
Artifacts and storage (backend)
Proxy repositories (backend)
proxy_requests_total counts requests to proxy repositories of all formats:
cache_hit="true"— the artifact was served from local storage;cache_hit="false"— the artifact was fetched from the upstream repository; if the upstream fetch failed,success="false".
proxy_blocked_total counts requests blocked by CodeScoring OSA Proxy. A block is a policy verdict, not a failure, so it is not counted in proxy_requests_total.
Cleanup (backend or worker)
cleanup_operations_total grows by 1 every time a cleanup policy runs for a repository. cleanup_artifacts_deleted_total grows by the number of artifacts that run deleted.
PromQL queries
Request rate by route:
Share of 5xx responses:
p95 response time — overall and by route:
Proxy cache hit rate — overall and by repository:
Failed requests to upstream repositories:
Requests blocked by OSA Proxy in the last hour:
Downloads by format:
Artifacts deleted by cleanup per day, and failed cleanup runs:
Grafana dashboard
The ready-made dashboard contains panels for HTTP requests, response time (p95 and p99), artifact uploads and downloads, proxy cache hits, storage operations, and cleanup.
- Download the dashboard JSON file.
- In Grafana, open Dashboards → New → Import and upload the file.
- In the Prometheus field, select the data source that collects Save metrics, and click Import.
The job variable at the top of the dashboard selects Save metrics; its default value is codescoring-save.
Alerting rules
A starter set of Prometheus rules:
SaveCleanupFailed also checks newly observed positive failure counters: the first failed run creates its series at 1, which increase() alone cannot detect. This fallback can also fire when Prometheus starts collecting an existing nonzero failure counter; it expires after one hour without further failures.
The rules select Save metrics by job="codescoring-save", see ServiceMonitor and Annotations. If your Save metrics have a different job, change it in the queries, the rules, and the job dashboard variable. Tune the thresholds to the load of your installation.
