Skip to content

Logs

A deployment's Logs tab receives logs from models and agentic workflows in the OpenTelemetry (OTel) standard format, centralizing the relevant logging information for deeper analysis, troubleshooting, and understanding of application performance and errors.

The collected logs provide time-period filtering capabilities and the OTel logs API is available to programmatically export logs with similar filtering capabilities. Because the logs are OTel-compliant, they're standardized for export to third-party observability tools like Datadog.

Access and retention

Logs are available for all deployment and target types. Only users with "Owner" and "User" roles on a deployment can view these logs. Logs are stored for a retention period of 30 days, after which they are automatically deleted.

To access the logs for a deployment, on the Deployments tab, locate and click the deployment, click the Activity log tab, and then click Logs.

The logging levels available are INFO, DEBUG, WARN, and ERROR. To filter the logs, use the Range UTC dropdown to select Last 15 min, Last hour, Last day, or Custom range.

Export OTel logs

The code example below uses the OTel logs API to get the OpenTelemetry-compatible logs for a deployment, print a preview and the number of ERROR logs, and then write logs to an output file. Before running the code, configure the entity_id variable with your deployment ID, replacing <DEPLOYMENT_ID> with the deployment ID from the deployment Overview tab or URL. In addition, you can modify the export_logs_to_json function to match your target observability service's expected format.

Export OTel logs to JSON
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import json
import requests
from typing import Dict, List, Any
import datarobot as dr

# Initialize DataRobot client for authentication
dr_client = dr.Client()

# Get authentication details from the DataRobot client
api_token: str = dr_client.token
base_url: str = dr_client.endpoint

# Provide DataRobot entity information
entity_type: str = "deployment"
entity_id: str = "<DEPLOYMENT_ID>" # From the deployment Overview tab or URL

# Set output filename
output_filename: str = "datarobot_otel_logs.json"

def get_otel_logs(entity_type: str, entity_id: str, **params: Any) -> Dict[str, Any]:
    """Get OTel logs from the DataRobot API"""
    url: str = f"{base_url}/otel/{entity_type}/{entity_id}/logs/"
    headers: Dict[str, str] = {
        "Authorization": f"Bearer {api_token}",
        "Content-Type": "application/json"
    }
    response = requests.get(url, headers=headers, params=params)
    response.raise_for_status()
    return response.json()

def export_logs_to_json(logs: List[Dict[str, Any]], entity_type: str, entity_id: str, filename: str) -> None:
    """Export logs to a JSON file"""
    log_entries = []
    for log in logs:
        log_payload = {
            "timestamp": log.get('timestamp', ''),
            "level": log.get('level', ''),
            "message": log.get('message', ''),
            "entity_type": entity_type,
            "entity_id": entity_id,
            "stacktrace": log.get('stacktrace', '')
        }
        log_entries.append(log_payload)

    with open(filename, 'w') as f:
        json.dump(log_entries, f, indent=2)

# Get and export OTel logs
try:
    print(f"Getting logs for {entity_type} {entity_id}...")
    logs_data: Dict[str, Any] = get_otel_logs(entity_type, entity_id)
    logs: List[Dict[str, Any]] = logs_data.get('data', [])
    print(f"Found {len(logs)} logs")

    # Preview first few logs
    for log in logs[:5]:
        timestamp = log.get('timestamp', 'N/A')
        level = log.get('level', 'N/A')
        message = log.get('message', 'N/A')
        print(f"{timestamp} - {level:8} - {message}")

    # Example: Filter for ERROR logs only
    error_logs = [log for log in logs if log.get('level', '').upper() == 'ERROR']
    print(f"Found {len(error_logs)} ERROR logs")

    # Export to JSON file
    print(f"Writing logs to {output_filename}...")
    export_logs_to_json(logs, entity_type, entity_id, output_filename)
    print(f"Exported {len(logs)} logs to {output_filename}")

except requests.exceptions.RequestException as e:
    print(f"API Error: {e}")
except FileNotFoundError as e:
    print(f"File Error: {e}")
except json.JSONEncodeError as e:
    print(f"JSON Error: {e}")
except Exception as e:
    print(f"Unexpected Error: {e}")