This project is a Log Ingestion System designed to ingest logs into both Elasticsearch and PostgreSQL databases. It provides a simple HTTP API for log ingestion and a query interface to search and retrieve logs.
The system is designed with the following components:
-
Log Ingestor: An Express.js server that receives logs via HTTP POST requests, ingests them into Elasticsearch, and stores them in PostgreSQL.
-
Query Interface: Another Express.js server that allows querying logs based on various parameters like level, message, timestamp, and more.
-
Elasticsearch: Used as the primary storage for logs.
-
PostgreSQL: Used as a secondary storage for logs.
- Ingest logs via HTTP POST requests.
- Search logs based on different parameters using the query interface.
-
Clone the repository:
git clone https://github.com/Sranjan0208/Log-Ingestor.git cd log-ingestion
-
Install dependencies:
npm install
-
Setup environment variables:
Create a
.env
file in the log-ingestor directory and add the following:# PostgreSQL Configuration DATABASE_URL=postgres://alex:AbC123dEf@ep-cool-darkness-123456.us-east-2.aws.neon.tech/dbname
-
Run the Log Ingestor:
cd log-ingestor npm install node logIngestor.js
-
Run the Query Interface:
cd query-interface npm install node queryInterface.js
-
Ingest logs:
curl -X POST -H "Content-Type: application/json" -d @common/sampleLogs.json http://localhost:3000/logs
-
Query logs:
curl "http://localhost:3001/logs?level=error"
- No Shard Available: If Elasticsearch shows "No shard available" issues, you might need to allocate the primary shard to a node. Refer to Elasticsearch documentation for solutions.