Coder powers secure, scalable development across key industries — automotive, finance, government, and technology — enabling faster builds, tighter compliance, and seamless AI adoption in enterprise-grade cloud environments.
We strive to keep the following use cases up to date, but please note that
changes to API queries and routes can occur. For the most recent queries and
payloads, we recommend checking the relevant documentation.
Workspace agents have a special token that can send logs, metrics, and workspace
activity.
Custom workspace logs:
Expose messages prior to the Coder init script running (e.g. pulling image, VM
starting, restoring snapshot).
coder-logstream-kube uses
this to show Kubernetes events, such as image pulls or ResourceQuota
restrictions.
Manually send workspace activity:
Keep a workspace "active," even if there is not an open connection (e.g. for a
long-running machine learning job).
#!/bin/bash
# Send workspace activity as long as the job is still running
while true
do
if pgrep -f "my_training_script.py" > /dev/null
then
curl -X PUT "https://coder.example.com/api/v2/workspaces/$WORKSPACE_ID/extend" \
-H "Coder-Session-Token: $CODER_AGENT_TOKEN" \
-d '{
"deadline": "2019-08-24T14:15:22Z"
}'
# Sleep for 30 minutes (1800 seconds) if the job is running
sleep 1800
else
# Sleep for 1 minute (60 seconds) if the job is not running
sleep 60
fi
done