GET /api/logs
curl --request GET \
--url https://vij.example.com/api/logsimport requests
url = "https://vij.example.com/api/logs"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://vij.example.com/api/logs', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://vij.example.com/api/logs",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://vij.example.com/api/logs"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://vij.example.com/api/logs")
.asString();require 'uri'
require 'net/http'
url = URI("https://vij.example.com/api/logs")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"logs": [
{
"_id": "65a1b2c3d4e5f6g7h8i9j0k1",
"message": "Payment processing failed",
"name": "Error",
"stack": "Error: Payment processing failed\n at processPayment (payment.js:45:12)\n at handleCheckout (checkout.js:123:5)",
"severity": "error",
"timestamp": "2024-01-01T12:34:56.789Z",
"appId": "my-frontend-app",
"environment": "production",
"metadata": {
"userId": "user-123",
"orderId": "order-456",
"feature": "checkout"
},
"context": {
"viewport": { "width": 1920, "height": 1080 },
"browser": {
"userAgent": "Mozilla/5.0...",
"language": "en-US"
}
},
"group": "abc123def456",
"aiAnalysis": {
"summary": "Payment object was undefined when processing transaction",
"possibleCause": "API request failed or user session expired",
"suggestedFix": "Add null check before accessing payment.amount"
}
},
{
"_id": "65a1b2c3d4e5f6g7h8i9j0k2",
"message": "Database connection timeout",
"name": "TimeoutError",
"stack": "TimeoutError: Connection timeout\n at connect (db.js:23:10)",
"severity": "error",
"timestamp": "2024-01-01T12:30:00.000Z",
"appId": "backend-api",
"environment": "production",
"metadata": {
"database": "mongodb",
"timeout": 5000
},
"context": {
"process": {
"pid": 12345,
"platform": "linux",
"nodeVersion": "v20.0.0"
}
},
"group": "def456ghi789"
}
],
"total": 1547,
"page": 1,
"limit": 50,
"pages": 31
}
Ingestion API
GET /api/logs
Retrieve error logs with filtering and pagination
GET
/
api
/
logs
GET /api/logs
curl --request GET \
--url https://vij.example.com/api/logsimport requests
url = "https://vij.example.com/api/logs"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://vij.example.com/api/logs', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://vij.example.com/api/logs",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://vij.example.com/api/logs"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://vij.example.com/api/logs")
.asString();require 'uri'
require 'net/http'
url = URI("https://vij.example.com/api/logs")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"logs": [
{
"_id": "65a1b2c3d4e5f6g7h8i9j0k1",
"message": "Payment processing failed",
"name": "Error",
"stack": "Error: Payment processing failed\n at processPayment (payment.js:45:12)\n at handleCheckout (checkout.js:123:5)",
"severity": "error",
"timestamp": "2024-01-01T12:34:56.789Z",
"appId": "my-frontend-app",
"environment": "production",
"metadata": {
"userId": "user-123",
"orderId": "order-456",
"feature": "checkout"
},
"context": {
"viewport": { "width": 1920, "height": 1080 },
"browser": {
"userAgent": "Mozilla/5.0...",
"language": "en-US"
}
},
"group": "abc123def456",
"aiAnalysis": {
"summary": "Payment object was undefined when processing transaction",
"possibleCause": "API request failed or user session expired",
"suggestedFix": "Add null check before accessing payment.amount"
}
},
{
"_id": "65a1b2c3d4e5f6g7h8i9j0k2",
"message": "Database connection timeout",
"name": "TimeoutError",
"stack": "TimeoutError: Connection timeout\n at connect (db.js:23:10)",
"severity": "error",
"timestamp": "2024-01-01T12:30:00.000Z",
"appId": "backend-api",
"environment": "production",
"metadata": {
"database": "mongodb",
"timeout": 5000
},
"context": {
"process": {
"pid": 12345,
"platform": "linux",
"nodeVersion": "v20.0.0"
}
},
"group": "def456ghi789"
}
],
"total": 1547,
"page": 1,
"limit": 50,
"pages": 31
}
The GET
Response includes:
Recommended limits:
Cache key should include:
/api/logs endpoint retrieves stored error logs with support for filtering, searching, sorting, and pagination.
Query Parameters
Filter logs created after this date (ISO 8601).Example:
/api/logs?startDate=2024-01-01T00:00:00ZFilter logs created before this date (ISO 8601).Example:
/api/logs?endDate=2024-01-31T23:59:59ZField to sort by.Values:
timestamp, severity, appId, environmentExample: /api/logs?sortBy=severitySort order.Values:
asc (ascending), desc (descending)Example: /api/logs?sortOrder=ascResponse Fields
Array of error log objects.
Show Log object properties
Show Log object properties
Example Requests
curl "https://vij.example.com/api/logs?severity=error"
curl "https://vij.example.com/api/logs?environment=production&severity=error"
curl "https://vij.example.com/api/logs?search=TypeError&appId=my-app&limit=10"
curl "https://vij.example.com/api/logs?startDate=2024-01-01T00:00:00Z&endDate=2024-01-31T23:59:59Z"
curl "https://vij.example.com/api/logs?page=2&limit=50&sortBy=timestamp&sortOrder=desc"
Example Response
{
"logs": [
{
"_id": "65a1b2c3d4e5f6g7h8i9j0k1",
"message": "Payment processing failed",
"name": "Error",
"stack": "Error: Payment processing failed\n at processPayment (payment.js:45:12)\n at handleCheckout (checkout.js:123:5)",
"severity": "error",
"timestamp": "2024-01-01T12:34:56.789Z",
"appId": "my-frontend-app",
"environment": "production",
"metadata": {
"userId": "user-123",
"orderId": "order-456",
"feature": "checkout"
},
"context": {
"viewport": { "width": 1920, "height": 1080 },
"browser": {
"userAgent": "Mozilla/5.0...",
"language": "en-US"
}
},
"group": "abc123def456",
"aiAnalysis": {
"summary": "Payment object was undefined when processing transaction",
"possibleCause": "API request failed or user session expired",
"suggestedFix": "Add null check before accessing payment.amount"
}
},
{
"_id": "65a1b2c3d4e5f6g7h8i9j0k2",
"message": "Database connection timeout",
"name": "TimeoutError",
"stack": "TimeoutError: Connection timeout\n at connect (db.js:23:10)",
"severity": "error",
"timestamp": "2024-01-01T12:30:00.000Z",
"appId": "backend-api",
"environment": "production",
"metadata": {
"database": "mongodb",
"timeout": 5000
},
"context": {
"process": {
"pid": 12345,
"platform": "linux",
"nodeVersion": "v20.0.0"
}
},
"group": "def456ghi789"
}
],
"total": 1547,
"page": 1,
"limit": 50,
"pages": 31
}
Error Responses
{
"error": "Invalid severity value. Must be 'error', 'warning', or 'info'"
}
{
"error": "Invalid date format for startDate. Use ISO 8601 format"
}
{
"error": "Failed to fetch logs"
}
Filtering Examples
By Severity
# Get only errors
GET /api/logs?severity=error
# Get warnings and info
GET /api/logs?severity=warning
GET /api/logs?severity=info
By Environment
# Production errors only
GET /api/logs?environment=production&severity=error
# Staging errors
GET /api/logs?environment=staging&severity=error
By Application
# Specific app
GET /api/logs?appId=my-frontend-app
# Multiple apps (requires multiple queries or custom implementation)
GET /api/logs?appId=my-frontend-app
GET /api/logs?appId=my-backend-app
By Date Range
# Last 24 hours
GET /api/logs?startDate=$(date -u -d '1 day ago' +%Y-%m-%dT%H:%M:%SZ)
# Specific month
GET /api/logs?startDate=2024-01-01T00:00:00Z&endDate=2024-01-31T23:59:59Z
# Today's errors
GET /api/logs?startDate=$(date -u +%Y-%m-%dT00:00:00Z)
Full-Text Search
# Search for specific error
GET /api/logs?search=TypeError
# Search in specific app
GET /api/logs?search=payment&appId=my-app
# Search with phrase
GET /api/logs?search="cannot%20read%20property"
Combined Filters
# Complex query
GET /api/logs?severity=error&environment=production&appId=my-app&search=payment&startDate=2024-01-01T00:00:00Z&limit=25
Pagination
Navigate through large result sets:# First page
GET /api/logs?page=1&limit=50
# Second page
GET /api/logs?page=2&limit=50
# Large page size
GET /api/logs?page=1&limit=100 # Max: 100
total- Total matching logspage- Current pagelimit- Items per pagepages- Total pages
if (page < pages) {
const nextPage = page + 1;
fetch(`/api/logs?page=${nextPage}&limit=${limit}`);
}
Sorting
Sort results by different fields:# Newest first (default)
GET /api/logs?sortBy=timestamp&sortOrder=desc
# Oldest first
GET /api/logs?sortBy=timestamp&sortOrder=asc
# Sort by severity
GET /api/logs?sortBy=severity&sortOrder=desc
# Sort by app
GET /api/logs?sortBy=appId&sortOrder=asc
Performance Considerations
Use time filters
Use time filters
Always include time filters to reduce query scope:
# Good - scans less data
GET /api/logs?startDate=2024-01-01T00:00:00Z
# Slow - scans all data
GET /api/logs
Limit page size
Limit page size
Use reasonable page sizes:Maximum allowed: 100 items per page
# Good
GET /api/logs?limit=50
# Slow
GET /api/logs?limit=10000
Use indexed fields
Use indexed fields
These fields are indexed for fast queries:
timestampseverityenvironmentappIdgroup
Text search performance
Text search performance
Full-text search uses MongoDB text index:
# Fast (indexed)
GET /api/logs?search=TypeError
# Slower on large datasets
GET /api/logs?search=very%20specific%20long%20phrase
Client Implementation
JavaScript/TypeScript
interface LogQuery {
severity?: 'error' | 'warning' | 'info';
environment?: string;
appId?: string;
search?: string;
startDate?: string;
endDate?: string;
page?: number;
limit?: number;
sortBy?: string;
sortOrder?: 'asc' | 'desc';
}
async function fetchLogs(query: LogQuery) {
const params = new URLSearchParams(
Object.entries(query)
.filter(([_, v]) => v !== undefined)
.map(([k, v]) => [k, String(v)])
);
const response = await fetch(
`https://vij.example.com/api/logs?${params}`
);
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${await response.text()}`);
}
return response.json();
}
// Usage
const logs = await fetchLogs({
severity: 'error',
environment: 'production',
page: 1,
limit: 50
});
Python
import requests
from typing import Optional, Literal
def fetch_logs(
severity: Optional[Literal['error', 'warning', 'info']] = None,
environment: Optional[str] = None,
app_id: Optional[str] = None,
search: Optional[str] = None,
start_date: Optional[str] = None,
end_date: Optional[str] = None,
page: int = 1,
limit: int = 50
):
params = {
k: v for k, v in {
'severity': severity,
'environment': environment,
'appId': app_id,
'search': search,
'startDate': start_date,
'endDate': end_date,
'page': page,
'limit': limit
}.items() if v is not None
}
response = requests.get(
'https://vij.example.com/api/logs',
params=params
)
response.raise_for_status()
return response.json()
# Usage
logs = fetch_logs(
severity='error',
environment='production',
page=1,
limit=50
)
Rate Limiting
No rate limiting by default. Implement rate limiting in production.
- 100 requests per minute per IP
- 1,000 requests per hour per user
Caching
Responses can be cached for performance:# Cache-Control header
Cache-Control: public, max-age=60
- All query parameters
- Current time bucket (e.g., minute)
Related Endpoints
POST /api/logs
Send error logs to VIJ
GET /api/stats
Get error statistics
GET /api/groups
Retrieve error groups
Filtering Guide
Advanced filtering techniques