Skip to content

Elasticsearch Collector

Captures Elasticsearch requests — method, endpoint, index, request/response body, timing, hits count, and duplicate detection.

Elasticsearch Collector panel

What It Captures

FieldDescription
methodHTTP method (GET, POST, PUT, DELETE)
endpointElasticsearch endpoint path
indexTarget index name
bodyRequest body (JSON)
statusRequest status (success or error)
statusCodeHTTP response status code
responseBodyResponse body
responseSizeResponse size in bytes
hitsCountNumber of search hits (for search queries)
durationRequest duration in seconds

Data Schema

json
{
    "requests": [
        {
            "method": "GET",
            "endpoint": "/users/_search",
            "index": "users",
            "body": "{\"query\": {\"match\": {\"name\": \"John\"}}}",
            "line": "/app/src/SearchService.php:42",
            "status": "success",
            "startTime": 1711878000.100,
            "endTime": 1711878000.150,
            "duration": 0.05,
            "statusCode": 200,
            "responseBody": "{\"hits\": {\"total\": 5, ...}}",
            "responseSize": 1024,
            "hitsCount": 5,
            "exception": null
        }
    ],
    "duplicates": {
        "groups": [],
        "totalDuplicatedCount": 0
    }
}

Summary (shown in debug entry list):

json
{
    "elasticsearch": {
        "total": 3,
        "errors": 0,
        "totalTime": 0.15,
        "duplicateGroups": 0,
        "totalDuplicatedCount": 0
    }
}

Contract

php
use AppDevPanel\Kernel\Collector\ElasticsearchCollector;
use AppDevPanel\Kernel\Collector\ElasticsearchRequestRecord;

// Option A: start/end pattern
$collector->collectRequestStart(
    id: 'es-1',
    method: 'GET',
    endpoint: '/users/_search',
    body: '{"query": {"match": {"name": "John"}}}',
    line: '/app/src/SearchService.php:42',
);
$collector->collectRequestEnd(
    id: 'es-1',
    statusCode: 200,
    responseBody: '{"hits": {"total": 5}}',
    responseSize: 1024,
);

// Option B: single record
$collector->logRequest(new ElasticsearchRequestRecord(
    method: 'GET',
    endpoint: '/users/_search',
    index: 'users',
    body: '{"query": {"match": {"name": "John"}}}',
    duration: 0.05,
    statusCode: 200,
    hitsCount: 5,
    line: '/app/src/SearchService.php:42',
));

See the dedicated Elasticsearch page for configuration and integration details.

Debug Panel

  • Request list — all ES requests with method, endpoint, status, and timing
  • Hits count — number of search results for search queries
  • Duplicate detection — highlights repeated identical requests
  • Error tracking — failed requests highlighted with error details

Released under the MIT License.