Skip to content

Add Redis service layer and Elasticsearch log indexing/search; update config and monitoring APIs#77

Merged
fuzziecoder merged 2 commits intocodex/fix-remaining-issues-and-raise-prfrom
codex/implement-elasticsearch-for-logs-and-analytics
Feb 24, 2026
Merged

Add Redis service layer and Elasticsearch log indexing/search; update config and monitoring APIs#77
fuzziecoder merged 2 commits intocodex/fix-remaining-issues-and-raise-prfrom
codex/implement-elasticsearch-for-logs-and-analytics

Conversation

@fuzziecoder
Copy link
Copy Markdown
Owner

@fuzziecoder fuzziecoder commented Feb 24, 2026

Motivation

  • Provide fast execution log search and analytics and add Redis-backed session, rate-limit, and job-queue support to improve caching and background processing.
  • Ensure observability and operational health insights by indexing execution logs into Elasticsearch while keeping DB-first persistence and graceful fallbacks when services are unavailable.

Description

  • Add Redis session/rate-limit/job-queue and Elasticsearch connection/index settings to pipeline/backend/config.py, add elasticsearch to pipeline/backend/requirements.txt, and register an elasticsearch service in pipeline/docker-compose.yml.
  • Implement an async Elasticsearch manager in pipeline/backend/core/elasticsearch_client.py that initializes the client, ensures an execution-log index, exposes index_execution_log and search_logs, and integrates with app lifecycle and health checks.
  • Add a Redis service layer in pipeline/backend/core/redis_services.py with set_session, get_session, check_rate_limit, enqueue_job, and dequeue_job, and expose the Redis client via a client property on RedisStateManager for specialized operations.
  • Extend monitoring APIs in pipeline/backend/api/routes/monitoring.py with endpoints for log search, session cache set/get, rate-limit checks, and background job enqueue/dequeue, and add best-effort async Elasticsearch indexing of logs in pipeline/backend/db/crud.py.

Testing

  • Ran python -m compileall pipeline/backend to validate code compiles successfully, which completed without errors.
  • Ran pytest -q pipeline/backend/tests/test_monitoring_engine.py, which passed (1 passed).

Codex Task


Open with Devin

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
flexi-roaster Ready Ready Preview, Comment Feb 24, 2026 2:45pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 24, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/implement-elasticsearch-for-logs-and-analytics

Comment @coderabbitai help to get the list of available commands and usage tips.

@fuzziecoder fuzziecoder merged commit a467c0d into codex/fix-remaining-issues-and-raise-pr Feb 24, 2026
6 of 7 checks passed
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 7 additional findings in Devin Review.

Open in Devin Review

}

response = await self._client.search(index=settings.ELASTICSEARCH_LOGS_INDEX, body=body)
return [hit.get("_source", {}) for hit in response.get("hits", {}).get("hits", [])]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 response.get() fails on ObjectApiResponse in elasticsearch-py 8.x

In pipeline/backend/core/elasticsearch_client.py:143, the code calls response.get("hits", {}).get("hits", []) on the return value of self._client.search(). In elasticsearch-py 8.15.1, search() returns an ObjectApiResponse, which does not implement a .get() method. Its __getattr__ tries self.body["get"] — looking up "get" as a key in the response dict (not as a method) — which raises KeyError, converted to AttributeError.

Root Cause and Impact

ObjectApiResponse provides __getitem__ (delegating to self.body[item]) and __getattr__ (also delegating to self.body[item]), but it does not inherit from dict or collections.abc.Mapping, so the dict .get() method is not available.

When response.get("hits", {}) is called:

  1. Python looks up get on the ObjectApiResponse class hierarchy — not found
  2. Falls back to __getattr__("get")
  3. __getattr__ does self.body["get"] where body is {"hits": {...}, "took": ..., ...}
  4. "get" is not a key in the response body → KeyError → re-raised as AttributeError

The correct approach is response["hits"]["hits"] or response.body.get("hits", {}).get("hits", []).

Impact: Every call to search_logs() — including the /monitoring/logs/search API endpoint — will crash with an AttributeError, making log search completely non-functional.

Suggested change
return [hit.get("_source", {}) for hit in response.get("hits", {}).get("hits", [])]
return [hit.get("_source", {}) for hit in response["hits"]["hits"]]
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant