Collect the logs of a host

You need a host installed as a service (see Install a host) and a log agent on the same machine that reads the systemd journal and Docker logs. Any agent that reads both works. The example uses Grafana Alloy and Loki.

Find the logs

SourceWhere
The host on LinuxThe systemd service spotlight-host, a user unit when the host runs as a user.
The host on macOS~/Library/Logs/spotlight-host.log.
A sandboxThe Docker container spotlight-<runner id>.
Its egressThe Docker container spotlight-egress-<runner id>.
A probe of an imageThe Docker container spotlight-egress-probe-<id>, with the host label only.

Each line is one JSON object. The containers carry the labels ai.usespotlight.host and ai.usespotlight.runner.

To read the host's log on the machine itself, run spotlight host logs. Add -f to follow it, or -n <lines> to show more than the last 100 lines.

Send them to Loki

  1. On Linux, read the journal of the host's service:

    loki.relabel "spotlight_host" {
      forward_to = []
    
      rule {
        source_labels = ["__journal__systemd_unit", "__journal__systemd_user_unit"]
        regex         = ".*spotlight-host\\.service.*"
        action        = "keep"
      }
    }
    
    loki.source.journal "spotlight_host" {
      forward_to    = [loki.write.default.receiver]
      relabel_rules = loki.relabel.spotlight_host.rules
      labels        = { service = "spotlight-host" }
    }
  2. On macOS, read the host's log file instead:

    local.file_match "spotlight_host" {
      path_targets = [{ __path__ = "/Users/*/Library/Logs/spotlight-host.log", service = "spotlight-host" }]
    }
    
    loki.source.file "spotlight_host" {
      targets    = local.file_match.spotlight_host.targets
      forward_to = [loki.write.default.receiver]
    }
  3. Read the sandbox and egress containers, with the host and runner as labels:

    discovery.docker "spotlight" {
      host             = "unix:///var/run/docker.sock"
      refresh_interval = "5s"
    
      filter {
        name   = "label"
        values = ["ai.usespotlight.host"]
      }
    }
    
    discovery.relabel "spotlight" {
      targets = discovery.docker.spotlight.targets
    
      rule {
        source_labels = ["__meta_docker_container_label_ai_usespotlight_host"]
        target_label  = "host"
      }
    
      rule {
        source_labels = ["__meta_docker_container_label_ai_usespotlight_runner"]
        target_label  = "runner"
      }
    }
    
    loki.source.docker "spotlight" {
      host       = "unix:///var/run/docker.sock"
      targets    = discovery.relabel.spotlight.output
      forward_to = [loki.write.default.receiver]
    }
  4. Point loki.write "default" at your Loki.

The host removes a sandbox and its egress when Spotlight drains the sandbox, and Docker removes their logs with them. A short refresh_interval finds a container before that happens. Lines that a container writes after the agent last read it are lost.

If the host runs with DOCKER_HOST or Podman, use that socket in place of /var/run/docker.sock.

Find a run

Search by the fields of the lines, not by labels:

FieldHolds
trace_idThe trace of the claim. The host and the runner write it on every line of the run. Spotlight writes the same id as reqId.
runThe run id, on the host's lines.
runnerThe runner id, on the host's lines.

For example, in Loki: {service="spotlight-host"} | json | run="<run id>".

What each process writes is in Observability.

On this page