Skip to content
apscotPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Self-Healing Log Analyzer

A microservices platform that watches your application logs, detects errors, uses AI to diagnose them, creates incident tickets, and automatically opens GitHub pull requests with suggested fixes — end to end, without human intervention.


How It Works

Error fires in app
      │
      ▼
LogForwarderAppender (Logback)
      │  HTTP POST
      ▼
log-monitor ──── filters ERROR level ────► alert-service ──── persists alert
                                                  │
                                                  │ async notify
                                                  ▼
                                            orchestrator
                                           /            \
                                    AI mode           Human mode
                                       │               (log only)
                              ┌────────┘
                              │  analyze
                              ▼
                          ai-service (RAG + GPT-4o)
                              │  10s delay
                              ▼
                         ticket-service (create ticket)
                              │  10s delay
                              ▼
                         github-service (create branch → commit → open PR)
                              │
                              ▼
                         ticket updated with PR URL

The dashboard auto-refreshes, shows live counts, and fires toast notifications when a new alert, ticket, or PR appears.


Services

Service Port Role
faulty-app 8081 Demo app with simulated error endpoints
log-monitor 8082 Ingests logs, filters ERRORs, forwards to alert-service
alert-service 8083 Persists alerts, notifies orchestrator
ticket-service 8084 Persists tickets with AI suggestions and PR URLs
orchestrator 8085 Coordinates the full AI flow or human mode
ai-service 8086 RAG-powered GPT-4o analysis + token tracking
github-service 8087 Creates branches, commits fix files, opens PRs
frontend 8080 Live dashboard (Thymeleaf + HTMX)
grafana 3000 Log dashboards (admin / admin)
loki 3100 Log storage

Prerequisites

  • Docker + Docker Compose
  • OpenAI API key
  • GitHub personal access token (with repo scope)
  • A GitHub repository to receive automated PRs

Setup

1. Clone the repo

git clone https://github.com/your-org/shTool.git
cd shTool

2. Create a .env file in the project root

OPENAI_API_KEY=sk-...
GITHUB_TOKEN=ghp_...
GITHUB_REPO=your-org/your-repo

Optional overrides:

CHAT_MODEL=gpt-4o
EMBEDDING_MODEL=text-embedding-ada-002
GITHUB_BASE_BRANCH=master
AI_ENABLED=true

3. Start everything

docker compose up --build

Usage

Trigger a simulated error

# NullPointerException
curl http://localhost:8081/simulate/null-pointer

# Database connection timeout
curl http://localhost:8081/simulate/db-timeout

Watch the flow

  1. Open the dashboard → http://localhost:8080
  2. Fire an error — the Alerts counter increments and a toast appears
  3. After ~10s — a Ticket is created by AI with a fix suggestion
  4. After another ~10s — a GitHub PR is opened; the PR link appears on the ticket and the Tokens Used counter updates

View logs in Grafana

Open http://localhost:3000 (admin / admin).

The pre-built dashboard shows:

  • ERROR and WARN counts (last 1h)
  • AI flow triggers and PRs created
  • Error rate over time graph
  • Live log streams filtered by ERROR, AI flow activity, and all logs

Dashboard Features

Feature Details
Mode badge Shows current mode — green AI or orange Human
Switch button Toggle between AI and Human mode at runtime
Total Alerts Auto-refreshes every 5s
Tickets Auto-refreshes every 5s
Tokens Used Updates only after a PR is created (reflects full flow cost)
Live alert feed Auto-refreshes every 3s
Recent tickets Auto-refreshes every 5s with PR links
Toast notifications Slide-in popups for new alert, new ticket, new PR

AI vs Human mode

  • AI mode — every new error triggers the full pipeline: analysis → ticket → PR
  • Human mode — alerts are logged only; no tickets or PRs are created
  • Switching back to AI mode ignores alerts that arrived during human mode — only new alerts trigger the AI flow

Project Structure

shTool/
├── faulty-app/          # Simulated error source
├── log-monitor/         # Log ingestion + ERROR filter
├── alert-service/       # Alert persistence + orchestrator notification
├── ticket-service/      # Ticket persistence
├── orchestrator/        # Flow coordinator (AI or Human)
├── ai-service/          # Spring AI + OpenAI RAG analysis
├── github-service/      # GitHub API integration
├── frontend/            # Thymeleaf + HTMX dashboard
├── observability/
│   ├── loki/            # Loki config
│   ├── promtail/        # Log scraper config
│   └── grafana/         # Dashboard + datasource provisioning
├── docker-compose.yml
└── .env                 # Your secrets (not committed)

Technology Stack

  • Java 17 + Spring Boot 3.x
  • Spring AI 1.0.0 — OpenAI chat + embeddings, in-memory vector store (RAG)
  • Spring Data JPA + H2 — in-memory persistence for alerts and tickets
  • Spring WebFlux / WebClient — reactive HTTP between services
  • Thymeleaf + HTMX — server-rendered UI with live partial updates
  • Grafana Loki + Promtail — log aggregation and dashboards
  • Docker Compose — single-command startup

Notes

  • The vector store and H2 databases are in-memory — all data is lost on container restart
  • GitHub PRs created are real — use a sandbox/test repository
  • The AI mode toggle is runtime-only — the container restarts with whatever AI_ENABLED is set to in .env
  • Token usage counter accumulates for the lifetime of the ai-service container and resets on restart

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages