How can We integrate Elasticsearch, Fluentd, and Kibana with Bagisto?

If you are using Bagisto’s Elasticsearch feature for product search and want to extend it for centralized logging and monitoring, I suggest integrating Elasticsearch, Fluentd, and Kibana for a complete ELK-based setup.

  1. Elasticsearch Integration (Search & Analytics):
    Bagisto already supports Elasticsearch for enhanced product search. You can further optimize it by using Laravel Scout and the Elasticsearch PHP client for indexing and querying.

    • Install the required packages:

      composer require elasticsearch/elasticsearch
      composer require babenkoivan/scout-elasticsearch-driver
      
      
    • Configure config/scout.php and your .env:

      SCOUT_DRIVER=elasticsearch
      ELASTICSEARCH_HOST=127.0.0.1:9200
      
      
    • Index entities like products, categories, and customers to enable faster and more relevant search results.

    • This also keeps your search data aligned with analytics and log data stored in Elasticsearch.

  2. Fluentd Integration (Centralized Logging):
    Fluentd acts as a data collector that gathers all Laravel (Bagisto) logs and sends them to Elasticsearch.

    • Update Laravel config/logging.php to use the single or daily driver in JSON format so logs are easy for Fluentd to parse.

    • Set up a Fluentd agent on your Bagisto host to tail /storage/logs/laravel.log.

    • Configure Fluentd output to Elasticsearch:

<match laravel.*>
  @type elasticsearch
  host 127.0.0.1
  port 9200
  logstash_format true
</match>

  • This ensures all application logs are centralized and queryable in Elasticsearch.
  1. Kibana Integration (Visualization & Monitoring):
    • Connect Kibana to the same Elasticsearch cluster used above.

    • Create an index pattern laravel-* or bagisto-* to visualize logs.

    • Build dashboards for request counts, errors, performance metrics, and search trends.

    • This allows developers and admins to monitor the health and behavior of Bagisto in real time.

  2. End-to-End Flow:
    Bagisto (Laravel app) → generates logs → Fluentd → sends data → Elasticsearch → visualized in Kibana