Skip to main content

Retrieve Request Log

Retrieves detailed information about a specific request log by its ID, including full request/response data and exception details.

HTTP Request

GET/api/metrics/request_logs/:id

Authorization

Authorization

  • Required: Yes
  • Permission: Staff with RequestLogPermission or Admin
  • Permission Code: 3601
  • Authentication: Token authentication

Path Parameters

ParameterTypeRequiredDescription
idIntegerYesUnique ID of the request log

Example Requests

1import requests
2
3# Get detailed request log information
4response = requests.get('http://www.example.com/api/metrics/request_logs/12345', headers={
5  'Authorization': 'Token <your_api_key>'
6})
7print(response.json())
8
9# Example response handling
10if response.status_code == 200:
11  log_data = response.json()
12  print(f"Request to {log_data['endpoint']} took {log_data['duration']} seconds")
13  if log_data['exception_type']:
14      print(f"Exception occurred: {log_data['exception_type']}")

Response Fields

FieldTypeDescription
idIntegerUnique ID of the request log
userObjectUser information (id, username, full_name) or null for anonymous
ipStringIP address of the request
deviceStringDevice name/model
device_typeStringType of device (pc, mobile, tablet)
is_botBooleanWhether the request was made by a bot
osStringOperating system information
browserStringBrowser information
schemeStringRequest scheme (http, https)
endpointStringAPI endpoint that was called
methodStringHTTP method used
status_codeIntegerHTTP response status code
exception_typeStringType of exception (if any occurred)
started_atString (ISO 8601)Timestamp when request started
finished_atString (ISO 8601)Timestamp when request finished
durationDecimalRequest duration in seconds
created_atString (ISO 8601)Timestamp when log entry was created
updated_atString (ISO 8601)Timestamp when log entry was last updated
query_paramsObjectJSON object containing request query parameters
bodyObjectJSON object containing request body data
responseObjectJSON object containing response data
request_headersObjectJSON object containing request headers
response_headersObjectJSON object containing response headers
exception_messageStringDetailed exception message (if exception occurred)
exception_tracebackStringFull exception traceback (if exception occurred)

Example Response

{
"id": 1,
"user": null,
"ip": "127.0.0.1",
"device": "Other",
"device_type": "pc",
"is_bot": false,
"os": "Windows",
"browser": "Firefox",
"scheme": "http",
"endpoint": "/superadmin/",
"method": "GET",
"status_code": 302,
"exception_type": null,
"started_at": "2025-11-19T14:55:32.673075Z",
"finished_at": "2025-11-19T14:55:32.789033Z",
"duration": 0.115958,
"created_at": "2025-11-19T14:55:32.789379Z",
"updated_at": "2025-11-19T14:55:32.789382Z",
"query_params": {},
"body": null,
"response": null,
"request_headers": {
"Host": "127.0.0.1:8000",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Cookie": "csrftoken=EqfXUxesM4u9XZc0UiptOMBL1mTRb8DA; sessionid=yf1pql5k3vvl6udi00fz1y5hzdriaur9",
"Priority": "u=0, i",
"Connection": "keep-alive",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:145.0) Gecko/20100101 Firefox/145.0",
"Content-Type": "text/plain",
"Content-Length": "",
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "none",
"Sec-Fetch-User": "?1",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Accept-Language": "en-US,en;q=0.5",
"Upgrade-Insecure-Requests": "1"
},
"response_headers": {
"Vary": "Accept-Language, Cookie",
"Expires": "Wed, 19 Nov 2025 14:55:32 GMT",
"Location": "/superadmin/login/?next=/superadmin/",
"Content-Type": "text/html; charset=utf-8",
"Cache-Control": "max-age=0, no-cache, no-store, must-revalidate, private",
"Server-Timing": "TimerPanel_utime;dur=62.012000000000064;desc=\"User CPU time\", TimerPanel_stime;dur=29.42600000000001;desc=\"System CPU time\", TimerPanel_total;dur=91.43800000000007;desc=\"Total CPU time\", TimerPanel_total_time;dur=105.6888599996455;desc=\"Elapsed time\", SQLPanel_sql_time;dur=1.919169999382575;desc=\"SQL 2 queries\", CachePanel_total_time;dur=2.0399810000526486;desc=\"Cache 1 Calls\"",
"Content-Length": "0",
"Referrer-Policy": "same-origin",
"X-Frame-Options": "DENY",
"djdt-request-id": "3e89467baded4ad498cf46ee313585fb",
"Content-Language": "en-us",
"X-Content-Type-Options": "nosniff",
"Cross-Origin-Opener-Policy": "same-origin"
},
"exception_message": null,
"exception_traceback": null
}

Notes

    • This endpoint provides comprehensive logging data for debugging and monitoring purposes
    • The duration field is automatically calculated from started_at and finished_at timestamps
    • Anonymous requests are stored with user: null and can be filtered using user=0 parameter
    • All JSON fields (query_params, body, response, etc.) may contain null values if no data was captured
    • Exception fields will be null for successful requests
    • Request and response headers may contain sensitive information - ensure proper access controls are in place