monitoring-app 1.1.84__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of monitoring-app might be problematic. Click here for more details.

Files changed (106) hide show
  1. monitoring_app-1.1.84/CHANGELOG.md +326 -0
  2. monitoring_app-1.1.84/LICENSE +7 -0
  3. monitoring_app-1.1.84/MANIFEST.in +48 -0
  4. monitoring_app-1.1.84/PKG-INFO +224 -0
  5. monitoring_app-1.1.84/README.md +186 -0
  6. monitoring_app-1.1.84/VERSION +1 -0
  7. monitoring_app-1.1.84/deploy/auth.policy.example +78 -0
  8. monitoring_app-1.1.84/deploy/entities.policy.example +34 -0
  9. monitoring_app-1.1.84/deploy/monitoring-app.service.example +28 -0
  10. monitoring_app-1.1.84/deploy/nginx.conf.example +100 -0
  11. monitoring_app-1.1.84/deploy/release.sh +601 -0
  12. monitoring_app-1.1.84/docs/DEPLOYMENT.md +416 -0
  13. monitoring_app-1.1.84/docs/USER_GUIDE.md +130 -0
  14. monitoring_app-1.1.84/pyproject.toml +86 -0
  15. monitoring_app-1.1.84/setup.cfg +4 -0
  16. monitoring_app-1.1.84/src/monitoring_app/VERSION +1 -0
  17. monitoring_app-1.1.84/src/monitoring_app/__init__.py +16 -0
  18. monitoring_app-1.1.84/src/monitoring_app/admin/__init__.py +1 -0
  19. monitoring_app-1.1.84/src/monitoring_app/admin/app.py +238 -0
  20. monitoring_app-1.1.84/src/monitoring_app/admin/audit.py +219 -0
  21. monitoring_app-1.1.84/src/monitoring_app/admin/dashboard/__init__.py +1 -0
  22. monitoring_app-1.1.84/src/monitoring_app/admin/dashboard/alert_insights.py +75 -0
  23. monitoring_app-1.1.84/src/monitoring_app/admin/dashboard/alerts.py +230 -0
  24. monitoring_app-1.1.84/src/monitoring_app/admin/dashboard/batch_insights.py +1576 -0
  25. monitoring_app-1.1.84/src/monitoring_app/admin/dashboard/log_summary.py +181 -0
  26. monitoring_app-1.1.84/src/monitoring_app/admin/deploy_ui.py +88 -0
  27. monitoring_app-1.1.84/src/monitoring_app/admin/deps.py +375 -0
  28. monitoring_app-1.1.84/src/monitoring_app/admin/entities_context.py +309 -0
  29. monitoring_app-1.1.84/src/monitoring_app/admin/entities_manager.py +150 -0
  30. monitoring_app-1.1.84/src/monitoring_app/admin/platform_users/__init__.py +1 -0
  31. monitoring_app-1.1.84/src/monitoring_app/admin/platform_users/approvals.py +222 -0
  32. monitoring_app-1.1.84/src/monitoring_app/admin/platform_users/export.py +1515 -0
  33. monitoring_app-1.1.84/src/monitoring_app/admin/platform_users/idc.py +1741 -0
  34. monitoring_app-1.1.84/src/monitoring_app/admin/platform_users/offboard.py +610 -0
  35. monitoring_app-1.1.84/src/monitoring_app/admin/platform_users/platform_api.py +956 -0
  36. monitoring_app-1.1.84/src/monitoring_app/admin/routes/__init__.py +1 -0
  37. monitoring_app-1.1.84/src/monitoring_app/admin/routes/approvals.py +183 -0
  38. monitoring_app-1.1.84/src/monitoring_app/admin/routes/auth.py +428 -0
  39. monitoring_app-1.1.84/src/monitoring_app/admin/routes/batches.py +271 -0
  40. monitoring_app-1.1.84/src/monitoring_app/admin/routes/dashboard.py +250 -0
  41. monitoring_app-1.1.84/src/monitoring_app/admin/routes/entities.py +265 -0
  42. monitoring_app-1.1.84/src/monitoring_app/admin/routes/idc_users.py +240 -0
  43. monitoring_app-1.1.84/src/monitoring_app/admin/routes/logs.py +130 -0
  44. monitoring_app-1.1.84/src/monitoring_app/admin/routes/platform_users.py +879 -0
  45. monitoring_app-1.1.84/src/monitoring_app/admin/routes/servers.py +220 -0
  46. monitoring_app-1.1.84/src/monitoring_app/admin/routes/settings.py +604 -0
  47. monitoring_app-1.1.84/src/monitoring_app/admin/routes/system.py +123 -0
  48. monitoring_app-1.1.84/src/monitoring_app/admin/routes/users.py +162 -0
  49. monitoring_app-1.1.84/src/monitoring_app/admin/security/__init__.py +1 -0
  50. monitoring_app-1.1.84/src/monitoring_app/admin/security/login.py +306 -0
  51. monitoring_app-1.1.84/src/monitoring_app/admin/security/login_errors.py +59 -0
  52. monitoring_app-1.1.84/src/monitoring_app/admin/security/saml.py +400 -0
  53. monitoring_app-1.1.84/src/monitoring_app/admin/security/users.py +523 -0
  54. monitoring_app-1.1.84/src/monitoring_app/admin/servers/__init__.py +1 -0
  55. monitoring_app-1.1.84/src/monitoring_app/admin/servers/log_analysis.py +342 -0
  56. monitoring_app-1.1.84/src/monitoring_app/admin/servers/manager.py +112 -0
  57. monitoring_app-1.1.84/src/monitoring_app/admin/servers/processes.py +405 -0
  58. monitoring_app-1.1.84/src/monitoring_app/admin/servers/registry.py +370 -0
  59. monitoring_app-1.1.84/src/monitoring_app/admin/servers/utilization.py +481 -0
  60. monitoring_app-1.1.84/src/monitoring_app/admin/servers/utilization_manager.py +142 -0
  61. monitoring_app-1.1.84/src/monitoring_app/admin/status_source.py +76 -0
  62. monitoring_app-1.1.84/src/monitoring_app/admin/ui_landing.py +35 -0
  63. monitoring_app-1.1.84/src/monitoring_app/admin_static/.base-href +1 -0
  64. monitoring_app-1.1.84/src/monitoring_app/admin_static/index.html +12 -0
  65. monitoring_app-1.1.84/src/monitoring_app/admin_static/main-ZCCHZ626.js +94 -0
  66. monitoring_app-1.1.84/src/monitoring_app/admin_static/polyfills-25SJBI4S.js +2 -0
  67. monitoring_app-1.1.84/src/monitoring_app/admin_static/styles-YEZDZ3Y6.css +1 -0
  68. monitoring_app-1.1.84/src/monitoring_app/cli.py +220 -0
  69. monitoring_app-1.1.84/src/monitoring_app/config/__init__.py +1 -0
  70. monitoring_app-1.1.84/src/monitoring_app/config/credentials.py +497 -0
  71. monitoring_app-1.1.84/src/monitoring_app/config/entities.py +337 -0
  72. monitoring_app-1.1.84/src/monitoring_app/config/env_editor.py +529 -0
  73. monitoring_app-1.1.84/src/monitoring_app/config/envfile.py +53 -0
  74. monitoring_app-1.1.84/src/monitoring_app/config/legacy.py +288 -0
  75. monitoring_app-1.1.84/src/monitoring_app/config/paths.py +82 -0
  76. monitoring_app-1.1.84/src/monitoring_app/config/policy.py +498 -0
  77. monitoring_app-1.1.84/src/monitoring_app/config/schema.py +335 -0
  78. monitoring_app-1.1.84/src/monitoring_app/config/settings.py +941 -0
  79. monitoring_app-1.1.84/src/monitoring_app/ctl.py +106 -0
  80. monitoring_app-1.1.84/src/monitoring_app/data/.env.example +146 -0
  81. monitoring_app-1.1.84/src/monitoring_app/integrations/__init__.py +1 -0
  82. monitoring_app-1.1.84/src/monitoring_app/integrations/inferyx_api.py +2052 -0
  83. monitoring_app-1.1.84/src/monitoring_app/integrations/mongodb.py +706 -0
  84. monitoring_app-1.1.84/src/monitoring_app/monitor/__init__.py +1 -0
  85. monitoring_app-1.1.84/src/monitoring_app/monitor/engine.py +3311 -0
  86. monitoring_app-1.1.84/src/monitoring_app/monitor/logs.py +333 -0
  87. monitoring_app-1.1.84/src/monitoring_app/monitor/schedule.py +236 -0
  88. monitoring_app-1.1.84/src/monitoring_app/monitor/targets.py +202 -0
  89. monitoring_app-1.1.84/src/monitoring_app/notify/__init__.py +1 -0
  90. monitoring_app-1.1.84/src/monitoring_app/notify/chat.py +201 -0
  91. monitoring_app-1.1.84/src/monitoring_app/notify/mail.py +58 -0
  92. monitoring_app-1.1.84/src/monitoring_app/service.py +239 -0
  93. monitoring_app-1.1.84/src/monitoring_app/store/__init__.py +1 -0
  94. monitoring_app-1.1.84/src/monitoring_app/store/alerts.py +519 -0
  95. monitoring_app-1.1.84/src/monitoring_app/store/approvals.py +407 -0
  96. monitoring_app-1.1.84/src/monitoring_app/store/console.py +33 -0
  97. monitoring_app-1.1.84/src/monitoring_app/store/consolidate.py +114 -0
  98. monitoring_app-1.1.84/src/monitoring_app/store/secrets.py +482 -0
  99. monitoring_app-1.1.84/src/monitoring_app/store/sqlite.py +96 -0
  100. monitoring_app-1.1.84/src/monitoring_app/version_info.py +62 -0
  101. monitoring_app-1.1.84/src/monitoring_app.egg-info/PKG-INFO +224 -0
  102. monitoring_app-1.1.84/src/monitoring_app.egg-info/SOURCES.txt +104 -0
  103. monitoring_app-1.1.84/src/monitoring_app.egg-info/dependency_links.txt +1 -0
  104. monitoring_app-1.1.84/src/monitoring_app.egg-info/entry_points.txt +6 -0
  105. monitoring_app-1.1.84/src/monitoring_app.egg-info/requires.txt +20 -0
  106. monitoring_app-1.1.84/src/monitoring_app.egg-info/top_level.txt +1 -0
