Skip to main content

Getting Application Logs

When debugging applications, you can retrieve logs using the Logs API. Logs include output from your functions such as print() statements, errors, and any other stdout/stderr output.

Get Logs via API

curl -X GET \
  "https://api.tensorlake.ai/applications/{application}/logs" \
  -H "Authorization: Bearer $TENSORLAKE_API_KEY"
Response:
{
  "logs": [
    {
      "timestamp": 1717171717171717171,
      "uuid": "550e8400-e29b-41d4-a716-446655440000",
      "namespace": "my-namespace",
      "application": "my-application",
      "body": "Processing started for item 1",
      "level": 3,
      "logAttributes": "{\"level\": \"info\"}"
    }
  ],
  "nextToken": "1717171717171717172.550e8400-e29b-41d4-a716-446655440000"
}

Filtering Logs

You can filter logs using query parameters to narrow down results: Filter by Request ID
curl -X GET \
  "https://api.tensorlake.ai/applications/{application}/logs?requestId={request_id}" \
  -H "Authorization: Bearer $TENSORLAKE_API_KEY"
Filter by Function Name
curl -X GET \
  "https://api.tensorlake.ai/applications/{application}/logs?function={function_name}" \
  -H "Authorization: Bearer $TENSORLAKE_API_KEY"
Filter system events out By default, we add system and application events to the logs, so you can keep track of the lifecycle of your requests. Use events if you want to filter out system events:
curl -X GET \
  "https://api.tensorlake.ai/applications/{application}/logs?events=3" \
  -H "Authorization: Bearer $TENSORLAKE_API_KEY"
Filter by log levels Log levels are identified by numbers from Trace(1) to Error(5). By default, we show logs for all levels. These are all the possible values for the different levels:
  1. Trace
  2. Debug
  3. Info
  4. Warning
  5. Error
If you want to learn how to set these log levels, check out our Logging reference.
curl -X GET \
  "https://api.tensorlake.ai/applications/{application}/logs?level={level}" \
  -H "Authorization: Bearer $TENSORLAKE_API_KEY"
Combine Filters Use the gate parameter to combine multiple filters with AND (default) or OR logic:
# Get logs matching BOTH request ID AND function name
curl -X GET \
  "https://api.tensorlake.ai/applications/{application}/logs?requestId={request_id}&function={function_name}&gate=and" \
  -H "Authorization: Bearer $TENSORLAKE_API_KEY"

# Get logs matching EITHER request ID OR function name
curl -X GET \
  "https://api.tensorlake.ai/applications/{application}/logs?requestId={request_id}&function={function_name}&gate=or" \
  -H "Authorization: Bearer $TENSORLAKE_API_KEY"

Pagination and Ordering

Get Most Recent Logs (Default) By default, logs are returned in descending order (newest first). Use tail to specify the number of logs:
curl -X GET \
  "https://api.tensorlake.ai/applications/{application}/logs?tail=50" \
  -H "Authorization: Bearer $TENSORLAKE_API_KEY"
Get Oldest Logs First Use head to get logs in ascending order (oldest first):
curl -X GET \
  "https://api.tensorlake.ai/applications/{application}/logs?head=50" \
  -H "Authorization: Bearer $TENSORLAKE_API_KEY"
Paginate Through Logs Use the nextToken from the response to fetch the next page:
curl -X GET \
  "https://api.tensorlake.ai/applications/{application}/logs?nextToken={next_token}" \
  -H "Authorization: Bearer $TENSORLAKE_API_KEY"

Query Parameters Reference

ParameterTypeDescription
requestIdStringFilter logs for specific request IDs
functionStringFilter logs for specific function names
functionExecutorStringFilter logs for specific function executor containers
functionRunIdStringFilter logs for specific function runs
allocationIdStringFilter logs for specific allocations
levelIntegerFilter logs for specific log levels
eventsIntegerFilter system and application events
gateand | orLogic for combining multiple filters (default: and)
headIntegerNumber of logs to return in ascending order (default: 100)
tailIntegerNumber of logs to return in descending order (default: 100)
nextTokenStringPagination token from previous response
The parameter that filter logs (requestId, function, functionExecutor, functionRunId, allocationId, and level) can be repeated one or multiple times. If you add more than one parameter with the same name, Tensorlake will search for both parameters using the gate parameter as connector. For example, filtering DEBUG and INFO logs:
curl -X GET \
  "https://api.tensorlake.ai/applications/{application}/logs?level=2&level=3" \
  -H "Authorization: Bearer $TENSORLAKE_API_KEY"

Common Issues

Function Timeout

If your function is timing out, consider:
  1. Increase the timeout - Set a higher timeout value in your @function decorator
  2. Report progress - Use ctx.progress.update() to reset the timeout. See Streaming Progress Updates
  3. Check the logs - Use the Logs API above to see what your function was doing before it timed out

Request Failed

To investigate a failed request:
  1. Check request state - Get the full request state including failure reason:
curl -X GET \
  "https://api.tensorlake.ai/applications/{application}/requests/{request_id}" \
  -H "Authorization: Bearer $TENSORLAKE_API_KEY"
  1. Review logs - Filter logs by the request ID to see what happened:
curl -X GET \
  "https://api.tensorlake.ai/applications/{application}/logs?requestId={request_id}" \
  -H "Authorization: Bearer $TENSORLAKE_API_KEY"

Out of Memory

If your function is running out of memory:
  1. Check current allocation - Review the memory setting in your @function decorator
  2. Increase memory - Set memory to a higher value (up to 32 GB). See Memory
  3. Process in batches - Break large datasets into smaller chunks

Debugging Tips

  • Add print() statements in your code to log intermediate values
  • Use ctx.request_id to correlate logs across function calls. See Request ID
  • Check that your function has sufficient CPU, memory, and disk resources
  • Review retry settings if functions are failing intermittently. See Retries