Skip to main content

Endpoint

POST /api/log
Create a maintenance log entry to record operator activities. Events are stored in InfluxDB and serve as ground-truth labels for supervised machine learning.

Request Body

asset_id
string
required
Asset identifier (e.g., “Motor-01”). Must be 1-100 characters.
event_type
string
required
Maintenance event classification. Allowed values:Preventive Maintenance:
  • PREVENTIVE_LUBRICATION - Scheduled lubrication activities
  • PREVENTIVE_CLEANING - Scheduled cleaning activities
  • PREVENTIVE_INSPECTION - Scheduled inspection activities
Corrective Maintenance:
  • CORRECTIVE_BEARING_REPLACEMENT - Repair/replacement of bearings
  • CORRECTIVE_ALIGNMENT - Alignment corrections
  • CORRECTIVE_ELECTRICAL - Electrical repairs
Status Changes:
  • STATUS_CALIBRATION - System calibration events
  • STATUS_RESTART - System restart events
severity
string
required
Event severity level. Allowed values:
  • LOW - Minor maintenance or routine activities
  • MEDIUM - Standard maintenance requiring attention
  • HIGH - Urgent repairs or significant issues
  • CRITICAL - Emergency situations requiring immediate action
description
string
required
Human-readable description of the maintenance activity. Must be 1-1000 characters. Include relevant details such as part numbers, observations, and actions taken.
timestamp
datetime
Event timestamp in ISO 8601 format with UTC timezone (e.g., “2026-01-31T10:30:00Z”). If not provided, defaults to the current server time. Allows backdating for historical entries.

Response

event_id
string
Unique identifier (UUID v4) for this log entry
asset_id
string
Asset that was logged
event_type
string
Type of maintenance event that was recorded
severity
string
Severity level of the event
timestamp
datetime
Timestamp of the event (UTC)
message
string
Confirmation message indicating successful log creation

Use Cases

  • Ground-Truth Labeling: Record maintenance events that can be correlated with sensor data for supervised ML training
  • Bearing Replacement Tracking: Log bearing replacements to correlate with vibration anomalies detected in sensor data
  • Lubrication Monitoring: Record lubrication events to track maintenance effectiveness over time
  • Failure Analysis: Document electrical repairs and other corrective actions for failure pattern analysis

ML Integration

Maintenance logs stored via this endpoint can be queried alongside sensor data to:
  • Train supervised models that predict failure modes based on sensor patterns
  • Identify early warning indicators in sensor data before failures occur
  • Validate anomaly detection algorithms against real-world maintenance events
  • Build predictive maintenance models with labeled training data

Example Request

curl -X POST "http://localhost:8000/api/log" \
  -H "Content-Type: application/json" \
  -d '{
    "asset_id": "Motor-01",
    "event_type": "CORRECTIVE_BEARING_REPLACEMENT",
    "severity": "HIGH",
    "description": "Replaced main bearing due to excessive vibration. Part #SKF-6205-2RS.",
    "timestamp": "2026-01-31T10:30:00Z"
  }'

Example Response

{
  "event_id": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
  "asset_id": "Motor-01",
  "event_type": "CORRECTIVE_BEARING_REPLACEMENT",
  "severity": "HIGH",
  "timestamp": "2026-01-31T10:30:00Z",
  "message": "Log entry created successfully for Motor-01"
}

Error Responses

422 Validation Error

Returned when the request body fails validation.
{
  "detail": [
    {
      "loc": ["body", "event_type"],
      "msg": "Input should be 'PREVENTIVE_LUBRICATION', 'PREVENTIVE_CLEANING', 'PREVENTIVE_INSPECTION', 'CORRECTIVE_BEARING_REPLACEMENT', 'CORRECTIVE_ALIGNMENT', 'CORRECTIVE_ELECTRICAL', 'STATUS_CALIBRATION' or 'STATUS_RESTART'",
      "type": "enum"
    }
  ]
}

500 Internal Server Error

Returned when the database write fails or an unexpected error occurs.
{
  "detail": "Failed to persist log entry to database"
}

Build docs developers (and LLMs) love