how can i see historic logs of agents?
# ask-ai
a
how can i see historic logs of agents?
t
Thanks for reaching out, Sebastián. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You want to see historic agent logs — here’s how you can depending on the log type. Runtime logs • LiveKit Cloud does not retain full historical runtime logs. You can stream recent logs from the newest instance with the CLI:
Copy code
lk agent logs
• For historic/long-term runtime logs, forward logs to an external provider (Datadog, CloudWatch, Sentry, or New Relic) by adding the appropriate secret (e.g.,
DATADOG_TOKEN
, `AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY`,
SENTRY_DSN
,
NEW_RELIC_LICENSE_KEY
). Once configured, view historic runtime logs in that provider. Build logs • View build logs for deployed versions via the CLI:
Copy code
lk agent logs --log-type=build
• You can also view build logs for multiple versions from the LiveKit Cloud dashboard. Session (Agent Observability) logs • Enable Agent Observability in Project → Data and privacy. • Open the Sessions dashboard → Agent insights to see session-level logs, transcripts, traces, and synchronized logs. • You can download a session’s data (ZIP with logs, audio, transcripts, traces). • Observability data is retained for 30 days. If you tell me which log type you need (runtime, build, or session) and whether you already have an external log provider configured, I’ll give exact next steps for your setup. Sources: Log collection | LiveKit Docs | Agent insights in LiveKit Cloud | LiveKit docs
a
which log providers are available?
t
Regarding which log providers you can forward agent runtime logs to: Datadog, AWS CloudWatch, Sentry, and New Relic. If you’d like, tell me which one you use and I’ll give the exact secrets/config keys to add and the next steps to enable forwarding.
a
grafana you don't have?
t
Grafana is not a native export target for LiveKit agent runtime logs. Supported providers you can forward runtime logs to are Datadog, AWS CloudWatch, Sentry, and New Relic. If you want to view logs in Grafana, a common approach is: • Forward LiveKit logs to a supported provider that Grafana can read (for example, send logs to CloudWatch or New Relic), or • Send logs to a log store Grafana queries (like Loki) by routing from one of the supported providers or using your own log-forwarder. Tell me which Grafana data source you plan to use (Loki, CloudWatch, New Relic, etc.), and I’ll outline the exact secrets/keys and steps to wire LiveKit logs into that flow.
a
Loki
t
Loki is not a native export target for LiveKit agent runtime logs. Supported runtime log destinations are Datadog, AWS CloudWatch, Sentry, and New Relic. To get LiveKit logs into Loki (so Grafana can query them), you have two common options: • Forward LiveKit logs to CloudWatch or New Relic, then configure Grafana to read that data source (Grafana supports CloudWatch/New Relic). • Send logs into Loki by adding a forwarding step: route logs from a supported provider or from your agent instances to a log-forwarder (Fluentd/Fluent Bit/Promtail) that writes to Loki. Tell me which approach you prefer and which infrastructure you control (CloudWatch/New Relic already set up, or do you run Fluent Bit/Promtail), and I’ll give the exact secrets/keys and step-by-step configuration to wire logs into Loki.
a
Promtail how it works?
t
You’re asking how Promtail works to get LiveKit agent logs into Loki. Below is a concise explanation and the typical steps to set it up; tell me which OS/container and where your agents run (VMs, Kubernetes, or LiveKit Cloud) so I can give exact config snippets. How Promtail works (high level) • Promtail tails (scrapes) log files or reads journald/syslog, adds labels, and pushes log entries to Loki over HTTP. • Promtail applies scrape configs that match file paths or targets, parses log lines (optional), and attaches labels used by Loki/Grafana for queries. • Promtail can run as an agent on each host, as a sidecar, or as a DaemonSet in Kubernetes to collect logs from many instances. Typical setup to get LiveKit logs into Loki 1. Ensure LiveKit runtime logs are written to files or stdout on your hosts or containers. 2. Install Promtail on hosts or deploy as a DaemonSet/sidecar in Kubernetes. 3. Create a Promtail config that: ◦ Defines
clients
with your Loki HTTP endpoint. ◦ Adds
scrape_configs
pointing at the LiveKit log file paths or container journald. ◦ Sets labels (e.g.,
job=livekit
,
project=<your-project>
,
agent=<agent-name>
). ◦ Optionally defines
pipeline_stages
to parse JSON logs or extract fields. 1. Start Promtail; it will push logs to Loki where Grafana can query them. Example Promtail config sections (conceptual) • clients: ◦ url: http//&lt;loki host&gt;3100/loki/api/v1/push • scrape_configs: ◦ job_name: livekit static_configs: • targets: ['localhost'] labels: job: livekit path: /var/log/livekit/*.log • pipeline_stages (optional): ◦ json: expressions: level: level msg: message Notes specific to LiveKit • LiveKit Cloud does not natively export to Loki; you must run Promtail yourself or route logs from a supported provider (CloudWatch/New Relic) into Loki. • If your agents run in LiveKit Cloud where you cannot install Promtail, forward logs to CloudWatch or New Relic and then pull or forward them into Loki. Tell me: • Where your agents run (Kubernetes, VMs, or LiveKit Cloud) • Whether LiveKit logs are files or stdout/journald I’ll provide a ready-to-use Promtail config and exact deployment steps for your environment.
a
and if i manually run a sidejob that picks logs and push them via HTTP?
t
You're asking whether a custom side job can collect LiveKit agent logs and push them to Loki via HTTP — yes, that works. Below are concise steps, formatting requirements, and important considerations. Tell me where your agents run (Kubernetes, VMs, or LiveKit Cloud) and whether logs are written to files or stdout, and I’ll give an exact script/config. How to do it (high level) 1. Obtain logs ◦ If logs are on the host/container filesystem or journald, read those files/journal. ◦ Alternatively, stream live logs with
lk agent logs
(note: this only shows the newest agent server instance). 1. Normalize and batch ◦ Parse each log line and attach metadata labels (e.g.,
job=livekit-agent
,
project
,
agent
,
room
). ◦ Buffer and batch entries to avoid per-line HTTP calls. 1. Format for Loki push API ◦ Send JSON with `streams`: each stream has
stream
(labels) and
values
(array of [timestamp_ns, line]). ◦ Timestamps must be nanoseconds since epoch and properly escaped strings. ◦ Example payload:
Copy code
{
  "streams": [
    {
      "stream": {
        "job": "livekit-agent",
        "agent": "my-agent"
      },
      "values": [
        [
          "1717765955000000000",
          "level=info msg='Agent started' room=my-room"
        ]
      ]
    }
  ]
}
1. Push over HTTP ◦ POST to Loki endpoint:
http://<loki-host>:3100/loki/api/v1/push
◦ Handle retries, backoff, and HTTP errors. 1. Operational concerns ◦ Run the side job per host/instance (or as a DaemonSet/sidecar) to capture all instances;
lk agent logs
alone won’t cover past instances at scale. ◦ Implement batching, rate limiting, and retry/backpressure to avoid overloading Loki. ◦ Preserve timestamps from logs where possible; otherwise use ingestion time. ◦ Ensure proper label selection to enable efficient queries in Grafana (avoid high-cardinality labels like unique request IDs). ◦ Secure traffic (TLS) and authentication if your Loki endpoint requires it. 1. Log level & completeness ◦ Adjust agent log level with the agent option
--log-level
to include needed detail. ◦ If agents run in LiveKit Cloud where you cannot install collectors, forward logs to a supported provider (CloudWatch/New Relic) and then route into Loki. If you tell me: • Where agents run (Kubernetes, VMs, LiveKit Cloud) • Whether logs are files or stdout/journald • Your Loki endpoint and auth method (basic token/TLS) I’ll provide a ready-to-run example script or Promtail-equivalent config tailored to your environment. Sources: Log collection | LiveKit Docs | Agent server options | LiveKit docs
a
agent run on LiveKit Cloud
t
You’re running agents on LiveKit Cloud — you cannot run custom sidejobs on LiveKit Cloud hosts. Here are the practical options to get historic logs and how to get them into Loki: What you can do now • Live stream recent logs from the newest agent instance:
Copy code
lk agent logs
(This is not historic for all instances.) • Use Agent Observability for session-level logs, transcripts, traces: ◦ Enable Agent Observability in Project → Data and privacy. ◦ View/download session data from Sessions → Agent insights (retained 30 days). • Forward runtime logs to a supported external provider (required for historic logs): ◦ Supported targets: Datadog, AWS CloudWatch, Sentry, New Relic. ◦ Configure the appropriate secret (e.g.,
DATADOG_TOKEN
, `AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY`,
SENTRY_DSN
,
NEW_RELIC_LICENSE_KEY
) so LiveKit forwards logs automatically. How to get logs into Loki from LiveKit Cloud • Option A — Provider → Loki: Forward LiveKit logs to CloudWatch or New Relic, then configure a forwarder that sends data from that provider into Loki (Grafana supports CloudWatch/New Relic). • Option B — Provider export → Promtail: Export logs from your chosen provider and push into Loki with Promtail/your own forwarder. • Option C — Pull session data: For session-specific traces/transcripts, download session ZIPs from Agent insights and ingest those into your systems (manual). Next step Tell me which external provider you already have (Datadog, CloudWatch, New Relic, Sentry) or whether you want step-by-step for: • Configuring LiveKit to forward to CloudWatch or New Relic (then into Loki), or • Exporting Session data from Agent Observability and ingesting into Loki I’ll provide the exact secrets/keys and step-by-step configuration for that path.