# Observability Backends

> Ship host and container metrics from your VM deployment spaces to your own VictoriaMetrics, Grafana Mimir or Prometheus, container logs to your own Grafana Loki, VictoriaLogs or Datadog, and request traces to your own Grafana Tempo, Jaeger or Zipkin, and read them back in ZopDay.

Source: https://zop.dev/developer-docs/integrations/observability

---

An **observability backend** is a metrics store you run (VictoriaMetrics, Grafana Mimir or Prometheus) connected to ZopDay (the ZopDev deploy app) as an org-level integration. Attach it to a VM deployment space and that space's VM ships host and container metrics to it every 30 seconds. The service **Observability** tab then reads those numbers back from your store, so the tab answers in well under a second and shows usage history instead of a single point-in-time reading.

A **logs backend** works the same way for container logs: a Grafana Loki, VictoriaLogs or Datadog store you run, attached to a VM space as its **Logs backend**. The VM ships every service container's output to it, and the service log viewer reads it live (refreshed every 10 seconds) with time-range, search and level filters. A **traces backend** (a Grafana Tempo, Jaeger or Zipkin store you run) keeps request traces from your services and from the edge proxy in front of them, and the **Requests** view of the service's **Observability** tab reads them back. A space can have any combination of the three. See [Logs backends](#logs-backends) and [Traces backends](#traces-backends).

**Info**

ZopDay keeps only the backend's URLs (or Datadog site), optional tenant and an encrypted credential. Every sample, log line and span lives in your store, under your retention, queryable with your own Grafana. The only exceptions are the log viewer's and the Requests view's newest page, which ZopDay caches for 5 seconds so viewers refreshing together share one read.

Without a backend attached, or while the backend is unreachable, the Observability tab works exactly as before: it reads the VM directly over the cloud provider's exec channel and shows the **Checked on the VM** pill.

## Add a backend

**Settings → Integrations → Observability → Add backend.** Integrations are shared by every project in the organisation, so any VM space can attach the same backend.

| Field | What to enter |
|---|---|
| Name | A name your team recognises, e.g. `prod-victoria`. |
| Provider | VictoriaMetrics, Grafana Mimir or Prometheus. |
| Write URL | Where the VM pushes metrics (Prometheus remote write). `https://<host>/api/v1/write` for VictoriaMetrics and Prometheus, `https://<host>/api/v1/push` for Mimir. **https only.** |
| Read URL | The `query_range` endpoint ZopDay queries for the tab. `https://<host>/api/v1/query_range`, or `https://<host>/prometheus/api/v1/query_range` for Mimir. Must be reachable from ZopDay. **https only.** |
| Tenant | Optional. Sent as `X-Scope-OrgID` on every write and read. **Required for Mimir.** |
| Authentication | **Username** (basic auth), **Bearer token**, a **Custom header** name and value, or **None** for a store that accepts writes and queries without credentials (no auth header is sent; the tenant still is). |

The paths are the stores' own. See the [Mimir HTTP API reference](https://grafana.com/docs/mimir/latest/references/http-api/) for `/api/v1/push` and `/prometheus/api/v1/query_range`, the [Prometheus HTTP API](https://prometheus.io/docs/prometheus/latest/querying/api/) for `/api/v1/write` (needs `--web.enable-remote-write-receiver`) and `/api/v1/query_range`, and the [VictoriaMetrics URL examples](https://docs.victoriametrics.com/victoriametrics/url-examples/) for both.

Click **Test connection** before saving. The probe writes one sample to the write URL and then reads it back from the read URL:

- The **write must pass**; Save stays disabled until it does.
- A read that answers correctly but does not yet show the sample is reported as a note, not a failure, most stores hide the newest 30 seconds or so.
- A read that is rejected (wrong path, wrong credential) is reported as a warning so you can fix it before attaching.

Editing a saved backend re-runs the same probe, so a rotated credential is verified before it replaces the stored one.

**Warning**

The write and read URLs must resolve to public addresses. Hosts that resolve to private ranges, plain `http://`, and redirects are all rejected, the same rule the collector on the VM follows.

### POST /integrations/test

Run the write/read connection probe against a backend without saving it. Same body as POST /integrations with category=observability.

```bash title="Request"
curl -X POST https://api.zop.dev/integrations/test \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "prod-victoria",
    "provider": "victoriametrics",
    "category": "observability",
    "config": "{\"signal\":\"metrics\",\"writeUrl\":\"https://metrics.example.com/api/v1/write\",\"readUrl\":\"https://metrics.example.com/api/v1/query_range\"}",
    "credential": "{\"authType\":\"basic\",\"username\":\"vmadmin\",\"password\":\"…\"}"
  }'
```

```json title="Response"
{
  "data": {
    "writeOk": true,
    "readOk": true,
    "readNote": "read endpoint verified; the probe sample was not visible yet (ingestion delay)"
  }
}
```

`POST /integrations`, `PUT /integrations/{id}` and `DELETE /integrations/{id}` work as for every other [integration](https://zop.dev/docs/integrations). For a metrics backend `config` carries `signal: "metrics"`, `writeUrl`, `readUrl` and optional `tenant`; `credential` carries `authType` (`basic`, `bearer`, `header` or `none`) with `username`/`password`, `token`, or `headerName`/`headerValue` (`none` carries nothing else). The credential is never returned by any read.

## Logs backends

**Settings → Integrations → Observability → Add backend**, choose **Logs**, then the provider. `config.signal` is `logs`. Every URL is **https only** and must resolve to a public address, as for metrics.

| Provider | What you enter | Authentication | What the credential must be allowed to do |
|---|---|---|---|
| Grafana Loki (`loki`) | **Write URL:** Loki's OTLP base, `https://<host>/otlp` (the agent appends `/v1/logs`). **Read URL**, `https://<host>/loki/api/v1/query_range`. **Tenant**, optional, sent as `X-Scope-OrgID`; letters, digits, `_ . : -` only. | Username (basic), Bearer token, Custom header or None | Push to and query that tenant. On Grafana Cloud leave the tenant empty and use your user ID and a token with logs write and read access as the username and password. |
| VictoriaLogs (`victorialogs`) | **Write URL:** `https://<host>/insert/opentelemetry/v1/logs`. **Read URL**, `https://<host>/select/logsql/query`. **Account ID**, optional, sent as `AccountID`; letters, digits, `_ . : -` only. | Username (basic), Bearer token, Custom header or None | Whatever your auth proxy requires on both paths. |
| Datadog (`datadog`) | **Site:** the domain in your Datadog address bar: `datadoghq.com`, `us3.datadoghq.com`, `us5.datadoghq.com`, `datadoghq.eu`, `ap1.datadoghq.com`, `ap2.datadoghq.com` or `ddog-gov.com`. No URLs. | **API key** and **Application key**, both required | The API key sends logs to log intake. The Application key reads them back for the log viewer through the Logs Search API, so it needs the `logs_read_data` permission (a scoped key must include that scope). |

The connection test writes one log line, `zopday probe <id>`, and reads it back. The line carries `service.name` and `vm_uid` `zopday-probe`, so it never mixes with a VM's container logs. As for metrics, the write must pass, and a read that answers but does not show the line yet is only a note.

```json
{ "signal": "logs", "writeUrl": "https://logs.example.com/otlp", "readUrl": "https://logs.example.com/loki/api/v1/query_range", "tenant": "acme" }
{ "signal": "logs", "options": { "site": "datadoghq.eu" } }
```

`credential.authType` is `basic`, `bearer`, `header` or `none` as for metrics, or `apikey` with `apiKey` and `appKey` for Datadog (Datadog always needs its keys, so it has no **None**).

## Traces backends

**Settings → Integrations → Observability → Add backend**, choose **Traces**, then the provider. `config.signal` is `traces`. As for metrics and logs, every `writeUrl` is **https only** and must resolve to a **public address** (`readUrl` may also be http and in-cluster, see below): the VM's agent (to write) has to reach it, so a store that only listens on a private network needs a public https write endpoint (an ingress or a tunnel) in front of it.

| Provider | Write URL | Read URL | Tenant |
|---|---|---|---|
| Grafana Tempo (`tempo`) | Tempo's OTLP/HTTP base, e.g. `https://<host>:4318`. The agent appends `/v1/traces`. With the **Zipkin** write format, the full Zipkin spans URL, `https://<host>/api/v2/spans`. | Tempo's HTTP API base, e.g. `https://<host>:3200`. ZopDay reads `/api/search` and `/api/traces/{id}`. | Optional, sent as `X-Scope-OrgID`; letters, digits, `_ . : -` only. Leave empty unless Tempo runs multi-tenant. |
| Jaeger (`jaeger`) | Jaeger's OTLP/HTTP base, e.g. `https://<host>:4318`. The agent appends `/v1/traces`. With the **Zipkin** write format, the full Zipkin spans URL, `https://<host>:9411/api/v2/spans`. | Jaeger's query API base, e.g. `https://<host>:16686`. ZopDay reads `/api/v3/traces`. | None. |
| Zipkin (`zipkin`) | The full spans URL, `https://<host>/api/v2/spans`. | Zipkin's API base, `https://<host>`. ZopDay reads `/api/v2/traces` and `/api/v2/trace/{id}`. | None. |

Authentication is **Username** (basic), **Bearer token**, a **Custom header** or **None**, as for metrics and logs. **None** (`"authType": "none"`) is for a store that takes writes and queries without credentials: no auth header is sent on writes or reads, and the tenant header still is. It is offered for every metrics, logs and traces backend except Datadog. A store without a login is your choice: anyone who can reach its write URL can send it data.

**Write format (Tempo and Jaeger).** A Tempo or Jaeger store takes spans as **OTLP** (the default; `writeUrl` is the OTLP/HTTP base and the agent appends `/v1/traces`) or as **Zipkin** JSON to the store's Zipkin receiver (Tempo's distributor, Jaeger v2's `zipkin` receiver), for a store whose public endpoint is Zipkin only. With **Zipkin**, `writeUrl` is the full spans URL and must end in `/api/v2/spans`; the agent posts there as is. Reads always use the store's own API (`readUrl`). In the config this is `options.writeFormat`: `"otlp"` or `"zipkin"`; leaving it out means `otlp`, so a store saved before the option keeps working unchanged. A Zipkin store always takes Zipkin, so it has no choice.

The connection test writes one span named `zopday probe <id>` (service `zopday-probe`) and reads that trace back by id; the write must pass, and a read that answers but does not show the span yet is only a note.

```json
{ "signal": "traces", "writeUrl": "https://tempo.example.com:4318", "readUrl": "https://tempo.example.com:3200", "tenant": "acme" }
```

A Tempo with a Zipkin write and no auth:

```json
{ "signal": "traces", "writeUrl": "https://tempo-distributor.example.com/api/v2/spans", "readUrl": "https://tempo.example.com:3200", "options": { "writeFormat": "zipkin" } }
```

with the credential `{ "authType": "none" }`.

**Note**
`readUrl` may be `http` or `https` and may point at a private or in-cluster address that ZopDay can reach, for example `http://tempo-query-frontend.tempo:3100` or `http://jaeger-query.jaeger:16686`. Link-local, carrier-grade NAT (`100.64.0.0/10`) and cloud metadata addresses (such as `169.254.169.254`, `100.100.100.200` or `metadata.google.internal`) are refused. If the read fails, **Test connection** shows only the HTTP status or that the address did not answer as a trace API — never the answer itself. A **Custom header** may not use a header name ZopDay's own services rely on (such as `X-Org-Id`, `X-User-Email`, `X-Forwarded-For` or `Host`). `writeUrl` is not covered by this: the VMs' agents run outside the cluster and need a public https URL (for a Tempo or Jaeger that only exposes Zipkin publicly, use the Zipkin write format above).

Attach it as the space's **Traces backend** (below). The agent then accepts spans from your services and forwards them to the store. ZopDay does **not** set a service's tracing environment variables for you: turn tracing on per service from its **Requests** view (below), which adds them to the service's own environment variables and redeploys it. **Switching** to another trace store takes effect right away, with no redeploy. After **detaching**, a service keeps the `OTEL_*` variables in its environment variables, so it keeps trying to send spans until you remove them. The detach confirm lists the services on the space, grouped by project.

### Send your app's traces

Add OpenTelemetry to your app to see requests, calls between services, background jobs and database time. Open the service's **Observability → Requests** view, pick how your app sends traces under **Tracing isn't enabled for this service yet** (**HTTP** or **gRPC**; the HTTP card's format is **OTLP** or **Zipkin**) and click **Add variables and redeploy**: ZopDay adds the matching variables to the service's environment variables (visible and editable in **Settings**) and redeploys it. The picker lists only the protocol's two variables, whose names you can change; the supporting ones below are added too, without being listed, so look for them in **Settings**. In the picker the bridge address shows as a **VM bridge** badge. A variable the service already has is kept as it is, never overwritten, except `OTEL_RESOURCE_ATTRIBUTES` (below), which is merged. If the service already sets its protocol (`OTEL_EXPORTER_OTLP_TRACES_PROTOCOL`, `OTEL_EXPORTER_OTLP_PROTOCOL` or `OTEL_TRACES_EXPORTER=zipkin`), that choice starts picked; a pick that conflicts with a value the service keeps can't be saved: HTTP or gRPC with an `OTEL_EXPORTER_OTLP_TRACES_PROTOCOL` of the other kind or an `OTEL_TRACES_EXPORTER` that doesn't include `otlp` (such as `none`, `console` or `jaeger`; the value is a comma-separated list, so `otlp,console` is fine), and **Zipkin (HTTP)** with an `OTEL_TRACES_EXPORTER` that doesn't include `zipkin` (an `OTEL_TRACES_EXPORTER` with `zipkin` starts on HTTP + Zipkin). A secret-backed value can't be read, so it never blocks a pick; check it yourself.

| Choice | Variables added |
|---|---|
| **HTTP**, format **OTLP** (OTLP/HTTP, most OpenTelemetry SDKs) | `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://${ZOP_DOCKER_BRIDGE}:4318/v1/traces`, `OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=http/protobuf` |
| **gRPC** (OTLP/gRPC) | `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://${ZOP_DOCKER_BRIDGE}:4317`, `OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc` |
| **Zipkin (HTTP)** (apps already instrumented with Zipkin) | `OTEL_TRACES_EXPORTER=zipkin`, `OTEL_EXPORTER_ZIPKIN_ENDPOINT=http://${ZOP_DOCKER_BRIDGE}:9411/api/v2/spans` |

Every choice also adds `OTEL_SERVICE_NAME` set to the service's container name (`zopday-<name>-<id>`), and `OTEL_METRICS_EXPORTER=none` and `OTEL_LOGS_EXPORTER=none`: SDKs whose metrics and logs exporters default to OTLP (the Java agent, `opentelemetry-instrument`) would otherwise send to `localhost:4318` inside the container, where nothing listens, and log every failed batch. Those two are left out when the service's metrics are in `otlp` mode, where the generic endpoint carries the app's metrics on purpose. If the metrics are switched to `otlp` mode later, ZopDay deploys a plain `OTEL_METRICS_EXPORTER=none` as `otlp`, so the metrics are still sent. These are the OpenTelemetry SDK's standard variable names, the same for every language and every traces backend (Tempo, Jaeger or Zipkin); the agent converts to the backend's format. **GoFr** apps read their own variables instead: set `TRACE_EXPORTER=otlp` and `TRACER_URL=${ZOP_DOCKER_BRIDGE}:4317` yourself.

Every choice also adds `OTEL_RESOURCE_ATTRIBUTES=service_id=<service id>,env_id=<environment id>` (plus `zop_org=<your organisation id>` on a VM shared with other organisations). This tag is required: it is how the **Requests** view finds the service's spans. Its name can't be changed. If the service already sets `OTEL_RESOURCE_ATTRIBUTES`, the tag is appended to your value (any old `service_id` / `env_id` entries are replaced); the merged value shows in **Settings** after saving. ZopDay adds nothing for traces on deploy, so the tag lives only in the service's environment variables: if you remove it, the service's spans are no longer listed. On each deploy ZopDay does point the tag's existing `service_id`, `env_id` and `zop_org` entries at the service being deployed, and points an `OTEL_SERVICE_NAME` that is another service's container name (`zopday-<name>-<id>`) at this service's container name, so a service whose variables were copied from another environment (**Copy environment**) is still listed under its own id, on Tempo, Zipkin and Jaeger. It changes only those entries, adds none, leaves a service name you chose yourself as it is, and can't do this for a secret-backed `OTEL_RESOURCE_ATTRIBUTES` or `OTEL_SERVICE_NAME`.

**Note**
Until October 2026 ZopDay set the tracing variables and the `service_id` tag in the container on every deploy. A service that relied on that stops sending traces after its next redeploy, until you use **Add variables and redeploy** in its **Requests** view. A service that never used that button gets no `service_id` tag, so its spans are not listed in the **Requests** view even if it sends them.

`${ZOP_DOCKER_BRIDGE}` is a placeholder, not a variable your app reads: when ZopDay deploys the service it replaces it, in any of the service's plain environment variables, with the VM's Docker bridge address (read from `docker0`, usually `172.17.0.1`), where the agent listens. A secret-backed variable is not filled in, so keep these values plain. The agent listens for OTLP (gRPC `4317`, HTTP `4318`) and for Zipkin on **`9411`** (`/api/v2/spans`), so any Zipkin-speaking tracer can send to it too. A service that had edge traces turned on earlier (`configs.tracing.edge`) keeps them: its edge proxy (Caddy) records one span per incoming request, and the app's spans join under it. The UI no longer turns edge traces on or off. **Add variables and redeploy** names an OpenTelemetry app's spans after its container. Keep that name on a **Jaeger** store: Jaeger lists traces by service name, so a service that names itself appears in the list only through its edge spans (see the limits below).

## Attach it to a VM space

Attaching is what installs the agent. Two entry points, same result:

- **Infrastructure → your VM space → Settings → Metrics backend**, **Logs backend** or **Traces backend**. Pick the backend and **Save**; one Save covers all three. The confirmation says exactly what will happen on the VM.
- **Infrastructure → your VM space → Components → Observability agent → Install.** Pick the backend in the dialog and **Install**.

Either way ZopDay records the attach on the space and runs the **observability-agent** component on the VM. The Components card shows the install in progress and then **Installed · enabled**; the first samples and log lines reach your store within about a minute.

- **Switch** to another backend by picking it and saving: the agent is re-applied with the new settings and metrics resume within a minute.
- **Detach** by choosing **No backend**: the agent stops shipping that signal, and is removed from the VM once no metrics, logs or traces backend is attached and Service Alerts are off. The tab goes back to reading the VM directly.
- A backend that any space still uses **cannot be deleted**; the Disconnect dialog names the spaces to detach first.

### What runs on the VM

The agent is a single pinned OpenTelemetry Collector container (`otel/opentelemetry-collector-contrib`), capped at **0.25 CPU and 512 MiB**. Measured footprint is 120 to 200 MiB for a VM with 20 to 30 live containers. It reads the Docker socket for per-container stats and the host for CPU, memory, disk, filesystem, load and network, every 30 seconds, and pushes them with Prometheus remote write. Its configuration and a root-only environment file with the credential are written to `/etc/zop-observability/` on the VM. Docker must already be present, which is true for any VM space that has deployed a service.

With a logs backend attached, the same agent also tails the Docker log of every running `zopday-*` service container and sends each line to your store, tagged with `container.name` and `service.name` (the container name), `service.instance.id` and `vm_uid` (the VM id), `vm_uid_lc` (the VM id in lowercase, which Datadog reads by), `org_id` and `space_id`. It starts from the moment of attaching (older lines are not replayed) and remembers its position; re-applying the agent stops it gracefully, so lines neither go missing nor repeat. Detaching the logs backend clears that position, so attaching again later starts from that moment rather than replaying the gap. A space with only a logs backend runs the agent without collecting any metrics.

### PATCH /spaces/{spaceID}

Attach, switch or detach: body { config: { observability: { metrics:
' | null, logs: '<integrationID>' | null, traces: '<integrationID>' | null } } }. Each id must be an observability integration of this org for that signal. Follow with the component install below; the UI does both on Save." />

### POST /components

Apply the agent: body { spaceId, targetType:

## What the Observability tab shows

Open a VM service → **Observability**. With a backend attached and the agent shipping, the header shows a **Metrics backend** pill and a green **Live · Ns ago** pill that says how old the newest sample is.

- **Status strip:** status, replicas ready and restarts. A container that exited cleanly (exit code 0 or 143, not out-of-memory) rolls up to **Scaled down**; a crash stays **Degraded**; a VM that cannot be reached stays **Unreachable**.
- **Usage:** CPU, Memory, Network and Block I/O over **15m / 1h / 6h / 24h**. The CPU chart draws the container's `--cpus` cap and the Memory chart its memory limit as dashed ceilings. Gaps in collection are drawn as gaps, not bridged. A scaled-down service shows dashes and the time of its last sample.
- **Replicas:** one card per container: uptime, restarts, PIDs and exit code, plus CPU, memory, network and block I/O when there are no charts.

If the agent stops reporting for more than 90 seconds, the VM rebooted, the store is down, the credential was rotated without updating the integration, the tab falls back to reading the VM directly and the pill switches to **Checked on the VM**. It returns to the backend on its own within a minute of samples resuming.

**Info**

Docker's stats stream carries no exit code, so the replica card shows a dash for it while the read comes from your store. It is filled in when the tab reads the VM directly.

### GET /resources/{resourceID}/metrics/live

Current state of the VM
 narrows to one service. source is 'backend' or 'exec'." />

### GET /resources/{resourceID}/metrics/range
, range=15m|1h|6h|24h. About 120 points per series; counters are returned as bytes per second. 404 when the space has no backend; 409 backend_host_unresolvable when the host of the stored URL does not resolve." />

## Viewing logs

Open a VM service's logs in its **Observability** tab with the **Logs** switch. There is one live view, in the page; where its lines come from depends on the space:

- **Logs backend attached:** lines are read from the backend and refreshed every 10 seconds. Pick **Last 15 minutes / 1 hour / 6 hours / 24 hours**, search case-insensitively, filter by level, and use **Show earlier logs** to page further back. On a pool with several VMs, each VM is read and the lines are merged by time. This still works when the VM itself cannot be reached.
- **No logs backend:** lines are read straight from the VM, as before.
- **A shared space you do not own:** your containers' lines are read from the space owner's logs backend, the same way; you only ever see your own services. If your container has no saved line in the last 24 hours (for example, the pool's agent has not been re-applied yet), the viewer reads its logs straight from the VM instead, and stays there until you reload the page.

### GET /resources/{resourceID}/logs/range

One page of a container
 (one of your own services), range=15m|1h|6h|24h (default 1h), limit (default 200, at most 1000), optional q (case-insensitive text, up to 200 characters), cursor (the previous page's nextCursor). Returns { items: [{ timestamp, container, line }], hasMore, nextCursor, provider }, newest first. 404 when the space has no logs backend, the container is not yours, or (on a shared space you do not own, with no q) your container has no line in the last 24 hours (read the VM's live logs); 409 backend_host_unresolvable when the host of the stored URL does not resolve; 502 when the store is unreachable or rejects the stored credential." />

## Viewing traces

Open a VM service → **Observability** and switch to **Requests** (the switch reads **Metrics | Logs | Requests**). The list shows the newest traces first over **15m / 1h / 6h / 24h**, with a search over the loaded traces (path, status or trace ID) and paging to older traces; each row shows the root span, start time, duration, span count and errors. Click a trace to open its span waterfall with each span's attributes. You only ever see your own service's spans (and its edge spans), even when the trace continues into other services. Without a traces backend on the space the switch reads **Metrics | Logs** only; attach one in the space's **Settings → Observability**. When the picked range is empty, the view says what to do next: if edge traces are off and the service has sent none of its own traces in the last 24 hours, it shows **Tracing isn't enabled for this service yet** (the protocol choice and an **Add variables and redeploy** button; the range, VM picker and Live indicator are hidden until something is recorded; a service with none of the tracing env vars, such as `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`, gets it right away instead of a loading screen); after saving it says **Env vars added** until the first requests arrive; while that change rolls out it shows **Turning on edge traces**; once tracing is on (edge traces live, or your app's own traces seen in the last 24 hours) it shows **No requests in the last …** (or **Waiting for the first request** when 24 hours hold none yet); pick a longer range above to look further back. A list of edge requests only has a **Connect your app** link under it that opens the same protocol choice.

### GET /resources/{resourceID}/traces/range

One page of a container
 (one of your own services), range=15m|1h|6h|24h (default 1h), limit (default 20, at most 100), optional q (span-name text, case-insensitive, up to 200 characters), cursor (the previous page's nextCursor). Returns { items: [{ traceId, rootService, rootName, startTime, durationMs, spanCount, errorCount }], hasMore, nextCursor, provider }, newest first. A page can come back empty with hasMore true (the store returned only other VMs' traces); keep paging. 404 when the container is not yours; 409 traces_not_configured when the space has no traces backend; 409 backend_host_unresolvable when the host of the stored URL does not resolve; 502 when the store is unreachable or rejects the stored credential." />

### GET /resources/{resourceID}/traces/{traceID}

One trace
. traceID is 16 or 32 hex characters. Returns { traceId, provider, spans: [{ spanId, parentSpanId, name, service, kind, startTime, durationMs, status, attributes }] } ordered by start time; a span whose parent is not listed is a root. 404 when the trace is unknown or has none of the container's spans; 409 traces_not_configured as above." />

**Info**

- **Jaeger and your own service name.** Jaeger lists traces by service name, and ZopDay searches for the container name **Add variables and redeploy** sets. A service that sets another `OTEL_SERVICE_NAME`, or a GoFr app (GoFr names its spans after `APP_NAME`), appears in the list only through its edge spans; without edge traces its traces are stored but not listed. Opening a trace by id works either way.
- **Large traces on Jaeger and Zipkin.** These stores return whole traces, and ZopDay reads at most 8 MiB per answer. When a page of traces is bigger, the list shows fewer traces per page; a single trace over 8 MiB cannot be opened.
- **Shared VMs.** On a VM shared with other organisations, your services' spans go to the space owner's traces store, tagged `zop_org` with your organisation id (as your logs are tagged `org_id_customer`). Which service a span belongs to is stated by the app that sent it, so on a shared VM another tenant's app could add spans to your list; it can never read yours.
- **Tempo or Jaeger with the Zipkin write format.** Spans travel as Zipkin JSON, so what Zipkin cannot carry (span links, span events beyond annotations, and resource attributes other than the service name, which arrive as span attributes) is not kept as such in Tempo. The Requests view reads them where the store keeps them.
- **Tempo error counts** are taken from at most 100 spans per trace, so a larger trace can show fewer errors than it has.
- **Tempo before 2.8** returns the first matching traces for a window rather than the newest, so on a busy service ZopDay asks again for shorter windows until it has them all. A service sending more than a page of traces in about one second, or a trace another service started earlier, can still be missed from the list; opening a trace by id always works.
- **Kubernetes services** are not covered yet; traces are for VM spaces only.

## Metrics and labels

Everything the agent ships is standard OpenTelemetry `hostmetrics` and `docker_stats` data, so you can build your own Grafana dashboards on it. The names below are what lands in a Prometheus-compatible store after the exporter's unit suffixes.

**Every series carries these labels**

| Label | Value |
|---|---|
| `org_id` | Your ZopDay organisation id |
| `space_id` | The deployment space id |
| `vm_uid` | The cloud provider's VM id, e.g. `projects/<project>/zones/<zone>/instances/<name>` on GCP |
| `cloud` | `aws`, `gcp` or `azure` |

**Container series** also carry `container_name` (`zopday-<service>-<id8>`), `service_id` (the ZopDay service id) and `container_runtime`.

| Metric | Type | Extra labels | Used on the tab for |
|---|---|---|---|
| `container_cpu_utilization_ratio` | gauge, fraction of one core | | CPU chart and card |
| `container_cpu_limit` | gauge, cores | | CPU chart ceiling |
| `container_memory_usage_total_bytes` | gauge | | Memory chart and card |
| `container_memory_usage_limit_bytes` | gauge | | Memory chart ceiling |
| `container_network_io_usage_rx_bytes_total` / `_tx_bytes_total` | counter | `interface` | Network chart, rate per interface then summed |
| `container_blockio_io_service_bytes_recursive_total` | counter | `operation` (read/write), `device_major`, `device_minor` | Block I/O chart |
| `container_pids_count` | gauge | | PIDs on the replica card |
| `container_restarts_total` | counter | | Restarts |
| `container_uptime_seconds` | gauge | | Uptime |

**Host series**

| Metric | Type | Extra labels |
|---|---|---|
| `system_cpu_time_seconds_total` | counter | `cpu`, `state` |
| `system_cpu_load_average_1m` / `_5m` / `_15m` | gauge | |
| `system_memory_usage_bytes` | gauge | `state` (used, free, cached, buffered, …) |
| `system_network_io_bytes_total` and related | counter | `device`, `direction` |
| `system_disk_io_bytes_total` and related | counter | `device`, `direction` |
| `system_filesystem_usage_bytes` | gauge | `device`, `mountpoint`, `mode`, `state` |

`system_memory_usage_bytes` is also the liveness signal: the tab treats the agent as up while a host sample is newer than 90 seconds.

**Tip**

Add your store as a Prometheus datasource and filter on `vm_uid` or `space_id`. A `sum by (container_name) (rate(container_network_io_usage_rx_bytes_total[5m]))` panel is the same number the tab's Network chart shows.

## Application metrics per service

The agent can also collect a service's own metrics. Set `configs.metrics` on the deployment and redeploy:

```json
{ "metrics": { "mode": "scrape", "port": 8000, "path": "/metrics" } }
```

- **`scrape`:** the collector discovers the container and scrapes `http://<container>:<port><path>` every 30 seconds. Every scraped series carries the same `org_id`, `space_id`, `vm_uid`, `container_name` and `service_id` labels, plus an `up` series that reads 1 while the endpoint answers and 0 when it does not.
- **`otlp`:** the container is given the collector's OTLP endpoint on the Docker bridge (`http://172.17.0.1:4318`; `4317` when you set `OTEL_EXPORTER_OTLP_PROTOCOL=grpc` and no endpoint of your own); push from an OpenTelemetry SDK.
- **`off`**, or no `metrics` key: nothing is collected. `mode` is required whenever the key is present.

Application metrics are shipped as-is, with no name filter; the per-service switch is the gate.

## From the MCP server

`test_integration` and `create_integration` cover metrics backends only; connect a logs or traces backend in the app or with the routes above, then attach and read it with the logs and traces tools below.

The metrics, logs and traces flows are available to an agent through the [ZopNight MCP server](https://zop.dev/docs/integrations/mcp-server/available-tools). These tools cover them, in the order you would use them:

| Tool | What it does |
|---|---|
| `test_integration` | Runs the write/read probe on a backend without saving it. `provider` is `victoriametrics`, `mimir` or `prometheus`; `integration_config` and `credential` are the same objects as below. Returns `writeOk`, `readOk` and the per-direction messages. |
| `create_integration` | Connects the backend: `category: "observability"`, `integration_config: { signal: "metrics", writeUrl, readUrl, tenant? }`, `credential: { authType: "basic" \| "bearer" \| "header" \| "none", … }`. The connect itself repeats the write probe and refuses a backend whose write fails. `update_integration` rotates the credential or changes the URLs; `delete_integration` disconnects it (refused while a space still uses it). |
| `set_infrastructure_metrics_backend` | Attaches the integration to a VM pool (`infrastructure_id` from `list_infrastructure`), switches it, or detaches with `detach: true`. This records the attach only. |
| `set_infrastructure_logs_backend` | The same for the logs signal: attaches a connected `loki`, `victorialogs` or `datadog` integration (or detaches with `detach: true`) and leaves the metrics backend as it is. This records the attach only. |
| `set_infrastructure_traces_backend` | The same for the traces signal: attaches a connected `tempo`, `jaeger` or `zipkin` integration (or detaches with `detach: true`) and leaves the metrics and logs backends as they are. This records the attach only; turn tracing on per service from its **Requests** view (ZopDay does not set the tracing variables on deploy). |
| `install_infrastructure_component` | With `component: "observability-agent"`, installs, re-configures or removes the collector on the pool's VMs according to the current attach. Poll `list_infrastructure_jobs` until the job settles. |

Reading back takes these tools:

- `get_live_metrics` with `scope: "vm"` (and optionally `container`) returns the live container rows the Observability tab's strip shows.
- `get_vm_usage_history` returns one container's CPU, memory, network and block I/O series over `15m`, `1h`, `6h` or `24h` from the backend.
- `get_vm_logs_history` returns one container's saved log lines from the logs backend over the same windows, newest first: `limit` lines per page (default 200, at most 1000), `search` for lines containing a text (case-insensitive, at most 200 characters), and `cursor` set to the previous page's `nextCursor` for older lines while `hasMore` is true.
- `get_vm_traces_history` returns one page of a container's traces from the traces backend over the same windows, newest first: `limit` traces per page (default 20, at most 100), `search` for traces with a span name containing a text, and `cursor` as above.
- `get_vm_trace` returns one trace's spans for the container, given a `trace_id` from `get_vm_traces_history`.

All of them address the VM by `resource_id`. Start from `get_service_infrastructure`: it names the pool a VM service runs on, its `target`, its `infrastructureOrgId`, and the pool's machines under `vms`. Which id to pass depends on who owns the pool:

- **Your own pool.** Pass the VM's id from the ZopDay inventory, the value `list_resources` reports as `id` for the machine of that name.
- **A shared pool** (`target: "zopcloud"`). Pass the machine's `instanceId` from `vms`, the provider's id such as `sep-vm-0`. A machine listed with a `name` but no `instanceId` has no key that fits the route and cannot be read this way yet. The VM belongs to the platform org, so also pass `infrastructureOrgId` as `resource_org_id` on every read while keeping `org_id` as your own org. Without it the reads see no containers.

Container names follow `zopday-<service>-<first 8 characters of the service id>`. A `404` from `get_vm_usage_history` or `get_vm_logs_history` means one of three things, in the order to check them: the VM id is wrong or not visible to your org, the container is not one of your org's deployments on that VM, or the pool has no metrics (or logs) backend attached yet. The traces tools answer a pool with no traces backend with a `409` (`traces_not_configured`) instead. For `get_vm_logs_history` on a shared pool you do not own, a fourth: with no search, your container has no saved line in the last 24 hours, read its live logs. On a shared pool, pass the pool owner's org as `resource_org_id`; your containers' saved history is read from the owner's logs backend.

**Info**

`credential` is redacted in the audit log and is not returned by any tool. Rotating it means sending a new `credential` to `update_integration`, which is verified against the store before it replaces the stored one.

## Troubleshooting

| Symptom | Likely cause | What to do |
|---|---|---|
| Test connection: write fails with 401 | Wrong credential or auth type for the store | Check the username/password or token; Mimir also needs the tenant. |
| Test connection: "resolves to a private address" | The store is only reachable inside your network | Expose it on a public https endpoint (a tunnel or ingress) that ZopDay and the VM can reach. |
| Tab shows **Checked on the VM** although a backend is attached | Agent not shipping: VM rebooted, store down, or credential changed | Check the Components card for the agent's state; re-save the backend to re-apply; confirm the store accepts writes. The tab recovers on its own within a minute of samples resuming. |
| Tab is slow and says **Collecting metrics…** | The read fell back to the VM's exec channel | Same as above; the exec read takes 20 to 60 seconds. |
| Charts have a gap | The agent or the store was down for that period, or the service was scaled to zero | Expected. A scaled-down service shows the time of its last sample. |
| Delete backend refused with 409 | A space still uses it | Detach in that space's Settings first; the message names the spaces. |
| Logs: "rejected the stored credentials" | The key was rotated or lost its read permission (Datadog: `logs_read_data`) | Update the integration's credential; it is re-tested before it is saved. |
| Requests view is empty although a traces backend is attached | The service has no tracing env vars | Use **Add variables and redeploy** in the empty Requests view. |
| Test connection: "trace API not reachable" or "the Read URL did not answer as a … trace API" | ZopDay cannot reach the trace store's Read URL, or something other than the store's query API answers there (a private or in-cluster Read URL, or one ZopDay could not connect to, gets the second message for every failure) | Check the Read URL is reachable from ZopDay and serves the trace API: the query service's address and port (for example Tempo's query frontend), not the write endpoint. |
| Requests view: "auth header name is reserved for internal use" | The trace store's credential uses a header name ZopDay keeps for its own services (for example `X-Org-Id`) | Edit the store and replace the credential with a different header name. |