@@ -0,0 +1,326 @@
1
+ # Changelog
2
+
3
+ All notable releases of **monitoring-app** (formerly `inferyx-monitoring`) on PyPI.
4
+
5
+ ## 1.1.84 — 2026-11-23 — MongoDB batch status source
6
+
7
+ First release under the name **monitoring-app** on PyPI (previously `inferyx-monitoring`, last 1.1.83). Numbered 1.1.84 so it is clearly newer than every `inferyx-monitoring` release.
8
+
9
+ - **New, optional:** `MONITORING_APP_STATUS_SOURCE=mongodb` reads schedules and runs straight from the Inferyx MongoDB (`schedule`, `scheduleexec`, `batchexec`, `batch`) instead of about one API call per batch per minute (3 queries per cycle).
10
+ - **Scheduled runs only:** a run counts when it starts within `MONITORING_APP_MONGODB_LINK_SECONDS` (60) of a schedule firing (`scheduleexec` TRIGGERED). Runs started by hand or through the API are ignored. No firing, or a firing without a run → **Missed**; a scheduled run that fails → **Failed**, with the error from `messageList` in the mail; MongoDB errors → **No data** / script failure to DevOps (never a silent switch to the API).
11
+ - **Only new failures:** the first MongoDB cycle sets its own go-live baseline (`default@mongodb`); failures from before the switch are not mailed. Each later failed scheduled run is mailed (replies in the day's thread).
12
+ - **Every schedule is monitored:** a batch with several schedules gets one row per schedule (`batch [schedule]`). (The API path still checks only the first active schedule.)
13
+ - **Credentials in the UI, encrypted:** Environment Settings → *MongoDB (batch status)*: connection string, user and password are stored encrypted in `data/config.db`; **Test connection** checks read access to the four collections. Single-server mode only.
14
+ - **Schedule parsing fixes (both sources):** MINUTES `frequencyDetail` is read as minute marks (`00,05,…,55` → every 5 min; `05,10,15,20` → at those minutes of every hour); HOURLY `frequencyDetail` lists the **hours of the day**, run at :00 (`01,02,16…23` → 01:00, 02:00, 16:00 … 23:00 — was every hour), and HOURLY without a list runs every hour at the next run's minute. Checked against Inferyx's own `nextRunTime` on real schedules.
15
+ - **One switch for the whole console:** with `mongodb`, the Scheduler (Batch Data) page, Batch Logs list and Dashboard read schedules and scheduled runs from MongoDB too, so they show exactly what the monitor alerts on (manual runs are not listed; a batch with several schedules has one row per schedule). Users, IDC, events and run log text keep using the API. Without an API token the pages still work; only run log text needs it.
16
+ - **Only live schedules are read** from MongoDB: active (`active: Y` — deleting in Inferyx sets N), not suspended (`suspend: Y`), not expired (end date passed). Others are not monitored, listed or counted.
17
+ - **"Triggered by" on Dashboard and Batch Logs:** *Scheduler* (linked to a schedule firing), *Batch user* (submitted by the application's current batch user — `application.batchuser` — without a firing, e.g. an API or pipeline call), *Manual* (anyone else). The firing stays the proof of a scheduled run: 11 of 30 applications have no batch user, and a batch user also runs batches that have no schedule.
18
+ - **Safety net:** a batch-user run that starts within a slot's grace window counts as that slot's run, so a missing firing record cannot cause a false *missed*.
19
+ - **Dashboard totals count every run** (scheduled and manual, last 24 months) so failed / passed totals are complete; live *missed* and **alerts stay scheduled-only and post-go-live**.
20
+ - **No false Missed for slots before a schedule existed:** a slot earlier than the schedule's start date or the time its current version was saved (a new schedule, or an edit to a time already past today) is not checked — monitor and Dashboard.
21
+ - **`schedule_windows` checks the latest slot:** it took the oldest slot with an open window, so with frequent schedules it lagged ~20 minutes behind (a 16:45 miss was checked after 17:05).
22
+ - **Missed for frequent schedules:** when slots are closer together than the grace (every 5 minutes, grace 5), the grace is capped to end a minute before the next slot; before, such a miss was never reported (API and MongoDB).
23
+ - Batch Logs shows a suspended schedule as **suspended** and one outside its start/end dates as **inactive** (was *missed*), matching the monitor.
24
+ - New dependency: `pymongo`.
25
+
26
+ ### User list (Platform users)
27
+
28
+ - **Inferyx sometimes answers `getAllLatest type=user` with only the token's own user** (seen on the DevOps server: 65 users, then 1, for the same request). The console now retries a much shorter answer and keeps showing the last full list instead of replacing it; the log records each short answer. Scheduled and manual **user exports** retry too and fail with a clear error rather than mailing a 1-user file. Root cause is on the Inferyx side (the admin token's user context).
29
+
30
+ ## 1.1.84 — security, structure and alert reliability
31
+
32
+ **Read "Upgrade notes — security release" in `docs/DEPLOYMENT.md` before upgrading.** After the upgrade the batch status source is `api` (as before); switch to MongoDB in Environment Settings when ready.
33
+
34
+ ### Security
35
+
36
+ - **Secrets encrypted at rest.** SMTP password, API tokens, admin API token, webhook URLs and entity tokens move from `.env` / `secrets/entities/*.token` into `data/config.db` (Fernet); batch API tokens in `alerts.db` are encrypted too. Migration is automatic on start; `.env.bak` is scrubbed. New CLI: `inferyx-monitoring secrets set|list|delete|migrate|rotate-key`.
37
+ - **Admin session key:** no built-in fallback (`dev-insecure-change-me` allowed forged admin cookies). A random key is generated when none exists.
38
+ - **SAML:** claims are read only from the signed element (XML signature wrapping fix); one assertion only; `Conditions` required; assertion replay rejected.
39
+ - **SMTP:** server certificate verified (STARTTLS / port 465), 30 s timeout, no login without TLS; mail headers stripped of CR/LF; API text HTML-escaped in alert mails.
40
+ - **Admin API:** CORS off by default (wildcard never with credentials); security headers; local login throttled per IP and email, one generic error message; `X-Forwarded-For` trusted only from a local proxy; optional `PIPELINE_ADMIN_BOOTSTRAP_EMAIL`; 500 responses no longer leak internals.
41
+ - **Server tools:** SSH host/user/key/path validated (no `-o` option injection), remote arguments quoted; log viewer refuses credential files (`.env`, keys, `*.db`, `secrets/`).
42
+ - **Admin UI:** Angular 19 → 20.3 (fixes 4 high XSS advisories; `npm audit` clean). Node 20.19+ required to build.
43
+ - **Packaging:** `requires-python >=3.10`; sdist/wheel exclude `.env*`, `*.bak`, `*.db`, keys and policies.
44
+
45
+ ### Alerts
46
+
47
+ - **Monitoring activation baseline** (per entity, monitor timezone): failures and missed starts from before go-live are not mailed; a post-activation failure in an earlier slot still is. Pre-activation runs still count as "started" (no false *missed*).
48
+ - **Isolation:** an error in one batch or entity no longer stops the whole cycle; one deduped "Batch Script Failure" mail per distinct error set (log tail inline, no full-log attachment), reset after a healthy cycle.
49
+ - **Multi-entity fixes:** alert dedupe, completed-slot and on-demand caches are scoped per entity (same batch name on two servers no longer suppresses alerts).
50
+ - **Tokens:** API mode no longer copies the default token onto every batch each cycle (it overwrote per-batch tokens); existing copies are removed.
51
+ - **SMTP circuit breaker:** after a connection failure, mail fails fast for 2 minutes (stored as Failed, retried) instead of a timeout per alert.
52
+ - **CSV:** a malformed row is skipped and logged instead of stopping all monitoring.
53
+ - Dashboard: "Queued" mail status removed — Sent / Failed only when `alerts.db` has the attempt.
54
+
55
+ ### Structure, configuration and storage cleanup
56
+
57
+ - **Layering:** core code (`config`, `monitor`, `notify`, `integrations`, `store`) no longer imports the web console. Shared modules moved out of `admin/`: `store/` (all SQLite), `config/schema.py`, `config/policy.py`, `config/paths.py`, `config/env_editor.py`, `monitor/logs.py`. The console is grouped into `admin/security`, `admin/dashboard`, `admin/platform_users`, `admin/servers`, plus `admin/routes`.
58
+ - **One purpose per database:** `alerts.db` (monitor), `config.db` (encrypted secrets + API servers/tokens), `console.db` (console users, access requests, export schedules, approvals). Existing tables are moved automatically on start (`store/consolidate.py`); `approvals.db` is merged and removed. All database files are mode 0600 (approvals.db was world-readable).
59
+ - **One name per setting:** `MONITORING_APP_HOME` (was `MONITOR_ROOT` and `WORK_DIR`), `MONITORING_APP_AUTH_POLICY` (was `ADMIN_POLICY`), `MONITORING_APP_SERVERS_POLICY` (was `UTILIZATION_POLICY`); old names still read and rewritten.
60
+ - **One place for AWS IDC settings:** `.env` (`MONITORING_APP_IDC_AWS_*`); the duplicate `auth.policy` `idc_user_access` block is migrated into `.env` and removed (the two sources had different default regions).
61
+ - **Google client secret** can be stored encrypted (`MONITORING_APP_GOOGLE_CLIENT_SECRET`); an inline value in `auth.policy` is moved into the store.
62
+ - `secrets/` and `data/` folders are restricted to the owner (0700) on start.
63
+
64
+ ### Alert fixes
65
+
66
+ - **Several runs a day** (`ExpectedStartTime=09:00,13:00`): a failure in the 13:00 run was counted in the 09:00 slot and never alerted. The current slot is now the latest one that has started, and a slot ends at the next start time that day.
67
+ - **Missed rule:** checked only after start + grace (09:00 + 5 min → from 09:05:01), then the batchexec API is tried 5 times; Missed only when all 5 answer with no record. An API outage or error is now **No data** to DevOps instead of a Missed mail to everyone (tries inside the grace window no longer count).
68
+ - **Rerun fails again in the same slot:** the newest failed run is alerted (as a reply in the thread); before, only the first failure was ever seen.
69
+ - **Monitor could hang:** the log-level filter re-read `.env` through the secret migration, which logs and re-entered the filter — a deadlock whenever `.env` held a plaintext secret. The filter now reads `.env` read-only, and the secret store no longer logs while holding its lock.
70
+ - Package metadata uses an SPDX license expression (setuptools ≥ 77), removing the build deprecation warning.
71
+ - New end-to-end alert scenario tests (`tests/test_alert_scenarios.py`) and guards against both failure classes (`tests/test_engine_guards.py`).
72
+
73
+ ### Renamed: monitoring-app
74
+
75
+ - **pip / PyPI:** `inferyx-monitoring` → `monitoring-app`. **Commands:** `monitoring-app`, `monitoring-app-service`, `monitoring-app-admin`, `monitoring-app-admin-install-ui`, `monitoring-app-ctl` (`pipeline-status-mailer` alias removed). **systemd:** `monitoring-app.service`. **Installed docs/scripts:** `.venv/share/monitoring-app/`.
76
+ - **Settings:** prefix `PIPELINE_` → `MONITORING_APP_` (same suffix). Existing `.env`, `.env.bak` and encrypted secrets are renamed automatically (values kept); `PIPELINE_*` process variables are still read during the switch. `auth.policy` `service_name: inferyx-monitoring` maps to `monitoring-app`.
77
+ - **Install folder:** `/opt/pipeline-monitor` → `/opt/monitoring-app`. `release.sh upgrade` migrates an existing server in one go (copy-then-switch): stops the old service, copies the folder, builds a fresh venv, rewrites paths in config / systemd drop-ins / nginx (`nginx -t`), renames settings, removes old units and the old pip package, cleans obsolete files, starts the new service and waits for `/api/health`. Healthy → old folder kept as `/opt/pipeline-monitor.migrated-<date>`; otherwise automatic rollback to the old install. Verified on Ubuntu 24.04 (success, rollback, `--home`). See DEPLOYMENT.md → *Switch from inferyx-monitoring*.
78
+ - Technical names: session cookies `monitoring_app_*` (admins sign in once more), nginx site `monitoring-app`, Angular project `monitoring-app-admin`. Branding ("Inferyx Monitoring") is unchanged.
79
+ - `--init-config` now also moves plaintext secrets into the encrypted store, and updates old names in `.env` comments.
80
+ - The temporary `inferyx_pipeline_monitor` import shim is removed; the Python package is `monitoring_app` only.
81
+
82
+ ### Package renamed: `monitoring_app`
83
+
84
+ - The Python package is now `monitoring_app` (was `inferyx_pipeline_monitor`). The pip name `inferyx-monitoring`, all `inferyx-monitoring*` commands, `PIPELINE_*` settings and the `inferyx-monitoring` systemd service are unchanged. A small `inferyx_pipeline_monitor` shim (`cli`, `admin.app`) forwards to the new package so a service started by an older release can relaunch its children during an upgrade.
85
+
86
+ ### Removed — CSV batch source
87
+
88
+ - The scheduler API is the only batch list. Removed: `PIPELINE_MONITOR_BATCH_SOURCE`, `PIPELINE_CSV_FILE`, `paths.csv_file`, the CSV loader and CSV-only columns, CSV token import, `batch_file.csv.example`, and the Batch Data edit / save / upload / sample endpoints. (CSV mode deleted its own file on every start, and Batch Data **Save** never stored anything.)
89
+ - **Batch Data** is now a read-only scheduler view with CSV *export*. Per-batch tokens: Entity Settings → tokens.
90
+ - Upgrade: the retired keys are removed from `.env`; a leftover `batch_file.csv` goes to `backup/` with the Token column blanked (the old `release.sh` step copied tokens in plain text). `--csv-file` is still accepted from older systemd units and ignored.
91
+
92
+ ### Alert state in SQLite
93
+
94
+ - Mail threads, last-alert time and resolved flags are stored in `alerts.db` (`alert_state`) instead of being re-parsed from `monitor.log`. Restarts and log rotation keep threads; multi-entity installs no longer lose state on restart (the log rebuild never matched entity-scoped keys).
95
+
96
+ ### Admin API split
97
+
98
+ - `admin/app.py` (≈3,900 lines) is now `app.py` (app setup, 236 lines), `deps.py` (shared auth / audit / rate limits) and `routes/<area>.py` (one router per console area). Routes, methods, auth dependencies, route order, middleware and error handlers verified identical.
99
+ - **Fix:** adding or editing a console user (`POST /api/users`) failed with 422 — its request model was defined after the route, so FastAPI treated `body` as a missing query parameter. Request models now sit above their routes; a test guards every endpoint.
100
+
101
+ ### Removed — "running too long" alert
102
+
103
+ - The **running too long** (and unused **delayed start**) alert is gone: `PIPELINE_ALERT_RUNNING`, `PIPELINE_ALERT_DELAY` and the `PIPELINE_MAIL_*_RUNNING` templates are retired and removed from existing `.env` files on upgrade. A running batch still shows as **Running** on the dashboard; `PIPELINE_POST_RUN_GRACE_MINUTES` remains as the monitoring window after the expected end.
104
+
105
+ ### Monitor efficiency and dashboard consistency
106
+
107
+ - **One bulk API call per entity per cycle** (`getAllLatest`) instead of one call per batch. Batches with their own token, batches absent from the bulk result, and bulk failures fall back to per-batch calls, so no missed alert is ever based on the bulk response alone.
108
+ - **Dashboard missed rows follow the monitor:** same go-live cutoff (activation per entity), and missed rows show the monitor's mail result (Sent / Failed).
109
+ - **Entity timezone works:** the per-entity timezone set in Entity Settings was ignored (broken import); it now applies, ahead of `PIPELINE_MONITOR_TIMEZONE`.
110
+
111
+ ### Project structure
112
+
113
+ - Standard `src/` layout. The package is grouped by purpose: `config/`, `monitor/` (the former top-level `pipeline_status_mailer.py` is now `monitor/engine.py`), `notify/`, `integrations/`, `admin/`. `release/` is now `deploy/`. Console commands and the installed `share/inferyx-monitoring/` files are unchanged.
114
+ - `pytest` runs everything (unit tests + the monitor regression suite); `make test`.
115
+
116
+ ### Schedule and batch-source fixes
117
+
118
+ - **One schedule calculator** (`schedule.py`) for monitor and dashboard. The dashboard showed weekday batches (e.g. Monday) and monthly batches as *missed* every day.
119
+ - **Monthly schedules** like `20 09:00` were treated as due every day (a bare time parsed onto today's date overwrote the day) — affected monitor alerts and the dashboard.
120
+ - **API mode:** schedules outside their `StartDate`/`EndDate` are skipped (an ended schedule could raise *missed* forever); `Minutes` schedules keep their interval for correct slot windows.
121
+ - **CSV mode:** `AvgExecutionTime` and `ExpectedDayOfMonth` columns are read (they were documented but ignored).
122
+ - **One `.env` parser** (`envfile.py`): the monitor cut values at any `#`, so a password or webhook containing `#` was truncated while the admin UI showed the full value.
123
+ - Removed duplicate legacy `/api/system/utilization*` routes (UI uses `/api/server/*`), the old log-file alert parser, and duplicated session/env helpers.
124
+
125
+ ### Cleanup
126
+
127
+ - Removed the stale `inferyx_monitoring-1.1.61/` source copy, runtime files that were committed (`.env.bak`, `data/approvals.db`, `backup/`, `offboard_pending_approvals.json`, `entities.policy`, `.inferyx-monitor-version`), and ~50 unused functions (dead dashboard "missed" recompute path, legacy OFFB-id JSON offboard approvals replaced by `approvals.db`, unused API helpers) plus unused imports.
128
+ - Removed unused dev scripts (`check-offboard-api.sh`, `keep-admin-local.sh`, `run_idc_smoke.sh`, `sync-admin-ui-local.sh`) and the orphaned Console Modules UI page (its route redirects to Environment settings).
129
+
130
+ ## 1.1.76
131
+
132
+ ### Monitor batch list — API by default (configurable)
133
+
134
+ - **Default:** ``PIPELINE_MONITOR_BATCH_SOURCE=api`` — the monitor loads scheduled batches from the **Inferyx scheduler API** (same as Admin Batch Data). **No CSV required** for new batches; they appear on the next poll after scheduling.
135
+ - **Legacy:** Set ``PIPELINE_MONITOR_BATCH_SOURCE=csv`` to use ``PIPELINE_CSV_FILE`` or ``<work>/batch_file.csv`` only.
136
+ - **Fix:** Single ``batchexec_record_name`` implementation (top-level ``name`` wins over ``dependsOn`` parent) for dashboard grouping.
137
+
138
+ ## 1.1.75
139
+
140
+ ### Fix — alert batch name matches batchexec (not wrong scheduler row)
141
+
142
+ - **Root cause:** ``getAllLatest`` could return another batch's batchexec in the same slot; alerts/emails used the **scheduler CSV name** while the **execution UUID** belonged to a different batch (e.g. mail for ``batch_dsa_ews_*`` but failure on ``batch_dsa_adm_view_*``).
143
+ - **Monitor:** Filter batchexec rows by ``name`` / ``displayName``; skip failed alerts when exec name ≠ scheduled row; store/mail using the execution batch name.
144
+ - **Dashboard:** Reconcile alert table names from status API by ``exec_uuid``; **Alert mail** column on Status (Sent / Failed / Queued) joined from ``alerts.db``.
145
+
146
+ ## 1.1.73
147
+
148
+ ### Alert dashboard — mail delivery status and failed log
149
+
150
+ - **SQLite:** ``mail_error`` column stores SMTP failure text when ``mail_sent=0`` (multiple failures per batch still one row per occurrence).
151
+ - **Dashboard:** Alert table shows **Mail** — Sent / Failed (click Failed for error text) / — for execution-only rows.
152
+ - **Failed log** button opens Batch Logs for that batchexec (uuid + version).
153
+
154
+ ## 1.1.72
155
+
156
+ PyPI release packaging **1.1.71** alert fixes (failure email regression, schedule slots, ``mail_sent`` in SQLite). Use ``inferyx-monitoring==1.1.72`` on servers.
157
+
158
+ ## 1.1.71
159
+
160
+ ### Alert SQLite — record every attempt; dedupe only after mail succeeds
161
+
162
+ - **``alerts.db``** adds ``mail_sent`` (existing DBs migrated automatically). Each **failed / missed / running / no_data** alert writes a row after the SMTP attempt: ``mail_sent=1`` when email succeeded, ``mail_sent=0`` when it failed.
163
+ - **Dedupe** (in-memory + SQLite) applies only to ``mail_sent=1``, so a mail failure is stored for the dashboard but **email retries** on the next monitor loop.
164
+ - Thread / ``alerted_occurrences`` state updates only when mail succeeds (same for all issue types).
165
+
166
+ ## 1.1.70
167
+
168
+ ### Fix — scheduled failure emails fire again
169
+
170
+ - **Regression (1.1.68):** Writing failed runs to ``alerts.db`` *before* the mail dedupe step made the monitor treat every scheduled failure as already alerted, so **no failure emails** were sent (dashboard could still show failures via status merge).
171
+ - **Schedule:** When Inferyx ``nextRunTime`` points at the *next* slot (e.g. 16:00 while the 04:00 run failed), the monitor now keeps checking the **prior slot** until that slot's monitoring window ends — required for twice-daily and similar schedules.
172
+
173
+ **Multiple failures per day:** With defaults ``PIPELINE_ALERT_ONCE_PER_DAY_ALL_SCENARIOS=true`` and ``PIPELINE_ALERT_REPLY_TO_THREAD=true``, each **new** failed execution (new batchexec version) same day sends a **reply** in the thread. For a separate email per failure, set ``PIPELINE_ALERT_REPLY_TO_THREAD=false`` and ``PIPELINE_ALERT_ONCE_PER_DAY_ALL_SCENARIOS=false``.
174
+
175
+ If you ran **1.1.68** and failures never emailed, upgrade and restart; optional cleanup of ``alerts.db`` rows that were inserted without a matching sent mail.
176
+
177
+ ## 1.1.69
178
+
179
+ ### Alert mail — optional execution log
180
+
181
+ - New ``PIPELINE_ALERT_INCLUDE_LOG`` (default **true**). Set **false** to omit the execution log block from Failed / Missed / Running alert emails and skip log API fetches. ``PIPELINE_ALERT_LOG_LINES`` applies only when include is on.
182
+
183
+ ## 1.1.68
184
+
185
+ ### Alert dashboard — all scheduled failures
186
+
187
+ - **Dashboard:** Alert table merges **every failed execution** from the status API for batches that are on the **scheduler**, **not suspended**, and **not OnDemand** (matches Status failed rows you expect to monitor).
188
+ - **Monitor:** Each detected **scheduled** failure was saved to ``alerts.db`` before email dedupe (fixed in **1.1.70** — that ordering suppressed failure emails).
189
+ - **Email:** Scheduled failures send when ``PIPELINE_ALERTS_ENABLED`` and ``PIPELINE_ALERT_FAILED`` are true (OnDemand unchanged — needs ``PIPELINE_ALERT_ONDEMAND``).
190
+
191
+ ## 1.1.67
192
+
193
+ ### Fix — Status times match portal; OnDemand alert gate
194
+
195
+ - **Execution times:** Default ``PIPELINE_API_EPOCH_WALL_CLOCK=false`` — epoch ``createdOn`` on status stages converts UTC→IST (aligns Status table Start/End with Inferyx Batch Results).
196
+ - **OnDemand alerts:** New ``PIPELINE_ALERT_ONDEMAND`` (default **false**). Failed/no_data emails for OnDemand only when this is **true** plus ``PIPELINE_ALERTS_ENABLED`` and the per-type toggle (e.g. ``PIPELINE_ALERT_FAILED``).
197
+ - **Dashboard:** Help text and API meta clarify Status (API executions + live missed) vs Alert summary (emailed rows only).
198
+
199
+ ## 1.1.65
200
+
201
+ ### Fix — Scheduler times match Inferyx portal
202
+
203
+ - **nextRunTime** strings with ``+0000`` / GMT are parsed as **UTC instants** and shown in the monitor timezone (e.g. API face ``10:05 +0000`` → **15:35 IST**, same as portal Effective / Next Run).
204
+ - **Expected Start Time** for Daily (and similar) is taken from that parsed **nextRunTime**, not a stale ``frequencyDetail`` hour (``10`` → 10:05 while portal is 15:35).
205
+ - Scheduler API responses format **Next Run Time** for the Batch Data / Scheduler UI.
206
+
207
+ ## 1.1.64
208
+
209
+ ### Fix — missed alerts and dashboard times
210
+
211
+ - **Missed dedupe:** Occurrence keys use the **schedule slot** (`batch|2026-11-01T10:05`), not a stale batchexec UUID/version — stops multiple missed emails/rows for one daily slot.
212
+ - **Alert times:** SQLite and the dashboard show **expected start (IST)** for missed alerts, aligned with the Status table and Scheduler — not the time the email was sent.
213
+ - **UI:** Alert period tabs labeled **Today / This week / …** (calendar windows, not batch Frequency).
214
+
215
+ ## 1.1.62
216
+
217
+ ### Fix — service crash after upgrade (1.1.57–1.1.61)
218
+
219
+ - **`settings.py`:** Post-upgrade `.env` migration no longer uses `logging` (fixes `NameError` crash loop on `inferyx-monitoring.service` startup).
220
+ - **`service.py`:** Logs merged `.env` keys after migration (logger is already configured there).
221
+ - **`release.sh`:** Creates `$IM_HOME/release.sh` → `.venv/share/inferyx-monitoring/release.sh` on install/upgrade so upgrades from `/opt/pipeline-monitor` work.
222
+
223
+ ### Upgrade (Devops-server)
224
+
225
+ ```bash
226
+ export IM_HOME=/opt/pipeline-monitor
227
+ export VERSION=1.1.62
228
+ sudo -u inferyx "$IM_HOME/.venv/bin/pip" install --upgrade "inferyx-monitoring==${VERSION}"
229
+ sudo bash "$IM_HOME/.venv/share/inferyx-monitoring/release.sh" upgrade --skip-pip
230
+ curl -sS "http://127.0.0.1:8090/api/health"
231
+ ```
232
+
233
+ Health should report `"version":"1.1.62"`. After upgrade, you can also run: `sudo bash "$IM_HOME/release.sh" upgrade --skip-pip`.
234
+
235
+ ## 1.0.56
236
+
237
+ ### Breaking / config migration
238
+
239
+ - **API auth moved to CSV:** each batch row requires a **`Token`** column. Removed global `PIPELINE_API_TOKEN` from `.env`.
240
+ - Keep **`PIPELINE_API_TOKEN_HEADER`** in `.env` (e.g. `token` or `Authorization`).
241
+ - After upgrade, fill `Token` for every Active batch (Admin UI → Batch Data, or edit `batch_file.csv`).
242
+ - Optional: delete unused `PIPELINE_API_TOKEN=...` from `.env`.
243
+
244
+ ### Alert enable / disable (`.env`)
245
+
246
+ Global toggles (Application Settings / `.env`), default `true`:
247
+
248
+ | Variable | Controls |
249
+ |----------|----------|
250
+ | `PIPELINE_ALERT_MISSED` | Did not start |
251
+ | `PIPELINE_ALERT_FAILED` | Failed status |
252
+ | `PIPELINE_ALERT_RUNNING` | Running too long / stuck |
253
+ | `PIPELINE_ALERT_NO_DATA` | API / auth lookup failure |
254
+
255
+ These are **not** CSV columns. Upgrade merges the new keys into existing `.env` files.
256
+
257
+ ### Batch CSV columns
258
+
259
+ ```text
260
+ Name, Frequency, ExpectedStartTime, AvgExecutionTime, ExpectedDayOfMonth, Token, Status
261
+ ```
262
+
263
+ `Status=Active|Suspended` still controls whether a batch is monitored.
264
+
265
+ ### Admin UI
266
+
267
+ - Frequency dropdown; time pickers for start / avg duration; day-of-month select
268
+ - Per-batch Token field (masked in view mode)
269
+ - Light / dark theme toggle in header
270
+
271
+ ### Upgrade notes
272
+
273
+ ```bash
274
+ export VERSION=1.0.56
275
+ export IM_HOME=/opt/pipeline-monitor
276
+ sudo -u inferyx "$IM_HOME/.venv/bin/pip" install --upgrade "inferyx-monitoring==${VERSION}"
277
+ sudo bash "$IM_HOME/.venv/share/inferyx-monitoring/release.sh" upgrade --skip-pip
278
+ ```
279
+
280
+ Then:
281
+
282
+ 1. Confirm `.env` has `PIPELINE_API_TOKEN_HEADER` and the four `PIPELINE_ALERT_*` keys
283
+ 2. Add **`Token`** values in `batch_file.csv` (migrate also adds the column if missing)
284
+ 3. Restart is done by `release.sh upgrade` unless you used `--no-restart`
285
+
286
+ ## 1.0.50
287
+
288
+ - Service control: `inferyx-monitoring start|stop|restart|status|logs` and `inferyx-monitoring-ctl`
289
+ - Batch Data: CSV upload (column validation) and download
290
+ - Fixed nginx example for `/monitoring/admin/` (internal SPA fallback; no `@named` location)
291
+ - Single server script: `release.sh install|upgrade --skip-pip` (in PyPI wheel)
292
+ - Single build script: `scripts/build.sh` (not in wheel)
293
+ - One auth.policy template: `release/auth.policy.example` (local + server)
294
+ - Single log file: `logs/monitor.log`
295
+
296
+ ## 1.0.49
297
+
298
+ - **Batch Data:** upload CSV (validates columns + rows, replaces `batch_file.csv`); download current data as CSV
299
+
300
+ ## 1.0.48
301
+
302
+ - **Project layout:** `scripts/build.sh`, `release/release.sh` (no separate development/ folder)
303
+ - **Single log file:** `$IM_HOME/logs/monitor.log` for monitor output and admin audit (JSON lines)
304
+ - **Single `.env` template:** `inferyx_pipeline_monitor/data/.env.example` only
305
+
306
+ ## 1.0.47
307
+
308
+ - Single install root `/opt/pipeline-monitor/` (no `/etc/pipeline-monitor`, no `/var/www/`)
309
+
310
+ ## 1.0.46
311
+
312
+ - Service supervisor: admin API stays up when monitor child exits; monitor auto-restarts every 10s
313
+
314
+ ## 1.0.45
315
+
316
+ - Admin UI API base path fix: `/monitoring/api` (nginx-compatible)
317
+ - Python 3.9 compatibility (`from __future__ import annotations`)
318
+
319
+ ## 1.0.44
320
+
321
+ - Unified PyPI package: monitor + admin API + bundled UI
322
+ - Production install/upgrade from PyPI
323
+
324
+ ## Earlier
325
+
326
+ See git history for versions 1.0.15–1.0.43 (admin UI, Google SSO, email templates, chat alerts).
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2026 Inferyx. All rights reserved.
2
+
3
+ Proprietary software. Unauthorized copying, distribution, or use is prohibited
4
+ unless agreed in writing with Inferyx.
5
+
6
+ For open-source release, replace this file with your chosen license (e.g. MIT, Apache-2.0)
7
+ before publishing to public PyPI.
@@ -0,0 +1,48 @@
1
+ # What ships in the PyPI sdist. See docs/DEVELOPER.md → "What goes where".
2
+ # The wheel content is defined in pyproject.toml ([tool.setuptools.*]).
3
+ # Order matters: later lines override earlier ones, so excludes come first and
4
+ # the explicit includes come last.
5
+
6
+ # ── 1. Source-only (git repo, not pip) ──────────────────────────────────────
7
+ prune admin-ui
8
+ prune scripts
9
+ prune tests
10
+ prune docs
11
+ prune dev
12
+ prune package
13
+ prune mail_preview
14
+ prune dist
15
+ prune build
16
+ prune data
17
+ prune logs
18
+ prune secrets
19
+ prune backup
20
+ exclude Makefile
21
+
22
+ # ── 2. Never ship secrets or runtime state, wherever they appear ────────────
23
+ global-exclude .env
24
+ global-exclude .env.*
25
+ global-exclude *.bak
26
+ global-exclude *.db
27
+ global-exclude *.db-wal
28
+ global-exclude *.db-shm
29
+ global-exclude *.key
30
+ global-exclude *.pem
31
+ global-exclude *.log
32
+ global-exclude *.policy
33
+ global-exclude batch_file.csv
34
+ global-exclude batch.csv
35
+ global-exclude jfl_batch.csv
36
+ global-exclude offboard_pending_approvals.json
37
+ global-exclude *.pyc
38
+
39
+ # ── 3. What the package needs (applied last) ────────────────────────────────
40
+ include README.md
41
+ include VERSION
42
+ include LICENSE
43
+ include CHANGELOG.md
44
+ include docs/DEPLOYMENT.md
45
+ include docs/USER_GUIDE.md
46
+ include src/monitoring_app/data/.env.example
47
+ recursive-include deploy *.example *.sh
48
+ recursive-include src/monitoring_app/admin_static *
@@ -0,0 +1,224 @@
1
+ Metadata-Version: 2.4
2
+ Name: monitoring-app
3
+ Version: 1.1.84
4
+ Summary: Monitor batch pipelines via API and email alerts — install and deploy on Linux servers from PyPI
5
+ Author-email: Inferyx DevOps <devops@inferyx.com>
6
+ License-Expression: LicenseRef-Proprietary
7
+ Keywords: batch,monitoring,pipeline,email,inferyx
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: System Administrators
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Topic :: System :: Monitoring
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: openpyxl>=3.1.0
20
+ Requires-Dist: pandas>=2.0.0
21
+ Requires-Dist: requests>=2.31.0
22
+ Requires-Dist: python-dateutil>=2.8.2
23
+ Requires-Dist: fastapi>=0.110.0
24
+ Requires-Dist: python-multipart>=0.0.9
25
+ Requires-Dist: uvicorn[standard]>=0.27.0
26
+ Requires-Dist: pydantic>=2.0.0
27
+ Requires-Dist: cryptography>=42.0.0
28
+ Requires-Dist: lxml>=5.0.0
29
+ Requires-Dist: signxml>=3.2.0
30
+ Requires-Dist: boto3>=1.34.0
31
+ Requires-Dist: pymongo<5,>=4.6
32
+ Provides-Extra: admin
33
+ Provides-Extra: dev
34
+ Requires-Dist: build; extra == "dev"
35
+ Requires-Dist: twine; extra == "dev"
36
+ Requires-Dist: check-manifest; extra == "dev"
37
+ Dynamic: license-file
38
+
39
+ # monitoring-app
40
+
41
+ Batch monitoring for the Inferyx platform: email (and Teams / Google Chat) alerts
42
+ when a scheduled batch **fails** or **does not start**, plus a web console with a
43
+ dashboard, schedules, batch logs, settings and user management.
44
+
45
+ | | |
46
+ |---|---|
47
+ | **Install directory** | `/opt/monitoring-app` |
48
+ | **Console** | `https://<your-host>/monitoring/admin/` (behind nginx) |
49
+ | **Service** | `monitoring-app` (systemd) |
50
+ | **Guides shipped with the package** | `/opt/monitoring-app/.venv/share/monitoring-app/` — `DEPLOYMENT.md` (install, upgrade, rollback, security, MongoDB), `USER_GUIDE.md` (alerts and console), `CHANGELOG.md` |
51
+
52
+ ---
53
+
54
+ ## What it does
55
+
56
+ - Reads the schedules from Inferyx and checks every run against its schedule, every minute.
57
+ - **Failed** — a scheduled run ends in a failed stage → mail with the error reason.
58
+ - **Missed** — no run was created for a scheduled time: after start time + grace
59
+ (default 5 min) the monitor checks 5 times; only then is it Missed.
60
+ - **No data** — Inferyx could not be reached → mail to DevOps only (never reported as Missed).
61
+ - One mail per occurrence; follow-ups arrive as replies in the same thread. Failures from
62
+ before the monitor was switched on are never mailed.
63
+ - Every alert is stored and shown in the console with its mail result.
64
+
65
+ **Batch status source** (Environment Settings): `api` (Inferyx REST API, default) or
66
+ `mongodb` (reads the Inferyx MongoDB directly, read-only). With MongoDB only runs
67
+ started **by the scheduler** are alerted — runs started by hand are ignored — and
68
+ suspended, deleted and expired schedules are not monitored. Credentials are entered
69
+ in the console and stored encrypted.
70
+
71
+ ---
72
+
73
+ ## Prerequisites
74
+
75
+ | Requirement | Notes |
76
+ |-------------|-------|
77
+ | **OS** | Ubuntu 22.04+ (or Debian with `apt`) |
78
+ | **Python** | 3.10+ (`python3`, `python3-venv`) |
79
+ | **nginx** | Reverse proxy for `/monitoring/admin/` and `/monitoring/api/` |
80
+ | **Network** | SMTP; the Inferyx API; optional: Inferyx MongoDB, Teams / Google Chat webhooks, Google OAuth, AWS IAM Identity Center |
81
+
82
+ ---
83
+
84
+ ## Install
85
+
86
+ ```bash
87
+ export IM_HOME=/opt/monitoring-app
88
+ sudo mkdir -p "$IM_HOME"
89
+ sudo useradd --system --home-dir "$IM_HOME" --shell /usr/sbin/nologin inferyx 2>/dev/null || true
90
+
91
+ sudo -u inferyx python3 -m venv "$IM_HOME/.venv"
92
+ sudo -u inferyx "$IM_HOME/.venv/bin/pip" install --upgrade pip
93
+ sudo -u inferyx "$IM_HOME/.venv/bin/pip" install monitoring-app
94
+
95
+ sudo bash "$IM_HOME/.venv/share/monitoring-app/release.sh" install --skip-pip
96
+ ```
97
+
98
+ Pin a version with `pip install "monitoring-app==1.1.84"`, or install a local wheel:
99
+ `pip install /path/to/monitoring_app-1.1.84-py3-none-any.whl`.
100
+
101
+ The install script creates:
102
+
103
+ | Path | Purpose |
104
+ |------|---------|
105
+ | `.env` | SMTP host, Inferyx API URL, alert settings — **no secret values** |
106
+ | `auth.policy` | Console sign-in (local, Google, AWS IAM Identity Center), paths |
107
+ | `secrets/` | `master.key` (encryption key), `session_secret` — owner-only |
108
+ | `data/` | `alerts.db` (alerts), `config.db` (encrypted secrets), `console.db` (users, approvals) |
109
+ | `www/` | Console files |
110
+ | `logs/` | Monitor log |
111
+
112
+ ### Configure
113
+
114
+ 1. **`.env`** — `MONITORING_APP_SMTP_HOST`, `_SMTP_USERNAME`, `_MAIL_TO`, `_DEVOPS_EMAIL`,
115
+ `_API_BASE_URL`, `_API_TOKEN_HEADER`.
116
+ 2. **Secrets** — stored encrypted, never in a file:
117
+
118
+ ```bash
119
+ CLI=/opt/monitoring-app/.venv/bin/monitoring-app
120
+ sudo -u inferyx $CLI secrets set MONITORING_APP_SMTP_PASSWORD --work-dir /opt/monitoring-app
121
+ sudo -u inferyx $CLI secrets set MONITORING_APP_API_TOKEN --work-dir /opt/monitoring-app
122
+ ```
123
+
124
+ **Back up `secrets/master.key` separately** — stored secrets cannot be read without it.
125
+ 3. **`auth.policy`** — `ui.public_base_url` and the sign-in methods. Set
126
+ `MONITORING_APP_ADMIN_BOOTSTRAP_EMAIL` for the first admin before the console is reachable.
127
+ 4. **nginx**:
128
+
129
+ ```bash
130
+ sudo cp /opt/monitoring-app/.venv/share/monitoring-app/nginx.conf.example /etc/nginx/sites-available/monitoring-app
131
+ sudo ln -sf /etc/nginx/sites-available/monitoring-app /etc/nginx/sites-enabled/
132
+ sudo nginx -t && sudo systemctl reload nginx
133
+ ```
134
+
135
+ Afterwards, settings can be changed in the console (**Environment Settings**,
136
+ **Application Settings**); changes apply within one check, no restart needed.
137
+
138
+ ### Verify
139
+
140
+ ```bash
141
+ sudo systemctl status monitoring-app
142
+ curl -s http://127.0.0.1:8090/api/health
143
+ ```
144
+
145
+ ---
146
+
147
+ ## Upgrade
148
+
149
+ ```bash
150
+ sudo -u inferyx /opt/monitoring-app/.venv/bin/pip install --upgrade monitoring-app
151
+ sudo bash /opt/monitoring-app/.venv/share/monitoring-app/release.sh upgrade --skip-pip
152
+ ```
153
+
154
+ The upgrade deploys the new console, adds new settings (existing values are kept),
155
+ removes retired ones, updates the service and restarts it. If the new service does not
156
+ answer its health check, it **rolls back** automatically.
157
+
158
+ ### Switching from `inferyx-monitoring` (`/opt/pipeline-monitor`)
159
+
160
+ The package was renamed from `inferyx-monitoring` to `monitoring-app`. On an old server,
161
+ put the new package into the **old** virtualenv (only to get the new upgrade script) and
162
+ run the upgrade — it moves the installation to `/opt/monitoring-app` in one step:
163
+
164
+ ```bash
165
+ OLD=/opt/pipeline-monitor
166
+ sudo -u inferyx "$OLD/.venv/bin/pip" install monitoring-app
167
+ sudo bash "$OLD/.venv/share/monitoring-app/release.sh" upgrade --skip-pip
168
+ ```
169
+
170
+ Settings `PIPELINE_*` become `MONITORING_APP_*` (values kept), plain-text secrets move
171
+ into the encrypted store, paths in config / systemd / nginx are rewritten, and the old
172
+ folder is kept as `/opt/pipeline-monitor.migrated-<date>`. Details: `DEPLOYMENT.md`.
173
+
174
+ ---
175
+
176
+ ## Using MongoDB as the batch status source (optional)
177
+
178
+ 1. Create a **read-only** MongoDB user with `find` on `schedule`, `scheduleexec`,
179
+ `batchexec`, `batch` and `application`, and the two indexes — commands in `DEPLOYMENT.md`.
180
+ 2. Console → **Environment Settings → MongoDB (batch status)**: connection string, user,
181
+ password (stored encrypted), database (`framework`) → Save → **Test connection**.
182
+ 3. Set **Batch Status Source** to `mongodb`. Only failures after this moment are mailed.
183
+ 4. To go back, set it to `api`.
184
+
185
+ ---
186
+
187
+ ## Alert settings
188
+
189
+ | Setting | Default | Meaning |
190
+ |---------|---------|---------|
191
+ | `MONITORING_APP_CHECK_MODE` | `full_window` | `full_window` checks through the whole run (recommended); `schedule_windows` only at start and expected end |
192
+ | `MONITORING_APP_SCHEDULE_GRACE_MINUTES` | `5` | Minutes after the scheduled time before a run counts as missed |
193
+ | `MONITORING_APP_ALERT_FAILED` / `_MISSED` / `_NO_DATA` | `true` | Switch each alert type on or off |
194
+ | `MONITORING_APP_ALERT_ONCE_PER_DAY_ALL_SCENARIOS` | `true` | One new mail thread per issue per day |
195
+ | `MONITORING_APP_ALERT_REPLY_TO_THREAD` | `true` | Follow-ups as replies in the same thread |
196
+ | `MONITORING_APP_LOG_RETENTION_DAYS` | `30` | Keep rotated monitor logs for N days |
197
+
198
+ Test the mail setup: `sudo -u inferyx /opt/monitoring-app/.venv/bin/monitoring-app --test-mail-thread`
199
+
200
+ ---
201
+
202
+ ## Troubleshooting
203
+
204
+ | Symptom | Fix |
205
+ |---------|-----|
206
+ | Service restarts in a loop | `sudo journalctl -u monitoring-app -n 50` — usually a missing `.env` value |
207
+ | Console shows "Unavailable" | `curl http://127.0.0.1:8090/api/health`; check nginx with `nginx.conf.example` |
208
+ | **No data** alerts | Inferyx API unreachable or token expired — `monitoring-app secrets set MONITORING_APP_API_TOKEN` |
209
+ | **Missed** although the batch ran | The run was started by hand, not by the scheduler (MongoDB source) — check the Inferyx scheduler |
210
+ | No mails at all | Environment Settings → SMTP; the console's Alert mail column shows the error |
211
+ | MongoDB test fails | Network to MongoDB, user / password / auth database, TLS settings |
212
+
213
+ ---
214
+
215
+ ## Service commands
216
+
217
+ ```bash
218
+ sudo systemctl restart monitoring-app
219
+ sudo systemctl status monitoring-app
220
+ sudo journalctl -u monitoring-app -f
221
+
222
+ sudo bash /opt/monitoring-app/.venv/share/monitoring-app/release.sh uninstall --skip-pip # keep config
223
+ sudo bash /opt/monitoring-app/.venv/share/monitoring-app/release.sh uninstall --purge --skip-pip # remove everything
224
+ ```