REST API

Read WatchLog from scripts with a personal API token, for Kubernetes clusters and Server fleets.

Everything the dashboard shows about your clusters, you can read from a script: pods, containers, nodes, hosts, events, the service map, alerts and metrics. You authenticate with a personal API token. It is read only and can't change anything.

The API covers both kinds of cluster WatchLog watches: Kubernetes clusters and Server fleets (one or more Linux servers). The examples below show both.

Get a token

  1. In WatchLog, open Settings → API tokens and choose Create token.
  2. Give it a name that says where you use it (for example "nightly report"), and pick when it expires.
  3. Copy the token. It starts with wl_pat_ and is shown only once.

Send it in the Authorization header:

export WATCHLOG=https://watchlog.example.com
export TOKEN=wl_pat_...

curl -H "Authorization: Bearer $TOKEN" $WATCHLOG/api/v1/me

GET /api/v1/me answers with your user and the token you used (its name, prefix, scope and expiry), which is a quick way to check that a token works.

A token reads as you: it sees the clusters you can see, nothing more. Revoke it in Settings → API tokens and the next request fails. You get an email 7 days before a token expires when WatchLog can send email.

Find a cluster

Every cluster has an id and a kind, kubernetes or docker:

curl -H "Authorization: Bearer $TOKEN" $WATCHLOG/api/v1/clusters
{
  "clusters": [
    {
      "id": "01a191fb-b18c-75a0-be51-47fcaa9eadde",
      "name": "prod-eu",
      "kind": "kubernetes",
      "status": "active",
      "nodeCount": 3,
      "lastSeenAt": "2026-11-08T14:02:31.000Z"
    },
    {
      "id": "01a18f2a-22a8-7457-94af-5a66bca41e97",
      "name": "docker-fleet",
      "kind": "docker",
      "status": "active",
      "nodeCount": 2,
      "lastSeenAt": "2026-11-08T14:02:29.000Z"
    }
  ]
}

(Shortened: responses carry more fields than shown on this page. The spec lists them all.)

The examples below use $CLUSTER for a Kubernetes cluster's id and $FLEET for a Docker fleet's id.

Kubernetes clusters

H="Authorization: Bearer $TOKEN"

# Pods, optionally in some namespaces: phase, readiness, restarts, the last termination
curl -H "$H" "$WATCHLOG/api/v1/clusters/$CLUSTER/pods?namespaces=shop"

# One pod, with its containers and why it is failing, if it is
curl -H "$H" $WATCHLOG/api/v1/clusters/$CLUSTER/pods/shop/cart-6488c85554-ws5tm

# Workloads (Deployments, StatefulSets, DaemonSets, Jobs) over the last hour
curl -H "$H" "$WATCHLOG/api/v1/clusters/$CLUSTER/workloads?range=3600"

# Nodes and one node
curl -H "$H" $WATCHLOG/api/v1/clusters/$CLUSTER/nodes
curl -H "$H" $WATCHLOG/api/v1/clusters/$CLUSTER/nodes/worker-1

# Namespaces
curl -H "$H" $WATCHLOG/api/v1/clusters/$CLUSTER/namespaces

# Warning events, newest first
curl -H "$H" "$WATCHLOG/api/v1/clusters/$CLUSTER/events?type=Warning&limit=20"

# A container's last 200 lines, redacted, never stored; previous=true for its last run
curl -H "$H" "$WATCHLOG/api/v1/clusters/$CLUSTER/pods/shop/cart-6488c85554-ws5tm/logs?container=cart&lines=200"
# Follow new lines for up to 5 minutes (server-sent events)
curl -N -H "$H" -H 'Accept: text/event-stream' "$WATCHLOG/api/v1/clusters/$CLUSTER/pods/shop/cart-6488c85554-ws5tm/logs?container=cart&follow=true"

A pod in the list looks like this:

{
  "namespace": "shop",
  "name": "cart-6488c85554-ws5tm",
  "node": "worker-2",
  "phase": "Running",
  "ready": true,
  "restarts": 0,
  "workloadKind": "Deployment",
  "workload": "cart",
  "lastTermination": null,
  "failing": null
}

Server fleets

H="Authorization: Bearer $TOKEN"

