Skip to main content

Endpoint

GET /api/logs
Retrieve maintenance logs from InfluxDB for chart overlay and correlation with sensor data.

Query Parameters

hours
integer
default:"24"
Look back period in hours. Defaults to 24 hours.
limit
integer
default:"50"
Maximum number of records to return. Defaults to 50.
asset_id
string
Filter logs by specific asset identifier (e.g., “Motor-01”). If not provided, returns logs for all assets.

Response

logs
array
Array of maintenance log entries
timestamp
datetime
Timestamp of the maintenance event (UTC)
asset_id
string
Asset identifier (e.g., “Motor-01”)
event_type
string
Type of maintenance event. Allowed values:
  • PREVENTIVE_LUBRICATION
  • PREVENTIVE_CLEANING
  • PREVENTIVE_INSPECTION
  • CORRECTIVE_BEARING_REPLACEMENT
  • CORRECTIVE_ALIGNMENT
  • CORRECTIVE_ELECTRICAL
  • STATUS_CALIBRATION
  • STATUS_RESTART
severity
string
Event severity level: LOW, MEDIUM, HIGH, or CRITICAL
description
string
Human-readable description of the maintenance activity
event_id
string
Unique identifier for this log entry (UUID v4)
count
integer
Total number of logs returned in the response
query_params
object
Echo of the query parameters used
hours
integer
Look back period used
limit
integer
Limit applied
asset_id
string
Asset filter applied (if any)

Use Cases

  • Chart Overlay: Display maintenance events on sensor charts to visualize correlation between maintenance activities and sensor readings
  • Anomaly Correlation: Correlate sensor anomalies with maintenance activities to understand cause and effect
  • Audit Trail: Review operator-logged events for compliance and documentation purposes
  • ML Training: Retrieve ground-truth labels for supervised machine learning model training

Example Request

curl -X GET "http://localhost:8000/api/logs?hours=48&limit=100&asset_id=Motor-01"

Example Response

{
  "logs": [
    {
      "timestamp": "2026-01-31T10:30:00Z",
      "asset_id": "Motor-01",
      "event_type": "CORRECTIVE_BEARING_REPLACEMENT",
      "severity": "HIGH",
      "description": "Replaced main bearing due to excessive vibration. Part #SKF-6205-2RS.",
      "event_id": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d"
    },
    {
      "timestamp": "2026-01-30T14:15:00Z",
      "asset_id": "Motor-01",
      "event_type": "PREVENTIVE_LUBRICATION",
      "severity": "LOW",
      "description": "Applied lithium grease to bearing housing per maintenance schedule.",
      "event_id": "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e"
    }
  ],
  "count": 2,
  "query_params": {
    "hours": 48,
    "limit": 100,
    "asset_id": "Motor-01"
  }
}

Error Responses

500 Internal Server Error

Returned when the database query fails or an unexpected error occurs.
{
  "detail": "Failed to retrieve logs: connection timeout"
}

Build docs developers (and LLMs) love