tracksolid_timescale_grafan.../legacy/tracksolid_ingestion_pipeline.txt
david kiania e5b0e192d8 chore(repo): reorganize tree into migrations/ data/ legacy/ docs/
Group root-level files (accreted from incremental changes) by purpose
without moving any deployment entrypoint or breaking imports:

- migrations/  : numbered SQL 02-10
- data/        : source CSVs
- legacy/      : superseded pre-_rev scripts + old pipeline notes (not deployed)
- docs/{manuals,reference,reports}/ : loose manuals, references, reports
- strip stray ** / *** prefixes from 5 doc filenames
- delete empty documents.txt / push_webhook.md

Reference updates so nothing breaks:
- run_migrations.py  -> /app/migrations/<file>
- run_migrations.sh  -> $SCRIPT_DIR/migrations
- import_drivers_csv.py -> data/<csv>
- docker-compose.yaml -> runbook path comment
- CLAUDE.md -> codebase map + inline doc references

Deployed Python (3 services + ts_shared_rev + run_migrations) and the
documented ops one-shots stay at root, preserving the flat-import layout
and all documented commands. Verified: py_compile clean across all modules,
every MIGRATIONS entry resolves under migrations/, CI-referenced paths
(tests/, mypy targets, db_audit) and the grafana build context intact.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 02:27:30 +03:00

56 lines
1.6 KiB
Text

### Pipeline health — last hour (key check)
SELECT
endpoint,
COUNT(*) AS calls,
SUM(rows_upserted) AS upserted,
SUM(rows_inserted) AS inserted,
ROUND(AVG(duration_ms)::numeric, 0) AS avg_ms,
COUNT(*) FILTER (WHERE success = false) AS failures,
MAX(run_at AT TIME ZONE 'Africa/Nairobi') AS last_call_eat
FROM tracksolid.ingestion_log
WHERE run_at > now() - interval '1 hour'
GROUP BY endpoint
ORDER BY calls DESC;
-------- Ingestion Pipeline Health
SELECT
endpoint,
COUNT(*) AS total_calls,
SUM(rows_upserted) AS total_upserted,
SUM(rows_inserted) AS total_inserted,
ROUND(AVG(duration_ms)::numeric, 0) AS avg_ms,
COUNT(*) FILTER (WHERE success = false) AS failures,
MIN(run_at AT TIME ZONE 'Africa/Nairobi') AS first_call,
MAX(run_at AT TIME ZONE 'Africa/Nairobi') AS last_call
FROM tracksolid.ingestion_log
GROUP BY endpoint
ORDER BY total_calls DESC;
### Recent calls — last 20 entries
SELECT
run_at AT TIME ZONE 'Africa/Nairobi' AS run_eat,
endpoint,
imei_count,
rows_upserted,
rows_inserted,
duration_ms,
success,
error_message
FROM tracksolid.ingestion_log
ORDER BY run_at DESC
LIMIT 20;
### Recent calls — FAILED CALLS entries
SELECT
run_at AT TIME ZONE 'Africa/Nairobi' AS run_eat,
endpoint,
error_code,
error_message
FROM tracksolid.ingestion_log
WHERE success = false
ORDER BY run_at DESC;