# Servers: OS, kernel, systemd and Docker, CPU, memory and disk, workload counts, problems
curl -H "$H" $WATCHLOG/api/v1/clusters/$FLEET/servers
# ...and every workload of the fleet (services, process groups, containers), problems first
curl -H "$H" "$WATCHLOG/api/v1/clusters/$FLEET/servers?workloads=1"

# One server: its use, events and who it talks to; its workloads
curl -H "$H" $WATCHLOG/api/v1/clusters/$FLEET/servers/app-1
curl -H "$H" $WATCHLOG/api/v1/clusters/$FLEET/servers/app-1/workloads

# One workload (service:<unit>, process:<group> or container:<name>): its last hour of exits
# and restarts, releases, connections and probable cause; and its log on demand
curl -H "$H" $WATCHLOG/api/v1/clusters/$FLEET/servers/app-1/workloads/service:orders.service
curl -H "$H" "$WATCHLOG/api/v1/clusters/$FLEET/servers/app-1/workloads/process:api/logs?lines=200"

# The fleet's own process-group rules
curl -H "$H" $WATCHLOG/api/v1/clusters/$FLEET/process-rules

# The 0.8 Docker routes still answer, for containers:
# Hosts: Docker version, container counts, CPU, memory and disk
curl -H "$H" $WATCHLOG/api/v1/clusters/$FLEET/docker/hosts

# Containers on every host, or on one, with state, health, restarts and the OOM flag
curl -H "$H" $WATCHLOG/api/v1/clusters/$FLEET/docker/containers
curl -H "$H" "$WATCHLOG/api/v1/clusters/$FLEET/docker/containers?host=docker-01"

# Events (container starts, stops, OOM kills, health changes) on one host
curl -H "$H" "$WATCHLOG/api/v1/clusters/$FLEET/events?hosts=docker-01&limit=20"

# A container's last 200 lines, each marked stdout or stderr
curl -H "$H" "$WATCHLOG/api/v1/clusters/$FLEET/docker/hosts/docker-01/containers/storefront-api-1/logs?lines=200"

A container looks like this:

{
  "name": "storefront-api-1",
  "host": "docker-01",
  "image": "ghcr.io/example/storefront-api:1.4.2",
  "state": "running",
  "health": "healthy",
  "restartCount": 2,
  "oomKilled": false,
  "composeProject": "storefront",
  "composeService": "api",
  "problem": null
}

The Kubernetes routes (pods, workloads, nodes, namespaces) answer with empty lists for a Server fleet, and the Docker routes with empty lists for a Kubernetes cluster.

For both kinds

H="Authorization: Bearer $TOKEN"

# The overview: health, problems, top consumers, recent changes and events
curl -H "$H" $WATCHLOG/api/v1/clusters/$CLUSTER/overview
curl -H "$H" $WATCHLOG/api/v1/clusters/$FLEET/overview

# Right-sizing hints: requests and limits against 7 days of use (see right-sizing.md);
# filter with namespace and workload (Kubernetes) or host, container, project and service (Docker)
curl -H "$H" "$WATCHLOG/api/v1/clusters/$CLUSTER/right-sizing?namespace=shop"
curl -H "$H" "$WATCHLOG/api/v1/clusters/$FLEET/right-sizing?project=storefront&service=web"

# Find objects by name, as the dashboard's ⌘K search does: workloads, pods and nodes, or
# hosts, containers and Compose projects, and applications; letters in order, best first
curl -H "$H" "$WATCHLOG/api/v1/clusters/$CLUSTER/search?q=payments%20api"
curl -H "$H" "$WATCHLOG/api/v1/clusters/$FLEET/search?q=storefront&limit=10"

# The service map: who talks to whom, with failures and latency (eBPF)
curl -H "$H" "$WATCHLOG/api/v1/clusters/$CLUSTER/service-map?range=3600"
curl -H "$H" "$WATCHLOG/api/v1/clusters/$FLEET/service-map?range=3600"

