Read logs and invocations
Find what a function did on a previous run, and read the output it produced.
Prerequisites#
- An organization owner or admin account, or another cloud user with access to the site. Site users can only look up a run's result by task id.
- The app and function slugs, or an invocation or task id.
Write output you can read back#
Output sent through the logging module or the injected log helper is stored
in the run record's logs. Output from print and standard error appears as
stdout and stderr in the task result of a successful run, not in logs.
The log helper writes structured entries:
def main(params, user_data, sdk_client):
log("Syncing invoice", level="info", data={"invoice_id": params.get("invoice_id")})
if not params.get("invoice_id"):
log("Missing invoice_id", level="error")
return {"ok": False}
return {"ok": True}
Entries logged at ERROR or CRITICAL set has_error on the record, which is
what makes a failed run findable later. Log deliberately rather than verbosely: a
function that logs every iteration of a large loop will lose the entries that
mattered.
List runs for one function#
Start here when you know which function you are investigating.
- REST API
- TaruviBase Console
/api/apps/$TARUVI_APP_SLUG/functions/$FUNCTION_SLUG/executions/Headers
AuthorizationApi-Key $TARUVI_API_KEY
View cURL
curl "$TARUVI_SITE_URL/api/apps/$TARUVI_APP_SLUG/functions/$FUNCTION_SLUG/executions/" \
-H "Authorization: Api-Key $TARUVI_API_KEY"
200Returns invocation records for this function. Log output is omitted from the list.
- Open the app and select Functions.
- Open the function and select the Execution History tab.
The list shows each run but not its log entries. Open one run to read them.
Read one run in full#
Read the invocation by its ID to inspect its captured logs.
- Python SDK
- REST API
client.functions.get_invocation("INVOCATION_ID")
This uses /api/invocations/INVOCATION_ID/, the site-wide detail route. Pass
an invocation ID, not a Celery task ID. It can read a run even when its
function is inactive, and requires organization access to the site.
Reading a single invocation through the function-scoped endpoint returns its captured logs and the code that actually ran, which is the fastest way to match a result to the code that produced it.
The endpoint is
/api/apps/{app_slug}/functions/{slug}/executions/{execution_id}/. It finds
only active functions; for an inactive one, use
/api/invocations/?function_slug=FUNCTION_SLUG.
Find a run when you only have a task id#
An asynchronous execution returns a celery_task_id. Two endpoints accept it:
| Endpoint | Returns |
|---|---|
/api/result/{task_id}/ | The task outcome alone |
/api/invocations/by-task-id/{task_id}/ | The invocation record together with its result |
For the request itself, see Execute a function.
Search across the site#
The site-wide invocation list answers questions that span apps, such as which functions failed this morning.
- Python SDK
- REST API
client.functions.list_invocations(function_slug="FUNCTION_SLUG")
/api/invocations/ pages with page and page_size, 20 by default. The
SDK's limit, offset, and status arguments aren't applied; filter with
function_slug, or call REST with ?page_size=50&has_error=true.
Request /api/invocations/. Narrow the result with function_slug,
trigger_type, user_id, or has_error.
has_error is the most useful of those. It is set when a run logged anything at
ERROR or CRITICAL, so it finds runs that reported a problem even when they
returned successfully.
These endpoints are scoped to the site, not to an app. They return runs for every app in the site, including their parameters, return values, and log output, to any organization user with access to the site. Don't pass or log secrets or personal data.
Understand what a record contains#
| Field | Contents |
|---|---|
celery_task_id | The handle for result lookups |
trigger_type | api, schedule, or event |
history_id | Which version of the code ran |
logs | Structured log entries, omitted from list responses |
log_count, has_error | Counters for filtering without reading the log |
task_result | Status, return value, and traceback |
Log entries are ordered by timestamp.
The credentials a function runs with are excluded from these responses.
Know the log limits#
A single execution captures at most 2,000 entries, 1 MiB in total, with individual messages truncated at 10,000 characters. Entries past the limits are dropped, sometimes without a truncation entry, so a log can be incomplete even when it doesn't end in one.
Verify#
Execute a function, then find its run and confirm the log output matches what the code produced. If a run you expected is missing, it never started — for event-triggered functions the usual cause is filter conditions that did not match.