Logs are useful resources for assessing your models’ performance, identifying problems, and tuning results.

Logs can only be retrieved for custom private models that you have deployed. Public model logs are not available to users.

Getting logs using the API

A GetLog method request must include an HTTP header with Content-Type set to application/json to indicate that the body of the request contains JSON data.

The request body requires the following fields:

  • An auth object with the following fields:
    • organization set to your Tune Studio organization ID.
    • cluster containing the cluster ID.
  • resourceId containing the resource ID.
  • type specifying the type of log to get. Options are LOG_TYPE_UNSPECIFIED, LOG_TYPE_MODEL, or LOG_TYPE_JOB.
  • startTime specifying the starting date and time for the period for which log entries must be retrieved.
  • endTime specifying the ending date and time for the period for which log entries must be retrieved.
  • level setting the severity level of the log entries to be retrieved. Options are info, error, debug, or warn.
  • A parent page object containing pagination details.
    • limit specifying the number of rows to return.
    • prevPageToken containing the previous page token (empty allowed).
    • nextPageToken containing the next page token (empty allowed).
    • totalPage specifying the total number of pages to return.

Here’s an example GetLog method using the curl CLI:

 curl --request POST \
   --url https://studio.tune.app/tune.Studio/GetLog \
   --header 'Content-Type: application/json' \
   --header 'X-Tune-Key: <YOUR-API-KEY>' \
   --data '{
   "auth": {
     "organization": "<YOUR-ORG-ID>",
     "cluster": ""
   },
   "resourceId": "<YOUR-MODEL-ID>",
   "type": "LOG_TYPE_MODEL",
   "startTime": "2023-11-07T05:31:56Z",
   "endTime": "2026-11-07T05:31:56Z",
   "level": "debug",
   "page": {
     "limit": 2,
     "prevPageToken": "",
     "nextPageToken": "",
     "totalPage": 1
   }
 }'

The example above returns the following logs:

[
  {
    "log": [
      {
        "message": "INFO:     10.48.2.1:52700 - \"GET /v1/models HTTP/1.1\" 200 OK",
        "timestamp": "2024-05-28T11:47:15.330495Z",
        "level": "INFO",
        "extraFields": {}
      },
      {
        "message": "failed to put tracker log",
        "timestamp": "2024-05-28T11:47:14.364108Z",
        "level": "ERROR",
        "extraFields": {
          "cmd": "lmao-sidecar",
          "error": "rpc error: code = Unavailable desc = unexpected HTTP status code received from server: 502 (Bad Gateway); transport: received unexpected content-type \"text/html; charset=UTF-8\"",
          "timestamp": "2024-05-28T11:47:14.363973336Z"
        }
      }
    ],
    "page": {
      "prevPageToken": "MjAyNC0wNS0yOFQxMTo0NzoxNC4zNjQxMDhafG8wdmZqYXo2",
      "nextPageToken": "MjAyNC0wNS0yOFQxMTo0NzoxNS4zMzA0OTVafG8wdmZqYXo2",
      "totalPage": 2916995
    }
  }
]

Getting logs using Python

To create a log request using Python, create a new file called get_logs.py and open it for editing.

Paste the following code into the file, replacing <YOUR-API-KEY>, <YOUR-ORG-ID>, and <YOUR-MODEL-ID> with your values:

 import json
 import requests


def get_logs():
   try:
       headers = {
           "Content-Type": "application/json",
           "X-Tune-Key": "<YOUR-API-KEY>"
       }

       data = {
         "auth": {
           "organization": "<YOUR-ORG-ID>",
           "cluster": ""
         },
         "resourceId": "<YOUR-MODEL-ID>",
         "type": "LOG_TYPE_MODEL",
         "startTime": "2023-11-07T05:31:56Z",
         "endTime": "2026-11-07T05:31:56Z",
         "level": "debug",
         "page": {
           "limit": 123,
           "prevPageToken": "",
           "nextPageToken": "",
           "totalPage": 123
         }
       }

       url = "https://studio.tune.app/tune.Studio/GetLog"
       response = requests.post(url, headers=headers, json=data)
       print(json.dumps(response.json(), sort_keys=True, indent=4))
   except IOError:
       print("Error in list_models: I/O error with API occurred")


if __name__ == '__main__':
   print("Getting logs from the API")
   get_logs()

Run the program with the following command:

python get_logs.py

You should see logs retrieved similar to the following:

[
  {
    "log": [
      {
        "message": "INFO:     10.48.2.1:52700 - \"GET /v1/models HTTP/1.1\" 200 OK",
        "timestamp": "2024-05-28T11:47:15.330495Z",
        "level": "INFO",
        "extraFields": {}
      },
      {
        "message": "failed to put tracker log",
        "timestamp": "2024-05-28T11:47:14.364108Z",
        "level": "ERROR",
        "extraFields": {
          "cmd": "lmao-sidecar",
          "error": "rpc error: code = Unavailable desc = unexpected HTTP status code received from server: 502 (Bad Gateway); transport: received unexpected content-type \"text/html; charset=UTF-8\"",
          "timestamp": "2024-05-28T11:47:14.363973336Z"
        }
      }
    ],
    "page": {
      "prevPageToken": "MjAyNC0wNS0yOFQxMTo0NzoxNC4zNjQxMDhafG8wdmZqYXo2",
      "nextPageToken": "MjAyNC0wNS0yOFQxMTo0NzoxNS4zMzA0OTVafG8wdmZqYXo2",
      "totalPage": 2916995
    }
  }
]