# External destinations (Egress watch): one row per destination and port, with its sources,
# first and last seen, bytes, connections and failures over the range (24 hours by default,
# at most 30 days, at most 500 rows). Filter by namespace, kind and workload (Kubernetes) or
# host, project, service and container (Docker), by badge (new, raw_ip, failing, expected,
# not_expected) or text (q); firstSeenAfter keeps the sources that started since then
curl -H "$H" "$WATCHLOG/api/v1/egress?cluster=$CLUSTER&namespace=shop&workload=orders"
curl -H "$H" "$WATCHLOG/api/v1/egress?cluster=$FLEET&project=storefront&service=api&badge=new"
curl -H "$H" "$WATCHLOG/api/v1/egress?cluster=$CLUSTER&firstSeenAfter=1794150000"

# The destinations marked expected, and how many rows each covers. Marking and removing
# need a browser session (an Owner or Admin): tokens can't
curl -H "$H" "$WATCHLOG/api/v1/egress/expected?cluster=$CLUSTER"

# A suggested egress policy for one Kubernetes workload, as YAML text: a standard
# NetworkPolicy and a CiliumNetworkPolicy (toFQDNs), the flavour detected on the cluster
# first. WatchLog never applies it. A Server fleet answers 404: Docker has no egress policy object
curl -H "$H" "$WATCHLOG/api/v1/egress/policy?cluster=$CLUSTER&workload=shop/Deployment/orders"
curl -H "$H" "$WATCHLOG/api/v1/egress/policy?cluster=$CLUSTER&workload=shop/Deployment/orders&flavour=kubernetes"

# What changed (Pro, in WatchLog Cloud): what left its usual range for that hour of the
# week, on a Kubernetes cluster or a Server fleet. Around an alert (an hour before it started
# to 15 minutes after), or from/to (Unix seconds, at most 24 hours; the last hour by
# default); sort=first (the first to move, the default) or furthest. At most 50 rows with
# total and truncated, the learning state (for the first 7 days nothing is listed: `learning`
# says which day it is, when it is ready and which hours of the week are learned) and the
# probable cause's short form. Cloud Free
# answers 403 pro-feature; a self-hosted Community install answers 404. The anomaly alert's
# page and "Was this worth an alert?" need a browser session: tokens can't
curl -H "$H" "$WATCHLOG/api/v1/what-changed?cluster=$CLUSTER&alert=$ALERT"
curl -H "$H" "$WATCHLOG/api/v1/what-changed?cluster=$FLEET&from=1794150000&to=1794153600&sort=furthest"

# Event counts over time, and change markers (deploys, restarts) between two times
curl -H "$H" $WATCHLOG/api/v1/clusters/$CLUSTER/events/summary
curl -H "$H" "$WATCHLOG/api/v1/clusters/$FLEET/change-markers?from=1794150000&to=1794153600"

# Firing alerts on every cluster, one alert, and its chart
curl -H "$H" "$WATCHLOG/api/v1/alerts?view=firing"
curl -H "$H" $WATCHLOG/api/v1/alerts/$ALERT
curl -H "$H" $WATCHLOG/api/v1/alerts/$ALERT/chart

# Alert rules and silences
curl -H "$H" $WATCHLOG/api/v1/alert-rules
curl -H "$H" $WATCHLOG/api/v1/silences

# Monitored services (Redis, PostgreSQL, Nginx, RabbitMQ), problems first, on every
# cluster or one; the ones found but not monitored yet (and those you chose to ignore);
# the integrations collectors
curl -H "$H" $WATCHLOG/api/v1/applications
curl -H "$H" "$WATCHLOG/api/v1/applications?cluster=$FLEET"
curl -H "$H" $WATCHLOG/api/v1/applications/discovered
curl -H "$H" $WATCHLOG/api/v1/applications/collectors

# One service: its health, what WatchLog sees (reasons with a code and facts), and the
# workloads or containers that connect to it over the range (1h, 6h, 24h or 7d)
curl -H "$H" "$WATCHLOG/api/v1/applications/$SERVICE?range=21600"

The egress routes, the badges and the suggested policy are explained in Egress watch. The usual ranges, the learning period and the rows of /what-changed are explained in What changed.

Your metrics

The numbers your own apps report (Your metrics): what is used and the sources, each metric with its value now, one metric over a range (split by one label with by=), the dashboards, and the alert rules on them.

