Repository navigation
Ops Telemetry Retention
Telemetry bounds its tables with age limits and thins old positions at night (ADR 0053, ADR 0017). The job runs inside the Telemetry service (one replica at a time, advisory lock); there is nothing to schedule outside.
Set as environment variables of the Telemetry service (Compose .env, Helm telemetry.env). Compose and the Helm chart pass TELEMETRY_RETENTION_POSITIONS_DAYS, TELEMETRY_POSITIONS_DETAIL_DAYS and TELEMETRY_MAINTENANCE_TIMEZONE through under the MOWDECK_ names below.
| Variable | Default | Meaning |
|---|---|---|
MOWDECK_TELEMETRY_RETENTION_HISTORY_DAYS |
30 |
History rows older than this are deleted |
MOWDECK_TELEMETRY_RETENTION_COMMANDS_DAYS |
30 |
Command timeline rows older than this are deleted |
MOWDECK_TELEMETRY_RETENTION_POSITIONS_DAYS |
730 |
Positions older than this are deleted; 0 keeps them forever; otherwise at least the detail days |
MOWDECK_TELEMETRY_POSITIONS_DETAIL_DAYS |
90 |
Positions younger than this keep every row (at least 7) |
MOWDECK_TELEMETRY_POSITIONS_THINNING_ENABLED |
true |
Thin older positions; false only deletes |
MOWDECK_TELEMETRY_POSITIONS_THIN_ACTIVE_SECONDS |
30 |
One row per this many seconds while mowing or moving (divides 300) |
MOWDECK_TELEMETRY_POSITIONS_THIN_IDLE_SECONDS |
300 |
One row per this many seconds while standing (divides 300) |
MOWDECK_TELEMETRY_MAINTENANCE_TIMEZONE |
UTC |
IANA zone of the window, for example Europe/Berlin
|
MOWDECK_TELEMETRY_THINNING_WINDOW_START_HOUR |
1 |
Local hour the nightly window opens |
MOWDECK_TELEMETRY_THINNING_WINDOW_END_HOUR |
5 |
Local hour it closes (exclusive); equal to the start means always |
MOWDECK_TELEMETRY_THINNING_BUDGET_SECONDS |
900 |
Longest one round runs |
MOWDECK_TELEMETRY_RETENTION_INTERVAL_SECONDS |
3600 |
How often the job wakes up |
Example for a German installation: MOWDECK_TELEMETRY_MAINTENANCE_TIMEZONE=Europe/Berlin. The window follows daylight saving time on its own.
- The first nights after an upgrade work through the backlog (one SQL statement per 6 hours of one mower, at most 15 minutes per round, rounds hourly inside the window). Watch
mowdeck_telemetry_position_thinning_rows_deleted_totaland the log lineposition thinning round(complete=falsemeans more to do tomorrow). - Metrics:
mowdeck_telemetry_retention_rows_deleted_total{table},mowdeck_telemetry_position_thinning_rows_scanned_total,mowdeck_telemetry_position_thinning_rows_deleted_total,mowdeck_telemetry_retention_round_seconds{kind}. - Disk space is reused by PostgreSQL after autovacuum; the files shrink only with a rewrite. After the first large run, a one-time
VACUUM (ANALYZE) mower_positions;is fine and lets the planner see the new sizes. Do not runVACUUM FULLon a live database (it locks the table). - Heatmaps and tracks older than the detail window show fewer points; coverage is joined across the gaps.
Run with psql against the Telemetry database. Nothing here writes.
-- 1. Size of the Telemetry tables (heap + indexes) and the estimated row count.
SELECT c.relname AS table_name,
pg_size_pretty(pg_total_relation_size(c.oid)) AS total,
pg_size_pretty(pg_relation_size(c.oid)) AS heap,
c.reltuples::bigint AS approx_rows
FROM pg_class c
JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE n.nspname = 'public' AND c.relkind = 'r'
AND c.relname IN ('mower_positions', 'mower_history', 'command_timeline',
'mower_snapshots', 'mower_health_daily', 'mower_positions_thinning')
ORDER BY pg_total_relation_size(c.oid) DESC;
-- 2. Positions per mower: count, oldest, newest, rows older than the detail window.
SELECT mower_id,
count(*) AS rows,
min(observed_at) AS oldest,
max(observed_at) AS newest,
count(*) FILTER (WHERE observed_at < now() - interval '90 days') AS older_than_90d
FROM mower_positions
GROUP BY mower_id;
-- 3. Expected saving of the default policy on rows older than 90 days: rows now versus
-- roughly the rows that survive (one per 30 s bin while blades_on, one per 5 min bin
-- otherwise; edges and turns add a little on top).
WITH old AS (
SELECT mower_id, observed_at, coalesce(blades_on, false) AS active
FROM mower_positions
WHERE observed_at < now() - interval '90 days'
)
SELECT (SELECT count(*) FROM old) AS rows_now,
(SELECT count(DISTINCT (mower_id,
date_bin(CASE WHEN active THEN interval '30 seconds' ELSE interval '5 minutes' END,
observed_at, TIMESTAMPTZ '2000-01-01 00:00:00+00'), active))
FROM old) AS rows_after_approx;
-- 4. Progress of the thinning: the watermark per mower.
SELECT mower_id, thinned_until FROM mower_positions_thinning ORDER BY thinned_until;Rule of thumb: multiply the bytes of query 1 by the ratio rows_after_approx / rows_now of query 3 for the share of the table that is older than the detail window.
Mirrored from docs/ops/telemetry-retention.md at commit 14af01c2a57ec5adc34136f7375ca93f2a5b7226. Edit the file in the repository, not this wiki page.
Mirrored from the docs/ directory at commit 14af01c2a57ec5adc34136f7375ca93f2a5b7226. Edit the files in the repository, not this wiki.
MowDeck documentation
- Home
- Phases
- Architecture
-
Decisions (ADR)
- Architecture decisions
- ADR 0001: OpenFGA instead of self-built authorization
- ADR 0002: Self-built Identity service in FastAPI instead of Keycloak or Zitadel
- ADR 0003: SvelteKit for the web app
- ADR 0004: Monorepo with a uv workspace
- ADR 0005: AGPL-3.0 for services and apps, Apache-2.0 for libraries
- ADR 0006: PostgreSQL for all persistence, no SQLite
- ADR 0007: NATS JetStream as event bus
- ADR 0008: Traefik as gateway
- ADR 0009: Command and event envelopes, subject naming and de-duplication
- ADR 0010: Python 3.13 for all services and libraries
- ADR 0011: Separate GPL-3.0 package for the PyMammotion adapter
- ADR 0012: Mower control interface and safety rules
- ADR 0013: Device-Gateway registry, sharding and per-mower concurrency
- ADR 0014: Authorization model, tuple ownership and the mowdeck-authz client
- ADR 0015: Tokens, sessions and key rotation
- ADR 0016: Fleet commands and authorization per command kind
- ADR 0017: Telemetry storage and retention
- ADR 0018: Realtime WebSocket protocol
- ADR 0019: Mammotion adapter transports, manual drive and secrets
- ADR 0020: Web app architecture
- ADR 0021: Browser authentication flow
- ADR 0022: Notifications: rules, recipients and delivery
- ADR 0023: Map rendering and projection
- ADR 0024: Scheduler: recurrence, rain pause and command issuing
- ADR 0025: Home Assistant integration as a pure API client
- ADR 0026: Manual drive channel over the Realtime WebSocket
- ADR 0027: Health history and theft alarm
- ADR 0028: Entitlements: plans as data and enforcement
- ADR 0029: Helm chart and release pipeline
- ADR 0030: Mowing patterns as plug-ins and the Planner
- ADR 0031: Billing with a Stripe adapter
- ADR 0032: Live camera over Agora, joined directly by the browser
- ADR 0033: Vision-assisted recovery with human approval
- ADR 0034: Linked cloud accounts and device discovery
- ADR 0035: Server-side camera frames and automatic AI analysis on errors
- ADR 0036: Native app shells with Capacitor, loading the web app from the server
- ADR 0037: Camera panorama calibration in the browser, with the AI supplying points only
- ADR 0038: Dual link per mower and firmware updates
- ADR 0039: Spot mowing by MowDeck-driven paths
- ADR 0040: Link heartbeat for online status
- ADR 0041: Spot runs from the dock: undock, transit and return
- ADR 0042: Drive calibration
- ADR 0043: Turn styles
- ADR 0044: Drive view with camera
- ADR 0045: Camera relay
- ADR 0046: Device settings as capabilities
- ADR 0047: The RTK base station as a Fleet device
- ADR 0048: Maintenance commands
- ADR 0049: Manual driving over the Mammotion cloud
- ADR 0050: Passkeys and the app login hand-off
- ADR 0051: Sign in with GitHub
- ADR 0052: Sign in with Apple
- ADR 0053: Retention and downsampling of the position track
- ADR 0054: Aerial photo under the mower map
- ADR 0055: Deploy maintenance window
- ADR 0056: Camera photo in push notifications for errors and theft alarms
- ADR 0057: Step-up re-authentication for critical actions
- ADR 0058: Theft tracking mode
- ADR 0059: iOS widgets and the mowing Live Activity
- ADR 0060: Apple Watch app
- ADR 0061: Mowing angle rotation
- ADR 0062: Setup tour for new users
- ADR 0063: Matter server (mowers in Apple Home and Google Home)
- ADR 0064: Personal access tokens and the public API documentation
- ADR 0065: Security center and new-login alerts
- ADR 0066: Cloud provider plugins and adapters for more vendors
- ADR 0067: Error code lexicon, provider independent
- ADR 0068: Public demo mode
-
Development
- Getting started
- Service template
- Shared libraries
- Cloud providers: adding a vendor
- Adding an error lexicon for a vendor
- Design: identity and authorization
- Design: fleet, telemetry, realtime
- Design: web app
- Web app
- Home Assistant integration
- Camera source bridge protocol
- Fuzzing and property-based tests
- GitHub wiki mirror
-
Operations
- Operating the Compose stack
- Operating MowDeck on Kubernetes (Helm)
- Building the Bluetooth bridge (ESPHome on a XIAO ESP32-S3)
- Releases
- Vendor library updates
- Billing operations
- Telemetry: retention and position downsampling
- iPhone and Android apps
- Passkeys
- Sign in with GitHub
- Aerial photo under the map
- Sign in with Apple
- Theft tracking mode
- Matter server
- Source code offer (AGPL-3.0 section 13)
- Public demo
- Spikes
-
Guides
- Guides
- ESP32 bridge: purchase and setup
- Signing in with a passkey
- Signing in with GitHub
- Error codes in plain words
- Aerial photo under the map
- Signing in with Apple
- Confirming critical actions
- Your security page
- iPhone widgets and the mowing Live Activity
- Apple Watch
- The setup tour
- Apple Home and Google Home (Matter)
- Worx Landroid, Kress and LandXcape mowers
- Scripting MowDeck
- API reference
- Original plan (German)