Investigate Autonomous Fleet Charging Failure and Degradation
System DesignModel answerLast updated
Analyze noisy charging logs, define unbiased reliability metrics, formulate root cause logic in SQL, and design a debugging playbook for slow-charging sessions.
Problem Context
You are a Lead Data Engineer at an autonomous mobility company. Operations has reported a spike in charging alerts across the fleet. You are provided with telemetry records streaming from charging sessions with the following fields:
session_id(string): Unique identifier for the charging attemptrobot_id(string): Unique identifier for the robotstart_time(timestamp): Start of the charging attemptend_time(timestamp, nullable): End of the attempt (frequently null for sudden failures)charge_added_wh(float, nullable): Total electrical energy transferred in Watt-hoursavg_voltage_v(float): Average recorded voltagestatus(string):'SUCCESS','FAILED', or'TIMEOUT'
Due to hardware disconnects, data drops, and sensor corruption, end_time is missing for many ungracefully aborted sessions, and charge_added_wh is occasionally null.
Requirements
-
Metrics Framework:
- Propose an unbiased Charging Reliability Rate metric that handles missing duration/energy telemetry without skewing results against units that fail early.
- Explain how you differentiate real-time critical safety alerts from batch analytical metrics.
- Detail a strategy for handling streaming data delays and out-of-order logs at scale (10,000+ daily sessions).
-
Root Cause Analysis (Robot vs. Charger vs. Environment):
- Assuming charging docks are shared by multiple robots (and vice versa), describe how to isolate whether failures stem from robot-side battery degradation, charger-side pad issues, or site-level environmental factors.
- Provide a SQL snippet or algorithmic framework demonstrating how to compare cross-docking failure rates while controlling for base traffic volume.
-
Performance Bottleneck Playbook:
- Define a plan to investigate a fleet subset exhibiting "Slow Charging" (energy transfer rate below baseline).
- Outline key diagnostic signatures to distinguish among thermal throttling, software power caps, and high-resistance physical contact issues.
Hints
Hint 1
Identify missing schema elements early (e.g., station_id, temperature, state of charge) and state how you would join them.
Hint 2
Use session attempts as the denominator rather than elapsed duration to prevent early-failure bias.
Hint 3
Leverage the crossed structure of robots docking at multiple stations to construct leave-one-out failure rate comparisons in SQL.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Clarifications and Data Schema Gaps
Before designing metrics and pipelines, note that the provided telemetry log lacks three essential dimensions:
station_id(ordock_id): Required to isolate dock-side hardware defects.battery_temperature/ambient_temperature: Required to diagnose thermal throttling.start_soc/end_soc(State of Charge): Required to reconstruct missingcharge_added_whvalues and control for the standard lithium-ion constant-current/constant-voltage (CC/CV) charging curve.
In a production architecture, we join the charging event stream with a dock assignment service stream (to attach station_id) and high-frequency battery/ambient sensor streams (to attach temperature and SoC).
1. Metrics Framework & Data Engineering Strategy
Primary Metric: Session Completion Rate (Unbiased)
To prevent bias against robots or stations that fail early in a cycle (e.g., within 5 seconds of docking), rely on an intent-based attempt denominator rather than duration-based exposure.
$$\text{Charging Reliability Rate} = \frac{\sum \mathbb{I}(\text{status} = \text{'SUCCESS'})}{\sum \mathbb{I}(\text{session_id is present})}$$
- Handling Missing Telemetry: Every initiated session receives a row when docking starts. Even if
end_timeorcharge_added_whis missing, the row exists withstatus IN ('FAILED', 'TIMEOUT'). Counting every session attempt in the denominator ensures that early-failing sessions are counted fully, avoiding the overestimation of reliability caused by dropping incomplete rows.
Secondary Metric: Exposure-Normalized Failure Rate
For long-term reliability engineering, compute failure rates relative to operating duration:
$$\text{Failure Rate per 100 Charging Hours} = \frac{\text{Count of (FAILED + TIMEOUT)}}{\text{Total Effective Charging Hours}} \times 100$$
To calculate duration when end_time is null:
- Use
end_timeif available. - Fall back to the timestamp of the last observed heartbeat/sensor payload for that
session_id. - If no heartbeat exists, impute
end_time = start_time + median_failed_durationand flag the record asis_imputed = True. - Report the metric both with and without imputed rows to monitor imputation bias.
Categorization & Priority Pipeline Tiers
System issues require different processing latencies depending on severity:
| Priority | Scenario | Telemetry Condition | Architecture & SLA |
|---|---|---|---|
| P0 (Critical) | Over-temperature, over-voltage, severe electrical short | avg_voltage_v > max_spec OR temp > critical_threshold | Continuous stream processing (e.g., Flink). Triggers immediate hardware isolation within seconds. |
| P1 (Operational) | Charge session aborted or timed out | status IN ('FAILED', 'TIMEOUT') | Near-real-time streaming. Re-routes affected robots to alternate chargers within minutes. |
| P2 (Efficiency) | Low power transfer rate ("Slow Charge") | $\frac{\text{charge_added_wh}}{\text{duration}} < \text{threshold}$ | Daily micro-batch / ETL. Used for maintenance scheduling. |
Handling Late-Arriving Streaming Data
At ~10,000 sessions/day, scale is modest (~0.12 sessions/sec baseline, with peak spikes). The main challenge is data completeness and out-of-order events:
- Watermarking: Set a late-arrival watermark (e.g., 2 hours) on event-time processing nodes.
- Session State Machine: Maintain session state in a key-value store (e.g., Redis or RocksDB state backend). Keep state open upon receiving
session_start. Transition toCLOSEDupon receivingsession_end. If no update occurs for 30 minutes, emit a provisionalTIMEOUT. - Idempotent Storage Strategy: Write aggregated metrics to an analytical database (e.g., ClickHouse, Snowflake, or BigQuery) using a
MERGEstatement onsession_id. Label metric windows asprovisionaluntil the watermark passes, then re-aggregate to mark themfinal.
2. Root Cause Analysis: Robot vs. Station vs. Environment
Because robots dock across various stations and stations serve multiple robots, we use a crossed-design analysis to isolate the source of failures.
Isolation Methodology
- Robot-Side Issue: A specific
robot_idexhibits high failure rates across all stations it visits, while those same stations maintain high success rates with other robots. - Station-Side Issue: A specific
station_idexhibits high failure rates across all robots docking at it, while those same robots succeed elsewhere. - Pairwise/Interaction Issue: Failures occur primarily on specific pairs (e.g., Robot Model A on Station Revision B), indicating mechanical misalignment or protocol incompatibilities.
- Environmental Issue: Failures spike across all robots and stations within a specific geographic site, correlated with ambient temperature or power grid fluctuations.
SQL Implementation: Cross-Dock Failure Rate Isolation
Assuming telemetry is enriched with station_id:
WITH session_base AS (
SELECT
session_id,
robot_id,
station_id,
CASE WHEN status != 'SUCCESS' THEN 1 ELSE 0 END AS is_failure
FROM enriched_charging_logs
WHERE start_time >= CURRENT_TIMESTAMP - INTERVAL '14 days'
),
pair_aggregates AS (
SELECT
robot_id,
station_id,
COUNT(*) AS total_pair_sessions,
SUM(is_failure) AS pair_failures
FROM session_base
GROUP BY robot_id, station_id
),
windowed_metrics AS (
SELECT
robot_id,
station_id,
total_pair_sessions,
pair_failures,
-- Total metrics for this robot across all stations
SUM(pair_failures) OVER(PARTITION BY robot_id) AS total_robot_failures,
SUM(total_pair_sessions) OVER(PARTITION BY robot_id) AS total_robot_sessions,
-- Total metrics for this station across all robots
SUM(pair_failures) OVER(PARTITION BY station_id) AS total_station_failures,
SUM(total_pair_sessions) OVER(PARTITION BY station_id) AS total_station_sessions
FROM pair_aggregates
)
SELECT
robot_id,
station_id,
total_pair_sessions,
ROUND(pair_failures::numeric / NULLIF(total_pair_sessions, 0), 3) AS pair_failure_rate,
-- Leave-one-out failure rate for the robot at OTHER stations
ROUND(
(total_robot_failures - pair_failures)::numeric /
NULLIF(total_robot_sessions - total_pair_sessions, 0), 3
) AS robot_failure_rate_elsewhere,
-- Leave-one-out failure rate for the station with OTHER robots
ROUND(
(total_station_failures - pair_failures)::numeric /
NULLIF(total_station_sessions - total_pair_sessions, 0), 3
) AS station_failure_rate_other_robots
FROM windowed_metrics
WHERE total_pair_sessions >= 5
ORDER BY pair_failure_rate DESC;
Statistical Modeling Approach
To isolate environmental fixed effects from hardware random effects, fit a Mixed-Effects Logistic Regression:
$$\text{logit}(P(\text{Failure})) = \beta_0 + \beta_1(\text{AmbientTemp}) + \beta_2(\text{GridVoltage}) + u_{\text{robot_id}} + v_{\text{station_id}}$$
- High variance in random effect $u_{\text{robot_id}} \implies$ Robot battery/BMS degradation.
- High variance in random effect $v_{\text{station_id}} \implies$ Station pad/connector wear.
- Large fixed effect coefficients ($\beta_1, \beta_2$) $\implies$ Environmental driving factors.
3. Slow-Charging Debugging Playbook
"Slow Charging" occurs when the average power transfer ($\text{Power} = \frac{\text{charge_added_wh}}{\text{duration_hours}}$) falls below expected thresholds.
[Is Power Transfer < Threshold?]
│
┌─────────────┴─────────────┐
▼ ▼
[Check Duration Valid?] [Drop Imputed Sessions]
│
▼
[Normalized for SoC Curve?] ──► Compare power in matched SoC bands
│ (e.g., 20% -> 50% vs 80% -> 100%)
│
┌─────────────┼───────────────────────────┐
▼ ▼ ▼
[Signature A] [Signature B] [Signature C]
Thermal Software Power Physical Contact /
Throttling Management Connector Resistance
Diagnostic Signatures
Signature A: Thermal Throttling
- Physical Cause: High internal battery temperature forces the Battery Management System (BMS) to step down charge current to prevent thermal runaway.
- Telemetry Indicators:
- In-session telemetry shows nominal initial power, followed by a sudden step-down when battery temperature crosses a threshold (e.g., $45^\circ\text{C}$).
- Highly correlated with back-to-back charging sessions and high ambient temperatures.
avg_voltage_vremains normal; current drops significantly.
Signature B: Software Power Management / Firmware Cap
- Physical Cause: BMS or dock firmware throttling power due to active power-sharing profiles, bugged firmware, or soft limits based on battery state-of-health algorithms.
- Telemetry Indicators:
- Power output profile is flat or exhibits rigid step functions at fixed SoC levels.
- Onset date aligns with a specific software deployment or firmware release.
- Uniform across all docks, regardless of local ambient temperatures or hardware age.
Signature C: Physical Resistance & Contact Wear
- Physical Cause: Oxide buildup, dirt, or mechanical misalignment on the contact pads causing high electrical resistance ($R$).
- Telemetry Indicators:
- Voltage drops across the interface or shows high high-frequency variance (
avg_voltage_vis lower or fluctuated relative to supplied dock voltage). - Power transfer is low throughout the session.
- Strong correlation with specific physical dock pads (
station_id).
- Voltage drops across the interface or shows high high-frequency variance (