curl -H "$H" "$WATCHLOG/api/v1/clusters/$CLUSTER/own-metrics"
curl -H "$H" "$WATCHLOG/api/v1/clusters/$CLUSTER/own-metrics/metrics"
curl -H "$H" "$WATCHLOG/api/v1/clusters/$CLUSTER/own-metrics/metrics/$METRIC/series?from=1794150000&to=1794153600&by=method"
curl -H "$H" "$WATCHLOG/api/v1/own-dashboards"
curl -H "$H" "$WATCHLOG/api/v1/clusters/$CLUSTER/own-metrics/alerts"

Sending is not part of this API and doesn't use an API token: metrics and change events are sent with a write-only own-metrics token (wl_mt_…).

Metrics

POST /api/v1/query/range returns a metric's series between two times (Unix seconds). It takes the metric names from WatchLog's catalog, not free-form queries:

# CPU of the cart Deployment on a Kubernetes cluster, the last hour
curl -H "$H" -H "Content-Type: application/json" $WATCHLOG/api/v1/query/range -d '{
  "clusterId": "'$CLUSTER'",
  "metric": "workload.cpu.usage",
  "scope": { "namespace": "shop", "workloadKind": "Deployment", "workload": "cart" },
  "from": '$(($(date +%s) - 3600))', "to": '$(date +%s)'
}'

# Memory of one container on a Docker host
curl -H "$H" -H "Content-Type: application/json" $WATCHLOG/api/v1/query/range -d '{
  "clusterId": "'$FLEET'",
  "metric": "container.memory.working_set",
  "scope": { "host": "docker-01", "container": "storefront-api-1" },
  "from": '$(($(date +%s) - 3600))', "to": '$(date +%s)'
}'
{
  "metric": "container.memory.working_set",
  "unit": "bytes",
  "step": 60,
  "series": [{ "labels": { "container": "storefront-api-1" }, "points": [[1794150000, 182452224]] }]
}

The spec lists every metric name and scope field. A query covers at most 31 days; WatchLog picks the step (the seconds between points) for the range unless you send step.

What a token can't read

The API is for reading your clusters. A token can't:

  • change anything: create, edit or delete clusters, rules, silences, channels or settings;
  • read settings, alert channel targets, email or Telegram details, cluster tokens or other API tokens;
  • read the error text of a failed alert delivery, which can name your mail server or part of a webhook address.

WatchLog never collects Kubernetes Secrets, ConfigMap data or container environment variables, so no token can read them either.

Errors

Errors are RFC 9457 problems, sent as application/problem+json:

{
  "type": "urn:watchlog:problem:token-scope",
  "title": "Forbidden",
  "status": 403,
  "detail": "API tokens are read-only and cannot use this endpoint"
}
Status When
400 A parameter is invalid. Also urn:watchlog:problem:token-with-session when a request carries both a token and a browser session: send only the token.
401 The token is wrong, expired or revoked. WWW-Authenticate: Bearer error="invalid_token".
403 urn:watchlog:problem:token-scope: the route is not in the public API, or it changes something. WWW-Authenticate: Bearer error="insufficient_scope".
403 urn:watchlog:problem:pro-feature: What changed is part of Pro, and the organization is on Cloud Free.
404 No such cluster, pod, node, container or alert, or not one you can see.
429 More than 300 requests in a minute with this token. Retry-After says how many seconds to wait.

Limits

  • 300 requests a minute per token. Use one token per script, so a busy script doesn't slow down another.
  • Ranges: range, in seconds, goes from 5 minutes to 7 days, as in the dashboard. A metrics query covers at most 31 days.

Stability

The routes on this page and in the spec are the public API. They are stable:

  • Additions can come in any release: new routes, new optional parameters, new fields in responses, and new values in fields that name a status or a kind. Ignore fields you don't know, and handle values you don't recognise.
  • Breaking changes come only with a new version (/api/v2), or after the old behaviour has been marked deprecated for two minor versions. A breaking change is removing a route or a field, making a field optional or nullable, changing a type, or requiring a new parameter. Release notes say when something is deprecated.

Other routes under /api/v1 are the dashboard's own. They can change in any release, and tokens can't call them.

The spec

The API is described in OpenAPI 3.1 at /api/v1/openapi.json, on your own WatchLog. It lists only the public routes, and needs no token:

curl $WATCHLOG/api/v1/openapi.json -o watchlog-openapi.json

Load it into any OpenAPI tool to browse the routes or generate a client.