Overview
The SigNoz Logs API is a robust interface which enables developers to manage and analyze log data efficiently. This API facilitates various operations:
-
Searching Logs: Allows users to search through log data based on specific criteria. For example, finding all logs where the error code is 500.
-
Paginating Logs: Helps in navigating through large sets of log data in a manageable way. For instance, retrieving logs in batches of 100 for easy viewing.
-
Aggregating Logs: Enables summarizing log data to extract meaningful insights, such as aggregating logs to count the number of errors per day.
API Endpoint
Endpoint for Logs API:
POST https://<your-instance-url>/api/v5/query_range
Replace <your-instance-url> with the URL of your SigNoz instance, for example example.us.signoz.cloud.
Prerequisites
API key: To access this API, you need an API key. Go to Settings → Service Accounts in SigNoz, create a service account, and generate an API key from its Keys tab. See Service Accounts for step-by-step instructions.

API keys can only be created/managed by users with the Admin role. If you don't have the Admin role, contact your organization's admin to create an API key for you.
The service account needs a role that can read logs, such as signoz-viewer. See Service Accounts.
SigNoz version: the steps on this page work on SigNoz Cloud and on self-hosted SigNoz v0.114.0 or later, the first version with service accounts.
Authentication
Using the API key: Add the API key to your request header as follows:
SIGNOZ-API-KEY: <your-api-key>Send a Request
This example returns the 10 latest error logs from the last 15 minutes.
-
Set the URL of your SigNoz instance and your API key:
export SIGNOZ_URL="https://<your-instance-url>" export SIGNOZ_API_KEY="<your-api-key>"Verify these values:
<your-instance-url>: the URL that you use to open SigNoz, for exampleexample.us.signoz.cloudon SigNoz Cloud orsignoz.example.comfor self-hosted SigNoz. If your self-hosted instance has no TLS, changehttps://tohttp://.<your-api-key>: the API key from Prerequisites.
-
Create the request payload.
startandendare Unix timestamps in milliseconds:END_MS=$(( $(date +%s) * 1000 )) START_MS=$(( END_MS - 15 * 60 * 1000 )) cat > query.json <<EOF { "start": $START_MS, "end": $END_MS, "requestType": "raw", "compositeQuery": { "queries": [ { "type": "builder_query", "spec": { "name": "A", "signal": "logs", "filter": { "expression": "severity_text = 'ERROR'" }, "order": [{ "key": { "name": "timestamp" }, "direction": "desc" }], "limit": 10 } } ] } } EOF -
Send the request:
curl -s -X POST "$SIGNOZ_URL/api/v5/query_range" \ -H "SIGNOZ-API-KEY: $SIGNOZ_API_KEY" \ -H "Content-Type: application/json" \ -d @query.json
The response lists each log in data.data.results[0].rows. Each row has the log fields under data. This response is shortened:
{
"status": "success",
"data": {
"type": "raw",
"data": {
"results": [
{
"queryName": "A",
"rows": [
{
"timestamp": "2026-11-06T05:52:01.605786Z",
"data": {
"body": "payment gateway timeout for order 42",
"severity_text": "ERROR",
"resources_string": { "service.name": "checkout" },
"attributes_string": { "http.route": "/api/checkout" },
"trace_id": "",
"id": "0mMZCp9dqBWc0v0QJnO2BRUhgst",
"timestamp": 1793944321605786000
}
}
]
}
]
}
}
}To return only some fields, such as the log body, see Return only some fields.
If the response has the authz_forbidden error code, the service account of the API key has no role that can read logs. Assign it a role such as signoz-viewer.
Export Logs
To download raw logs as a file, send a query payload to POST /api/v1/export_raw_data. An API key with the signoz-viewer role is enough.
-
In
query.jsonfrom Send a Request, setstartandendto the time range to export, and setlimitto the number of rows. The maximum is 50,000. Withoutlimit, the export returns 10,000 rows. -
Send the payload. Set
formattojsonlorcsv. Withoutformat, the export is CSV:curl -s -X POST "$SIGNOZ_URL/api/v1/export_raw_data?format=jsonl" \ -H "SIGNOZ-API-KEY: $SIGNOZ_API_KEY" \ -H "Content-Type: application/json" \ -d @query.json \ -o logs.jsonl
A limit above 50,000 returns limit cannot be more than 50000. The Logs Explorer download has the same maximum.
Export More Than 50,000 Logs
To export more logs, export consecutive time windows that each hold fewer than 50,000 logs. This script exports the last 24 hours in 1-hour windows, one JSONL file per window. It needs jq and query.json from Send a Request:
WINDOW_MS=$(( 60 * 60 * 1000 ))
END_MS=$(( $(date +%s) * 1000 ))
START_MS=$(( END_MS - 24 * WINDOW_MS ))
for (( S = START_MS; S < END_MS; S += WINDOW_MS )); do
E=$(( S + WINDOW_MS ))
jq --argjson s "$S" --argjson e "$E" \
'.start = $s | .end = $e | .compositeQuery.queries[0].spec.limit = 50000' \
query.json > window.json
curl -s -X POST "$SIGNOZ_URL/api/v1/export_raw_data?format=jsonl" \
-H "SIGNOZ-API-KEY: $SIGNOZ_API_KEY" \
-H "Content-Type: application/json" \
-d @window.json -o "logs-$S.jsonl"
ROWS=$(wc -l < "logs-$S.jsonl")
echo "logs-$S.jsonl: $ROWS rows"
[ "$ROWS" -ge 50000 ] && echo " Window is full. Use a smaller window."
doneIf a file has 50,000 rows, its window holds more logs than one export returns. Set WINDOW_MS to a smaller window, for example 5 * 60 * 1000 for 5 minutes, and run the script again. The windows do not overlap, so no log appears in two files.
Operations
- Search Logs — filter logs by attributes, body content, severity, or trace ID with pagination support.
- Aggregate Logs — compute counts, averages, and group-by operations over filtered log data.
- Logs URL for Explorer — generate a direct URL to the Logs Explorer with predefined filters and time range.
- Payload Model — request and response schema reference.