Skip to content

h3mantD/log-ingestor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Built With

  • Laravel

(back to top)

Prerequisites

Prerequisites for running the projects are

  • Docker
  • MongoDb database connection URL

Installation

  1. Clone the repo
    git clone https://github.com/h3mantD/log-ingestor.git
  2. Go in project directory
    cd log-ingestor
  3. Create .env file using .env.sample
    cp .env.sample .env
  4. Add your mongodb connection url in .env
    DB_URL=<your-mongodb-connection-string>
  5. Run the docker
    docker compose up -d
    
  6. Open the docker containers shell to install the dependency packages
    docker exec -it log-ingestor-laravel.test-1 sh
  7. Once you are in container shell then execute following commands to install dependencies
    composer install
    npm install
    npm run build
  8. Exit the container shell
    exit
  9. Restart the docker container
    docker restart log-ingestor-laravel.test-1

(back to top)

API Documentation

The purpose of this API is to ingest logs into the database.

Authentication

No authentication is required.

Base URL

The base URL for the API is http://localhost:3000/api/v1.

Endpoints

1. POST /ingest-logs

Ingests logs into the database.

Request

curl -X POST   -H "Accept: application/vnd.api+json"   -H "Content-Type: application/vnd.api+json"   -d '{
    "logs": {
      "level": "error",
      "message": "Failed to connect to DB",
      "resourceId": "server-1234",
      "timestamp": "2023-09-15T08:00:00Z",
      "traceId": "abc-xyz-123",
      "spanId": "span-456",
      "commit": "5e5342f",
      "metadata": {
        "parentResourceId": "server-0987"
      }
    }
  }'   http://localhost:3000/api/v1/ingest-logs

2. GET /logs

Retrieve logs with optional pagination and filtering.

Request

# Retrieve logs, default page size (10 logs per page)
curl -X GET http://localhost:3000/api/v1/logs

# Retrieve logs of page 2
curl -X GET http://localhost:3000/api/v1/logs?page=2

# Retrieve logs of page 2 with page size 1
curl -X GET http://localhost:3000/api/v1/logs?page=2&page_size=1

# Filtering level with error
Curl -X GET http://localhost:3000/api/v1/logs?level=error

# Nesting filtering with level and message
Curl -X GET http://localhost:3000/api/v1/logs?level=error&message=Failed%20to%20connect%20to%20DB

# Filtering with metadata.parentResourceId
Curl -X GET http://localhost:3000/api/v1/logs?metadata.parentResourceId=server-0987

UI Details

Visit localhost:3000 to view the UI

  1. Register a new user
  2. Login with the registered user
  3. Now you can see the the logs in the UI and also you can filter them

(back to top)

Contact

h3mantd - @h3mant_d

(back to top)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages