Repository navigation
feat: log aggregation and conditional alert rules - #11
Merged
Merged
Conversation
Introduces per-job AlertRule configuration with four condition types:
http_status_gte, duration_ms_gte, response_body_contains and
consecutive_failures_gte. Rules are evaluated after every execution
(both inline and via Celery worker) and create Alerts with configurable
severity when triggered.
- AlertRule model with CASCADE FK to jobs and workspace isolation
- Alembic migration c3d4e5f6a7b8 creates the alert_rules table
- CRUD API under /api/jobs/{job_id}/alert-rules (operator required)
- evaluate_alert_rules() in http_runner; Celery worker wired post-retry
- React section in JobDetailPage with create form, toggle and delete
- RBAC: viewers read-only; operators manage rules
- i18n in English and Portuguese
- 7 backend integration tests; 1 frontend component test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Adds two independent features to AutoFlowOps:
Changes
Log Aggregation
structlogwith context propagation throughcontextvarsLOG_SINK,LOKI_URL,ELASTICSEARCH_URL)service,env,job_id,execution_id,workspace_iddocker-compose.observability.ymlwith Loki + Promtail stack for local developmentdocs/log-aggregation.md: label schema, sink configuration, local setup and production guidanceConditional Alert Rules
AlertRulemodel with CASCADE FK tojobs, workspace isolation via SET NULL FK toworkspacesc3d4e5f6a7b8creates thealert_rulestable with index onjob_idhttp_status_gte,duration_ms_gte,response_body_contains,consecutive_failures_gteGET|POST /api/jobs/{job_id}/alert-rulesandPATCH|DELETE /api/jobs/{job_id}/alert-rules/{rule_id}require_operator)evaluate_alert_rules()inhttp_runner.py; Celery worker wired post-retry to avoid premature alerts during retrying stateJobDetailPagewith create form, inline toggle and delete; operators-only write actionslog_action()Test Plan
uv run pytest— 260 backend tests pass (7 new alert rule tests, 3 new notification tests)npm testinfrontend/— 76 frontend tests pass (1 newJobDetailPagetest)npx tsc --noEmitinfrontend/— no TypeScript errorsuv run ruff check backend/— no linting errorsalembic upgrade headLOG_SINK=lokiandLOKI_URL=http://localhost:3100— verify structured logs reach LokiNotes
stdout(existing behavior)consecutive_failures_gtequeries the last 50 completed executions to determine the streakSecurity Checklist
.env.productionis not trackedgit push --force, no history rewrite, no--no-verifybypass