PHPackages                             hakam/ai-log-inspector-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. hakam/ai-log-inspector-bundle

ActiveSymfony-bundle[Logging &amp; Monitoring](/categories/logging)

hakam/ai-log-inspector-bundle
=============================

AI-powered Symfony bundle to inspect, analyze, and interact with logs using LLMs and MCP agents.

00PHP

Since Sep 12Pushed 7mo agoCompare

[ Source](https://github.com/RamyHakam/ai-log-inspector-bundle)[ Packagist](https://packagist.org/packages/hakam/ai-log-inspector-bundle)[ RSS](/packages/hakam-ai-log-inspector-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

AI Log Inspector Bundle
=======================

[](#ai-log-inspector-bundle)

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![PHP](https://camo.githubusercontent.com/0be43eddd7df02c94a0fbc04aaa13d5250351c44ab63a3782498d66280b1767a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344382e322d626c75652e737667)](https://www.php.net/)[![Symfony](https://camo.githubusercontent.com/e5acef9cb7da7ec94c9ffa60a668d8eb07a55563f48b7a6601771f3a8db129f8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d253545362e34253230253743253743253230253545372e302d677265656e2e737667)](https://symfony.com/)[![Status](https://camo.githubusercontent.com/b20f69837572ea4469935526f223886218e4bf042f04c41e49179749fa643f0f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5374617475732d4578706572696d656e74616c2d7265642e737667)](#)

AI-powered Symfony bundle to inspect, analyze, and interact with logs using Large Language Models (LLMs) and Model Context Protocol (MCP) agents.

Features
--------

[](#features)

- 🤖 **AI-Powered Log Analysis**: Leverage LLMs to understand and analyze your application logs
- 🔍 **Intelligent Log Search**: Vector-based semantic search through log entries
- 📊 **Log Summarization**: Automatically summarize and extract insights from logs
- 🛠️ **Extensible Tool System**: Add custom analysis tools using Symfony's `#[AsTool]` attribute
- ⚙️ **Multiple AI Providers**: Support for OpenAI, Anthropic, Ollama, and more
- 💾 **Vector Storage**: Multiple vector store backends (Chroma, Pinecone, Weaviate)
- 📱 **Console Commands**: CLI interface for log analysis and indexing
- 🔄 **Auto-Indexing**: Automatic log indexing via event listeners

Installation
------------

[](#installation)

Install the bundle using Composer:

```
composer require hakam/ai-log-inspector-bundle
```

Configuration
-------------

[](#configuration)

Create a configuration file at `config/packages/hakam_ai_log_inspector.yaml`:

```
hakam_ai_log_inspector:
    ai_platform:
        provider: 'openai'  # or 'anthropic', 'ollama', etc.
        api_key: '%env(AI_API_KEY)%'
        model:
            name: 'gpt-4'
            capabilities: ['text_generation', 'embeddings']
            options:
                temperature: 0.7

    vector_store:
        provider: 'chroma'  # or 'pinecone', 'weaviate', etc.
        connection_string: '%env(VECTOR_STORE_URL)%'

    log_sources:
        - path: '%kernel.logs_dir%'
          pattern: '*.log'
        - path: '/var/log/application'
          pattern: '*.log'
```

### Environment Variables

[](#environment-variables)

Set the required environment variables in your `.env` file:

```
AI_API_KEY=your_ai_provider_api_key
VECTOR_STORE_URL=your_vector_store_connection_string
```

Usage
-----

[](#usage)

### Console Commands

[](#console-commands)

#### Ask Questions About Your Logs

[](#ask-questions-about-your-logs)

```
php bin/console ai:log-inspector:ask "What errors occurred in the last hour?"
php bin/console ai:log-inspector:ask "Show me all database connection errors"
php bin/console ai:log-inspector:ask "Summarize today's critical issues"
```

#### Index Logs for Analysis

[](#index-logs-for-analysis)

```
php bin/console ai:log-inspector:index
```

### Service Integration

[](#service-integration)

#### Using the Agent Factory (Recommended)

[](#using-the-agent-factory-recommended)

```
use Hakam\AiLogInspectorBundle\Factory\LogInspectorAgentFactory;
use Symfony\Component\DependencyInjection\Attribute\Autowire;

class LogAnalysisService
{
    public function __construct(
        #[Autowire(service: 'hakam_ai_log_inspector.agent_factory')]
        private LogInspectorAgentFactory $agentFactory
    ) {}

    public function analyzeError(string $errorMessage): string
    {
        $agent = $this->agentFactory->create();
        return $agent->interact("Analyze this error: {$errorMessage}");
    }

    public function getLogSummary(): string
    {
        $agent = $this->agentFactory->create();
        return $agent->interact("Provide a summary of recent log activity");
    }
}
```

#### Service Configuration

[](#service-configuration)

```
# config/services.yaml
services:
    App\Service\LogAnalysisService:
        arguments:
            $agentFactory: '@hakam_ai_log_inspector.agent_factory'
```

### Creating Custom Tools

[](#creating-custom-tools)

Create custom analysis tools by implementing `LogInspectorToolInterface` and using the `#[AsTool]` attribute:

```
